[PR #4005] [MERGED] Fix broken YT scraping with YT API #4492

Closed
opened 2026-02-22 18:35:56 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/4005
Author: @bobbercheng
Created: 6/14/2025
Status: Merged
Merged: 7/7/2025
Merged by: @timothycarambat

Base: masterHead: master


📝 Commits (4)

  • 6c9f3c8 Fix broken YT scraping with YT API
  • 54aad76 refactor youtube transcript class/add jsdoc comments
  • 4efc7f0 Merge branch 'master' into test-yt-fix
  • 0229eb6 fix test

📊 Changes

2 files changed (+142 additions, -78 deletions)

View changed files

collector/__tests__/utils/extensions/YoutubeTranscript/YoutubeLoader/youtube-transcript.test.js (+18 -0)
📝 collector/utils/extensions/YoutubeTranscript/YoutubeLoader/youtube-transcript.js (+124 -78)

📄 Description

Pull Request Type

  • feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 🔨 chore
  • 📝 docs

Relevant Issues

resolves #4004

What is in this change?

Use Youtube API https://www.youtube.com/youtubei/v1/get_transcript to get transcript instead of https://www.youtube.com/ptracking from youtube scripts. For unknown reason, https://www.youtube.com/ptracking returns empty content for xml transcript and causes current yt scraping fails.

Additional Information

As Youtube API has rate limit, scraping may fails after reaching api limit. For long term solution, it's better to offload ty scraping to npm package youtubei like https://github.com/LuanRT/YouTube.js/blob/main/examples/transcript/index.ts.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

🔄 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/Mintplex-Labs/anything-llm/pull/4005 **Author:** [@bobbercheng](https://github.com/bobbercheng) **Created:** 6/14/2025 **Status:** ✅ Merged **Merged:** 7/7/2025 **Merged by:** [@timothycarambat](https://github.com/timothycarambat) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (4) - [`6c9f3c8`](https://github.com/Mintplex-Labs/anything-llm/commit/6c9f3c86f63ffb494e18bd5f787586b5e59bd605) Fix broken YT scraping with YT API - [`54aad76`](https://github.com/Mintplex-Labs/anything-llm/commit/54aad76fe77f765427c4e0b949cf54f1e5471c11) refactor youtube transcript class/add jsdoc comments - [`4efc7f0`](https://github.com/Mintplex-Labs/anything-llm/commit/4efc7f000e11c59010b9b0a0209682c0d7b9f7d4) Merge branch 'master' into test-yt-fix - [`0229eb6`](https://github.com/Mintplex-Labs/anything-llm/commit/0229eb65124494c3546453488ede59411af789ce) fix test ### 📊 Changes **2 files changed** (+142 additions, -78 deletions) <details> <summary>View changed files</summary> ➕ `collector/__tests__/utils/extensions/YoutubeTranscript/YoutubeLoader/youtube-transcript.test.js` (+18 -0) 📝 `collector/utils/extensions/YoutubeTranscript/YoutubeLoader/youtube-transcript.js` (+124 -78) </details> ### 📄 Description ### Pull Request Type <!-- For change type, change [ ] to [x]. --> - [ ] ✨ feat - [x] 🐛 fix - [ ] ♻️ refactor - [ ] 💄 style - [ ] 🔨 chore - [ ] 📝 docs ### Relevant Issues <!-- Use "resolves #xxx" to auto resolve on merge. Otherwise, please use "connect #xxx" --> resolves #4004 ### What is in this change? <!-- Describe the changes in this PR that are impactful to the repo. --> Use Youtube API https://www.youtube.com/youtubei/v1/get_transcript to get transcript instead of https://www.youtube.com/ptracking from youtube scripts. For unknown reason, https://www.youtube.com/ptracking returns empty content for xml transcript and causes current yt scraping fails. ### Additional Information <!-- Add any other context about the Pull Request here that was not captured above. --> As Youtube API has rate limit, scraping may fails after reaching api limit. For long term solution, it's better to offload ty scraping to npm package [youtubei](https://www.npmjs.com/package/youtubei.js) like https://github.com/LuanRT/YouTube.js/blob/main/examples/transcript/index.ts. ### Developer Validations <!-- All of the applicable items should be checked. --> - [x] I ran `yarn lint` from the root of the repo & committed changes - [x] Relevant documentation has been updated - [x] I have tested my code functionality - [x] Docker build succeeds locally --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-22 18:35:56 -05:00
yindo closed this issue 2026-02-22 18:35:56 -05:00
yindo changed title from [PR #4005] Fix broken YT scraping with YT API to [PR #4005] [MERGED] Fix broken YT scraping with YT API 2026-06-05 15:18:50 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#4492