Skip to content

services/facebook: fix incorrect facebook video being downloaded (#1499)#1533

Open
sunilpar wants to merge 1 commit intoimputnet:mainfrom
sunilpar:fix/issue-1499
Open

services/facebook: fix incorrect facebook video being downloaded (#1499)#1533
sunilpar wants to merge 1 commit intoimputnet:mainfrom
sunilpar:fix/issue-1499

Conversation

@sunilpar
Copy link
Copy Markdown

@sunilpar sunilpar commented Apr 3, 2026

fixes #1499

summary

fixes an issue where incorrect facebook video was being downloaded due to regex matching a different url from the fetched html.

cause

in some low resolution facebook videos using the share/:shareType/:id pattern, there is no hd url present.

example:

{
  "browser_native_sd_url": "https://video.fktm3-1.fna.fbcdn.net/o1/v/t2/f2/m366/...",
  "browser_native_hd_url": null,
  "id": "1972277293595444"
}

the previous regex:

const hd = html.match('"browser_native_hd_url":(".*?")');
const sd = html.match('"browser_native_sd_url":(".*?")');

would incorrectly match another video's hd url, resulting in downloading the wrong video.

changes

  1. added null checks before processing hd/sd urls
const hd = html.match('"browser_native_hd_url":(null|".*?")');
const sd = html.match('"browser_native_sd_url":(null|".*?")');
  1. ensured only valid urls are parsed and used
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 there is a better approach for filtering null or invalid urls, suggestions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Facebook] Downloading wrong video

2 participants