Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PytubeError when using YoutubeVideoSearchTool with a specific YouTube video URL #1578

Open
naoki1213mj opened this issue Nov 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@naoki1213mj
Copy link

Description

Summary

When attempting to use YoutubeVideoSearchTool with a specific YouTube video URL, a PytubeError occurs. This error is raised by pytube while trying to access the video title. The error message suggests a missing videoDetails field in the YouTube response, which causes a KeyError. This issue may be related to recent changes in YouTube’s data structure or a limitation within pytube.

Steps to Reproduce

  1. I used the following code to initiate a YoutubeVideoSearchTool instance with a specified YouTube video URL:
    from crewai_tools import YoutubeVideoSearchTool
    
    youtube_video_url = "https://www.youtube.com/watch?v=FD-yp57VbmQ"
    youtube_video_search_tool = YoutubeVideoSearchTool(youtube_video_url=youtube_video_url)
  2. When this code runs, it raises a PytubeError with a KeyError: 'videoDetails', which prevents YoutubeVideoSearchTool from working with this video.

Error Message

PytubeError: Exception while accessing title of https://youtube.com/watch?v=FD-yp57VbmQ. Please file a bug report at https://github.com/pytube/pytube
Traceback:
    File "path_to_crewai_tools/youtube_video_search_tool.py", line XX, in __init__
        self.add(youtube_video_url)
    File "path_to_pytube/__main__.py", line 346, in title
        self._title = self.vid_info['videoDetails']['title']
    KeyError: 'videoDetails'

Environment

  • crewai version: 0.51.1
  • pytube version: 15.0.0
  • Python version: 3.11.9
  • Operating System: macOS Sequoia 15.1

Expected behavior

YoutubeVideoSearchTool should retrieve information from the specified YouTube video URL without errors.

Screenshots/Code snippets

None

Operating System

Other (specify in additional context)

Python Version

3.11

crewAI Version

0.51.1

crewAI Tools Version

0.8.3

Virtual Environment

Venv

Evidence

PytubeError: Exception while accessing title of https://youtube.com/watch?v=example. Please file a bug report at https://github.com/pytube/pytube
Traceback:
File "path_to_crewai_tools/youtube_video_search_tool.py", line XX, in init
self.add(youtube_video_url)
File "path_to_pytube/main.py", line 346, in title
self._title = self.vid_info['videoDetails']['title']
KeyError: 'videoDetails'

Possible Solution

None

Additional context

None

@naoki1213mj naoki1213mj added the bug Something isn't working label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant