[GH-ISSUE #6208] issue: youtube video errors #134011

Closed
opened 2026-05-24 23:35:39 -05:00 by GiteaMirror · 12 comments
Owner

Originally created by @zabirauf on GitHub (Oct 16, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/6208

Bug Report

Installation Method

Installed using Docker

Environment

  • Open WebUI Version: 0.3.32

  • Ollama (if applicable): 0.3.12

  • Operating System: Ubuntu 22.04

  • Browser (if applicable): Safari on Mac 15.0.1

Confirmation:

  • I have read and followed all the instructions provided in the README.md.
  • I am on the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below.

Expected Behavior:

Expect the Youtube video info to be extracted

Actual Behavior:

Something went wrong :/ Exception while accessing title of https://www.youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube

Description

Bug Summary:
Using #youtubeurl pretty consistently runs into following error

Something went wrong :/ Exception while accessing title of https://www.youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube

Reproduction Details

Steps to Reproduce:

  1. Copy a Youtube URL e.g. https://www.youtube.com/watch?v=LJbUaciFdV8
  2. In OpenWebUI add it #https://www.youtube.com/watch?v=LJbUaciFdV8which gets detected as Youtube URL
    image
  3. Press Enter

Logs and Screenshots

Screenshot 2024-10-15 at 20 49 37

Docker Container Logs:

INFO:     100.85.106.59:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 200 OK
ERROR [open_webui.apps.retrieval.main] Exception while accessing title of https://youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 341, in title
    self._title = self.vid_info['videoDetails']['title']
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'videoDetails'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/backend/open_webui/apps/retrieval/main.py", line 925, in process_youtube_video
    docs = loader.load()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 258, in load
    video_info = self._get_video_info()
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 325, in _get_video_info
    "title": yt.title or "Unknown",
             ^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 346, in title
    raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube
INFO:     100.85.106.59:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 400 Bad Request
Originally created by @zabirauf on GitHub (Oct 16, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/6208 # Bug Report ## Installation Method Installed using Docker ## Environment - **Open WebUI Version:** 0.3.32 - **Ollama (if applicable):** 0.3.12 - **Operating System:** Ubuntu 22.04 - **Browser (if applicable):** Safari on Mac 15.0.1 **Confirmation:** - [X] I have read and followed all the instructions provided in the README.md. - [X] I am on the latest version of both Open WebUI and Ollama. - [ ] I have included the browser console logs. - [X] I have included the Docker container logs. - [X] I have provided the exact steps to reproduce the bug in the "Steps to Reproduce" section below. ## Expected Behavior: Expect the Youtube video info to be extracted ## Actual Behavior: Something went wrong :/ Exception while accessing title of https://www.youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube ## Description **Bug Summary:** Using #youtubeurl pretty consistently runs into following error ``` Something went wrong :/ Exception while accessing title of https://www.youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube ``` ## Reproduction Details **Steps to Reproduce:** 1. Copy a Youtube URL e.g. https://www.youtube.com/watch?v=LJbUaciFdV8 2. In OpenWebUI add it #https://www.youtube.com/watch?v=LJbUaciFdV8which gets detected as Youtube URL ![image](https://github.com/user-attachments/assets/6a598bba-4d8d-4822-9b23-1b36eb173ff3) 3. Press Enter ## Logs and Screenshots ![Screenshot 2024-10-15 at 20 49 37](https://github.com/user-attachments/assets/85ec0068-aa37-4f07-94fb-875c1f00a1a1) **Docker Container Logs:** ``` INFO: 100.85.106.59:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 200 OK ERROR [open_webui.apps.retrieval.main] Exception while accessing title of https://youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 341, in title self._title = self.vid_info['videoDetails']['title'] ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ KeyError: 'videoDetails' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/backend/open_webui/apps/retrieval/main.py", line 925, in process_youtube_video docs = loader.load() ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 258, in load video_info = self._get_video_info() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 325, in _get_video_info "title": yt.title or "Unknown", ^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 346, in title raise exceptions.PytubeError( pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=LJbUaciFdV8. Please file a bug report at https://github.com/pytube/pytube INFO: 100.85.106.59:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 400 Bad Request ```
Author
Owner

@thiswillbeyourgithub commented on GitHub (Oct 16, 2024):

Wouldn't it be better if open-webui used ytdlp? I've had far better results with it for fetching youtube data.

<!-- gh-comment-id:2415807990 --> @thiswillbeyourgithub commented on GitHub (Oct 16, 2024): Wouldn't it be better if open-webui used [ytdlp](https://github.com/ytdl-patched/ytdl-patched)? I've had far better results with it for fetching youtube data.
Author
Owner

@tjbck commented on GitHub (Oct 16, 2024):

Seems like pytube library is being unmaintained at the moment, PR welcome!

<!-- gh-comment-id:2416114722 --> @tjbck commented on GitHub (Oct 16, 2024): Seems like pytube library is being unmaintained at the moment, PR welcome!
Author
Owner

@rgaricano commented on GitHub (Oct 19, 2024):

Seems like pytube library is being unmaintained at the moment, PR welcome!

maybe pytubefix? (more update lib)
https://github.com/JuanBindez/pytubefix
https://pypi.org/project/pytubefix/

<!-- gh-comment-id:2423963141 --> @rgaricano commented on GitHub (Oct 19, 2024): > Seems like pytube library is being unmaintained at the moment, PR welcome! maybe pytubefix? (more update lib) https://github.com/JuanBindez/pytubefix https://pypi.org/project/pytubefix/
Author
Owner

@Varming73 commented on GitHub (Oct 20, 2024):

I have a similar problem (and I understand it's because of the usuage of pytube)

INFO:     87.104.45.18:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 400 Bad Request
DEBUG [open_webui.main] Commit session after request
ERROR [open_webui.apps.retrieval.main] Exception while accessing title of https://youtube.com/watch?v=fJszPAk-WHk. Please file a bug report at https://github.com/pytube/pytube
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 341, in title
    self._title = self.vid_info['videoDetails']['title']
                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'videoDetails'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/backend/open_webui/apps/retrieval/main.py", line 925, in process_youtube_video
    docs = loader.load()
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 258, in load
    video_info = self._get_video_info()
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 325, in _get_video_info
    "title": yt.title or "Unknown",
             ^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 346, in title
    raise exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=fJszPAk-WHk. Please file a bug report at https://github.com/pytube/pytube
<!-- gh-comment-id:2424793269 --> @Varming73 commented on GitHub (Oct 20, 2024): I have a similar problem (and I understand it's because of the usuage of pytube) ``` INFO: 87.104.45.18:0 - "POST /retrieval/api/v1/process/youtube HTTP/1.1" 400 Bad Request DEBUG [open_webui.main] Commit session after request ERROR [open_webui.apps.retrieval.main] Exception while accessing title of https://youtube.com/watch?v=fJszPAk-WHk. Please file a bug report at https://github.com/pytube/pytube Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 341, in title self._title = self.vid_info['videoDetails']['title'] ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ KeyError: 'videoDetails' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/app/backend/open_webui/apps/retrieval/main.py", line 925, in process_youtube_video docs = loader.load() ^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 258, in load video_info = self._get_video_info() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/langchain_community/document_loaders/youtube.py", line 325, in _get_video_info "title": yt.title or "Unknown", ^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pytube/__main__.py", line 346, in title raise exceptions.PytubeError( pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=fJszPAk-WHk. Please file a bug report at https://github.com/pytube/pytube ```
Author
Owner

@Tweeeks commented on GitHub (Oct 21, 2024):

I think there is a way to fix it. Need to fork it and make some changes:
it pytube/cipher.py:
function_patterns = [
# https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
# 48416bc4a8
# var Bpa = [iha];
# ...
# a.C && (b = a.get("n")) && (b = Bpa0, a.set("n", b),
# Bpa.length || iha("")) }};
# In the above case, iha is the relevant function name
r'a.[a-zA-Z]\s*&&\s*([a-z]\s*=\sa.get("n"))\s&&\s*'
r'([a-z]\s*=\s*([a-zA-Z0-9$]+)([\d+])?([a-z])',
]
# https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377
# 48416bc4a8
# var Bpa = [iha];
# ...
# a.C && (b = a.get("n")) && (b = Bpa0, a.set("n", b),
# Bpa.length || iha("")) }};
# In the above case, iha is the relevant function name
r'a.[a-zA-Z]\s*&&\s*([a-z]\s*=\sa.get("n"))\s&&.?||\s([a-z]+)',
r'([a-z]\s*=\s*([a-zA-Z0-9$]+)([\d+])?([a-z])',
r'([a-z]\s*=\s*([a-zA-Z0-9$]+)([\d+])([a-z])',
]

<!-- gh-comment-id:2426133835 --> @Tweeeks commented on GitHub (Oct 21, 2024): I think there is a way to fix it. Need to fork it and make some changes: it pytube/cipher.py: function_patterns = [ # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377 # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8 # var Bpa = [iha]; # ... # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b), # Bpa.length || iha("")) }}; # In the above case, `iha` is the relevant function name r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&\s*' r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)', ] # https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-865985377 # https://github.com/yt-dlp/yt-dlp/commit/48416bc4a8f1d5ff07d5977659cb8ece7640dcd8 # var Bpa = [iha]; # ... # a.C && (b = a.get("n")) && (b = Bpa[0](b), a.set("n", b), # Bpa.length || iha("")) }}; # In the above case, `iha` is the relevant function name r'a\.[a-zA-Z]\s*&&\s*\([a-z]\s*=\s*a\.get\("n"\)\)\s*&&.*?\|\|\s*([a-z]+)', r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])?\([a-z]\)', r'\([a-z]\s*=\s*([a-zA-Z0-9$]+)(\[\d+\])\([a-z]\)', ]
Author
Owner

@Varming73 commented on GitHub (Oct 21, 2024):

I would like to test if needed, just tell me what you need me to do. Am running dockerized so that might limit it a bit.

<!-- gh-comment-id:2426553591 --> @Varming73 commented on GitHub (Oct 21, 2024): I would like to test if needed, just tell me what you need me to do. Am running dockerized so that might limit it a bit.
Author
Owner

@tjbck commented on GitHub (Oct 24, 2024):

Directly using yt-dlp sounds like would be the best option here like @thiswillbeyourgithub suggested. PR welcome!

<!-- gh-comment-id:2436512676 --> @tjbck commented on GitHub (Oct 24, 2024): Directly using yt-dlp sounds like would be the best option here like @thiswillbeyourgithub suggested. PR welcome!
Author
Owner

@thiswillbeyourgithub commented on GitHub (Oct 25, 2024):

Directly using yt-dlp sounds like would be the best option here like @thiswillbeyourgithub suggested. PR welcome!

Well that's terrific timing I just fixed my rag app to use yt-dlp instead of relying on langchain's youtube loader that too crashed because of pytube.

Unfortunately I won't be available for the PR (not on a computer) but the code is in a single function here : ab34e27088/wdoc/utils/loaders.py (L2221)

Basically it downloads all the subtitles names. Then look for any of the subtitles corresponding to the accepted language code like en or fr. And it downloads the subtitle using the URL that is a value at this specific key. Then cleans the chapters and timecodes to save a lot of tokens. And store the result as a langchain Document.

I haven't thorougly tested it but it seemed fine and is at least a good start.

<!-- gh-comment-id:2436580921 --> @thiswillbeyourgithub commented on GitHub (Oct 25, 2024): > Directly using yt-dlp sounds like would be the best option here like @thiswillbeyourgithub suggested. PR welcome! Well that's terrific timing I just fixed my rag app to use yt-dlp instead of relying on langchain's youtube loader that too crashed because of pytube. Unfortunately I won't be available for the PR (not on a computer) but the code is in a single function here : https://github.com/thiswillbeyourgithub/wdoc/blob/ab34e27088ba8d961565ac63d4bedb0f98c3fc49/wdoc/utils/loaders.py#L2221 Basically it downloads all the subtitles names. Then look for any of the subtitles corresponding to the accepted language code like en or fr. And it downloads the subtitle using the URL that is a value at this specific key. Then cleans the chapters and timecodes to save a lot of tokens. And store the result as a langchain Document. I haven't thorougly tested it but it seemed fine and is at least a good start.
Author
Owner

@grigio commented on GitHub (Oct 26, 2024):

+1 currently I'm using a workaround withyt-dlp

<!-- gh-comment-id:2439426995 --> @grigio commented on GitHub (Oct 26, 2024): +1 currently I'm using a workaround with`yt-dlp`
Author
Owner

@VideoFX commented on GitHub (Oct 30, 2024):

I am also getting this error lately. Is there any more specifics/help on a fix/workaround?

<!-- gh-comment-id:2445974648 --> @VideoFX commented on GitHub (Oct 30, 2024): I am also getting this error lately. Is there any more specifics/help on a fix/workaround?
Author
Owner

@tjbck commented on GitHub (Nov 3, 2024):

Should be fixed on dev!

<!-- gh-comment-id:2453576487 --> @tjbck commented on GitHub (Nov 3, 2024): Should be fixed on dev!
Author
Owner

@spammenotinoz commented on GitHub (Nov 6, 2024):

Should be fixed on dev!

Thank-you, confirming that YouTube is working fine in dev.

<!-- gh-comment-id:2461005515 --> @spammenotinoz commented on GitHub (Nov 6, 2024): > Should be fixed on dev! Thank-you, confirming that YouTube is working fine in dev.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#134011