services/facebook: fix incorrect sd video url selection (#1499)

This commit is contained in:
Sunil Parajuli 2026-04-03 09:12:05 +05:45
parent a62d734993
commit f6df70ef95

View file

@ -37,11 +37,11 @@ export default async function({ id, shareType, shortLink, dispatcher }) {
if (!html) return { error: "fetch.fail" };
const urls = [];
const hd = html.match('"browser_native_hd_url":(".*?")');
const sd = html.match('"browser_native_sd_url":(".*?")');
const hd = html.match('"browser_native_hd_url":(null|".*?")');
const sd = html.match('"browser_native_sd_url":(null|".*?")');
if (hd?.[1]) urls.push(JSON.parse(hd[1]));
if (sd?.[1]) urls.push(JSON.parse(sd[1]));
if (hd?.[1] && hd[1] !== 'null') urls.push(JSON.parse(hd[1]));
if (sd?.[1] && sd[1] !== 'null') urls.push(JSON.parse(sd[1]));
if (!urls.length) {
return { error: "fetch.empty" };