mirror of
https://github.com/imputnet/cobalt.git
synced 2025-01-15 19:35:31 +00:00
support for linkedin videos
This commit is contained in:
parent
dcb3cf3673
commit
26ea2b12c0
|
@ -16,6 +16,7 @@ this list is not final and keeps expanding over time. if support for a service y
|
||||||
| bilibili.com | ✅ | ✅ | ✅ | ➖ | ➖ |
|
| bilibili.com | ✅ | ✅ | ✅ | ➖ | ➖ |
|
||||||
| instagram posts & stories | ✅ | ✅ | ✅ | ➖ | ➖ |
|
| instagram posts & stories | ✅ | ✅ | ✅ | ➖ | ➖ |
|
||||||
| instagram reels | ✅ | ✅ | ✅ | ➖ | ➖ |
|
| instagram reels | ✅ | ✅ | ✅ | ➖ | ➖ |
|
||||||
|
| linkedin videos | ✅ | ❌ | ❌ | ✅ | ✅ |
|
||||||
| pinterest | ✅ | ✅ | ✅ | ➖ | ➖ |
|
| pinterest | ✅ | ✅ | ✅ | ➖ | ➖ |
|
||||||
| reddit | ✅ | ✅ | ✅ | ❌ | ❌ |
|
| reddit | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||||
| rutube | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| rutube | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
"express-rate-limit": "^6.3.0",
|
"express-rate-limit": "^6.3.0",
|
||||||
"ffmpeg-static": "^5.1.0",
|
"ffmpeg-static": "^5.1.0",
|
||||||
"hls-parser": "^0.10.7",
|
"hls-parser": "^0.10.7",
|
||||||
|
"libxmljs": "^1.0.11",
|
||||||
"nanoid": "^4.0.2",
|
"nanoid": "^4.0.2",
|
||||||
"node-cache": "^5.1.2",
|
"node-cache": "^5.1.2",
|
||||||
"psl": "1.9.0",
|
"psl": "1.9.0",
|
||||||
|
|
|
@ -24,6 +24,7 @@ import pinterest from "./services/pinterest.js";
|
||||||
import streamable from "./services/streamable.js";
|
import streamable from "./services/streamable.js";
|
||||||
import twitch from "./services/twitch.js";
|
import twitch from "./services/twitch.js";
|
||||||
import rutube from "./services/rutube.js";
|
import rutube from "./services/rutube.js";
|
||||||
|
import linkedin from "./services/linkedin.js";
|
||||||
|
|
||||||
export default async function(host, patternMatch, url, lang, obj) {
|
export default async function(host, patternMatch, url, lang, obj) {
|
||||||
assert(url instanceof URL);
|
assert(url instanceof URL);
|
||||||
|
@ -158,6 +159,12 @@ export default async function(host, patternMatch, url, lang, obj) {
|
||||||
isAudioOnly: isAudioOnly
|
isAudioOnly: isAudioOnly
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case "linkedin":
|
||||||
|
r = await linkedin({
|
||||||
|
url,
|
||||||
|
id: patternMatch.id
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return apiJSON(0, { t: errorUnsupported(lang) });
|
return apiJSON(0, { t: errorUnsupported(lang) });
|
||||||
}
|
}
|
||||||
|
|
27
src/modules/processing/services/linkedin.js
Normal file
27
src/modules/processing/services/linkedin.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import libxmljs from "libxmljs";
|
||||||
|
|
||||||
|
export default async function(obj) {
|
||||||
|
const htmlContent = await fetch(obj.url.href).then((r) => {
|
||||||
|
return r.status === 200 ? r.text() : false
|
||||||
|
}).catch(() => { return false });
|
||||||
|
const htmlDoc = await libxmljs.parseHtmlAsync(htmlContent)
|
||||||
|
.then((d) => { return d });
|
||||||
|
const rawData = htmlDoc.find("//script[@type='application/ld+json']")[0];
|
||||||
|
const json = JSON.parse(rawData.text());
|
||||||
|
|
||||||
|
let fileMetadata = {
|
||||||
|
title: json.video.name,
|
||||||
|
author: json.author.name
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
urls: json.video.contentUrl,
|
||||||
|
filenameAttributes: {
|
||||||
|
service: "linkedin",
|
||||||
|
id: obj.id,
|
||||||
|
title: fileMetadata.title,
|
||||||
|
author: fileMetadata.author,
|
||||||
|
extension: "mp4"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -106,6 +106,12 @@
|
||||||
"tld": "ru",
|
"tld": "ru",
|
||||||
"patterns": ["video/:id", "play/embed/:id"],
|
"patterns": ["video/:id", "play/embed/:id"],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
"linkedin": {
|
||||||
|
"alias": "linkedin posts",
|
||||||
|
"subdomains": ["m"],
|
||||||
|
"patterns": ["posts/:id"],
|
||||||
|
"enabled": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,9 @@ export const testers = {
|
||||||
patternMatch.postId?.length <= 12
|
patternMatch.postId?.length <= 12
|
||||||
|| (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24),
|
|| (patternMatch.username?.length <= 30 && patternMatch.storyId?.length <= 24),
|
||||||
|
|
||||||
|
"linkedin": (patternMatch) =>
|
||||||
|
patternMatch.id?.length >= 0,
|
||||||
|
|
||||||
"ok": (patternMatch) =>
|
"ok": (patternMatch) =>
|
||||||
patternMatch.id?.length <= 16,
|
patternMatch.id?.length <= 16,
|
||||||
|
|
||||||
|
|
|
@ -1171,5 +1171,14 @@
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"status": "stream"
|
"status": "stream"
|
||||||
}
|
}
|
||||||
|
}],
|
||||||
|
"linkedin": [{
|
||||||
|
"name": "video post",
|
||||||
|
"url": "https://www.linkedin.com/posts/hadiyarajesh_kotlin-android-coroutines-activity-7144537175857037312-JKmR",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "stream"
|
||||||
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue