facebook: add shared link pattern

This commit is contained in:
Brama Udi 2024-05-11 14:13:45 +07:00 committed by Brama Udi
parent 7f8dcde98c
commit f1b1d35ea9
No known key found for this signature in database
GPG Key ID: C163FBB0BB454FBD
3 changed files with 9 additions and 3 deletions

View File

@ -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", {

View File

@ -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)

View File

@ -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
} }