[PR #1533] services/facebook: fix incorrect facebook video being downloaded (#1499) #5864

Open
opened 2026-04-16 01:00:22 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/imputnet/cobalt/pull/1533
Author: @sunilpar
Created: 4/3/2026
Status: 🔄 Open

Base: mainHead: fix/issue-1499


📝 Commits (1)

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

📊 Changes

1 file changed (+4 additions, -4 deletions)

View changed files

📝 api/src/processing/services/facebook.js (+4 -4)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/imputnet/cobalt/pull/1533 **Author:** [@sunilpar](https://github.com/sunilpar) **Created:** 4/3/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/issue-1499` --- ### 📝 Commits (1) - [`f6df70e`](https://github.com/imputnet/cobalt/commit/f6df70ef95d8a35eb2c92e3ea654bc5437629954) services/facebook: fix incorrect sd video url selection (#1499) ### 📊 Changes **1 file changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `api/src/processing/services/facebook.js` (+4 -4) </details> ### 📄 Description 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: ```json { "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: ```js 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 ```js const hd = html.match('"browser_native_hd_url":(null|".*?")'); const sd = html.match('"browser_native_sd_url":(null|".*?")'); ``` 2. ensured only valid urls are parsed and used ```js 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 01:00:22 -05:00
Sign in to join this conversation.