ultralytics 8.2.54 resolve YouTube bug with switch to pytubefix (#14354)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
95736975fc
commit
5b330ad310
4 changed files with 12 additions and 16 deletions
|
|
@ -544,8 +544,9 @@ def get_best_youtube_url(url, method="pytube"):
|
|||
(str): The URL of the best quality MP4 video stream, or None if no suitable stream is found.
|
||||
"""
|
||||
if method == "pytube":
|
||||
check_requirements("pytube")
|
||||
from pytube import YouTube
|
||||
# Switched from pytube to pytubefix to resolve https://github.com/pytube/pytube/issues/1954
|
||||
check_requirements("pytubefix")
|
||||
from pytubefix import YouTube
|
||||
|
||||
streams = YouTube(url).streams.filter(file_extension="mp4", only_video=True)
|
||||
streams = sorted(streams, key=lambda s: s.resolution, reverse=True) # sort streams by resolution
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue