mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
fix: facebook shared link pattern with clean up
This commit is contained in:
parent
98929c493c
commit
20975cb0fd
@ -26,19 +26,14 @@ function resolveUrl(url) {
|
||||
|
||||
export default async function({ sourceUrl, shortLink, username, id }) {
|
||||
const isShortLink = !!shortLink?.length
|
||||
const isSharedLink = !!sourceUrl.match(/\/share\/v\//)?.length
|
||||
const isSharedLink = !!sourceUrl.match(/\/share\/\w\//)?.length
|
||||
|
||||
let url = isShortLink
|
||||
? `https://fb.watch/${shortLink}`
|
||||
: `https://web.facebook.com/${username}/videos/${id}`
|
||||
|
||||
if (isShortLink) {
|
||||
url = await resolveUrl(url)
|
||||
}
|
||||
|
||||
if (isSharedLink) {
|
||||
url = sourceUrl
|
||||
}
|
||||
if (isShortLink) url = await resolveUrl(url)
|
||||
if (isSharedLink) url = (sourceUrl)
|
||||
|
||||
const html = await fetch(url, { headers })
|
||||
.then(r => r.text())
|
||||
@ -50,12 +45,8 @@ export default async function({ sourceUrl, shortLink, username, id }) {
|
||||
const hd = html.match('"browser_native_hd_url":(".*?")')
|
||||
const sd = html.match('"browser_native_sd_url":(".*?")')
|
||||
|
||||
if (hd?.[1]) {
|
||||
urls.push(JSON.parse(hd[1]))
|
||||
}
|
||||
if (sd?.[1]) {
|
||||
urls.push(JSON.parse(sd[1]))
|
||||
}
|
||||
if (hd?.[1]) urls.push(JSON.parse(hd[1]))
|
||||
if (sd?.[1]) urls.push(JSON.parse(sd[1]))
|
||||
|
||||
if (!urls.length) {
|
||||
return { error: 'ErrorEmptyDownload' };
|
||||
|
Loading…
Reference in New Issue
Block a user