From e1440e48046d5bdda4d5f5e6fd8d5e4ccb208f0a Mon Sep 17 00:00:00 2001 From: "Jonathan C. McKinney" Date: Sat, 26 Oct 2024 14:58:27 -0700 Subject: [PATCH] Use different downloader for youtube --- docs/run_patches.sh | 8 ++++---- reqs_optional/requirements_optional_image.txt | 2 +- src/version.py | 2 +- src/vision/extract_movie.py | 10 ++++++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/run_patches.sh b/docs/run_patches.sh index 5430b9aaf..127327e03 100755 --- a/docs/run_patches.sh +++ b/docs/run_patches.sh @@ -15,12 +15,12 @@ sed -i 's/with HiddenPrints():/if True:/g' $sp/langchain_community/utilities/se # find "$sp" -type f -name "*.py" -exec sed -i -E 's/(sys\.stdout\s*=\s*.*)/pass # \1/; s/(sys\.stderr\s*=\s*.*)/pass # \1/' {} + # use pytubefix instead, pytube too old and various issues -sed -i 's/Pytube/PytubeFix/g' $sp/fiftyone/utils/youtube.py -sed -i 's/pytube>=15/pytube>=6/g' $sp/fiftyone/utils/youtube.py -sed -i 's/pytube/pytubefix/g' $sp/fiftyone/utils/youtube.py +#sed -i 's/Pytube/PytubeFix/g' $sp/fiftyone/utils/youtube.py +#sed -i 's/pytube>=15/pytube>=6/g' $sp/fiftyone/utils/youtube.py +#sed -i 's/pytube/pytubefix/g' $sp/fiftyone/utils/youtube.py # diff -Naru /home/jon/miniconda3/envs/h2ogpt/lib/python3.10/site-packages/pytubefix/extract.py ~/extract.py > docs/pytubefix.patch -patch $sp/pytubefix/extract.py docs/pytubefix.patch +#patch $sp/pytubefix/extract.py docs/pytubefix.patch # fix asyncio same way websockets was fixed, else keep hitting errors in async calls # https://github.com/python-websockets/websockets/commit/f9fd2cebcd42633ed917cd64e805bea17879c2d7 diff --git a/reqs_optional/requirements_optional_image.txt b/reqs_optional/requirements_optional_image.txt index 18ab1ae44..d16e0019f 100644 --- a/reqs_optional/requirements_optional_image.txt +++ b/reqs_optional/requirements_optional_image.txt @@ -7,4 +7,4 @@ yt-dlp>=2024.8.6 # moviepy>=0.5.1 # for fiftyone with patches -pytubefix==6.15.4 +pytubefix==8.1.1 diff --git a/src/version.py b/src/version.py index 508544794..19d79ebc7 100644 --- a/src/version.py +++ b/src/version.py @@ -1 +1 @@ -__version__ = "028f433b69021436a7ffd5f26970eb7ec0bfbfa7" +__version__ = "f28e728d5e5a3f67c2642641e2743d2c7fbe7aea" diff --git a/src/vision/extract_movie.py b/src/vision/extract_movie.py index 1090cce66..22bf94f2f 100644 --- a/src/vision/extract_movie.py +++ b/src/vision/extract_movie.py @@ -1,4 +1,5 @@ import os +import sys import uuid from src.utils import makedirs, sanitize_filename, get_gradio_tmp @@ -14,8 +15,13 @@ def extract_unique_frames(urls=None, file=None, download_dir=None, export_dir=No makedirs(download_dir, exist_ok=True) # os.environ['FIFTYONE_DISABLE_SERVICES'] = 'True' if urls: - import fiftyone.utils.youtube as fouy - fouy.download_youtube_videos(urls, download_dir=download_dir) + if 'openai_server' not in sys.path: + sys.path.append('openai_server') + from openai_server.agent_tools.download_web_video import download_web_video + for url in urls: + download_web_video(video_url=url, base_url="https://www.youtube.com", output_dir=download_dir) + #import fiftyone.utils.youtube as fouy + #fouy.download_youtube_videos(urls, download_dir=download_dir) # Create a FiftyOne Dataset import fiftyone as fo