mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 11:18:28 +00:00
facebook: add shared link pattern
This commit is contained in:
parent
7f8dcde98c
commit
f1b1d35ea9
@ -194,7 +194,7 @@ export default async function(host, patternMatch, lang, obj) {
|
|||||||
id: patternMatch.id
|
id: patternMatch.id
|
||||||
});
|
});
|
||||||
case "facebook":
|
case "facebook":
|
||||||
r = await facebook(patternMatch);
|
r = await facebook(url.href, patternMatch);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return createResponse("error", {
|
return createResponse("error", {
|
||||||
|
@ -24,8 +24,9 @@ function resolveUrl(url) {
|
|||||||
.catch(() => false)
|
.catch(() => false)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function ({ shortLink, username, id }) {
|
export default async function (sourceUrl, { shortLink, username, id }) {
|
||||||
const isShortLink = !!shortLink?.length
|
const isShortLink = !!shortLink?.length
|
||||||
|
const isSharedLink = !!sourceUrl.match(/\/share\/v\//)?.length
|
||||||
|
|
||||||
let url = isShortLink
|
let url = isShortLink
|
||||||
? `https://fb.watch/${shortLink}`
|
? `https://fb.watch/${shortLink}`
|
||||||
@ -35,6 +36,10 @@ export default async function ({ shortLink, username, id }) {
|
|||||||
url = await resolveUrl(url)
|
url = await resolveUrl(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isSharedLink) {
|
||||||
|
url = sourceUrl
|
||||||
|
}
|
||||||
|
|
||||||
const html = await fetch(url, { headers })
|
const html = await fetch(url, { headers })
|
||||||
.then(r => r.text())
|
.then(r => r.text())
|
||||||
.catch(() => false)
|
.catch(() => false)
|
||||||
|
@ -127,7 +127,8 @@
|
|||||||
"_shortLink/:shortLink",
|
"_shortLink/:shortLink",
|
||||||
":username/videos/:caption/:id",
|
":username/videos/:caption/:id",
|
||||||
":username/videos/:id",
|
":username/videos/:id",
|
||||||
"reel/:id"
|
"reel/:id",
|
||||||
|
"share/v/:id"
|
||||||
],
|
],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user