chore: clean up removing unnecessarily code

This commit is contained in:
Brama Udi 2024-07-07 20:37:08 +07:00
parent f1b1d35ea9
commit fcec613c84
No known key found for this signature in database
GPG Key ID: C163FBB0BB454FBD

View File

@ -47,26 +47,21 @@ export default async function (sourceUrl, { shortLink, username, id }) {
if (!html) return { error: 'ErrorCouldntFetch' }; if (!html) return { error: 'ErrorCouldntFetch' };
const urls = [] const urls = []
const hd = html.match('"browser_native_hd_url":"(.*?)"') const hd = html.match('"browser_native_hd_url":(".*?")')
const sd = html.match('"browser_native_sd_url":"(.*?)"') const sd = html.match('"browser_native_sd_url":(".*?")')
if (hd?.length) { if (hd?.[1]) {
urls.push(JSON.parse(`["${hd[1]}"]`)[0]) urls.push(JSON.parse(hd[1]))
} }
if (sd?.length) { if (sd?.[1]) {
urls.push(JSON.parse(`["${sd[1]}"]`)[0]) urls.push(JSON.parse(sd[1]))
} }
if (!urls.length) { if (!urls.length) {
return { error: 'ErrorEmptyDownload' }; return { error: 'ErrorEmptyDownload' };
} }
let filename = `facebook_${id}.mp4` let filename = `facebook_${id || shortLink}.mp4`
if (isShortLink) {
filename = `facebook_${shortLink}.mp4`
} else if (username?.length && username !== 'user') {
filename = `facebook_${username}_${id}.mp4`
}
return { return {
urls: urls[0], urls: urls[0],