From fa86526fa2c43432161ec9fd212ae56fc71082a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Tue, 4 Jul 2023 02:01:05 +0200 Subject: [PATCH] Use yt-dlp and include soundfile --- audioscrape/youtube.py | 8 ++++---- pyproject.toml | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/audioscrape/youtube.py b/audioscrape/youtube.py index b298d7e..c8ba717 100644 --- a/audioscrape/youtube.py +++ b/audioscrape/youtube.py @@ -4,7 +4,7 @@ from urllib.parse import urlencode from urllib.request import urlopen -import youtube_dl +import yt_dlp as yt logger = logging.getLogger(__name__) @@ -37,7 +37,7 @@ def scrape(query, include, exclude, quiet, verbose, overwrite, limit): """Search YouTube and download audio from discovered videos.""" # Search YouTube for videos. - query_string = urlencode({"search_query": query}) + query_string = urlencode({"search_query": f"{query} {include}"}) url = f"http://youtube.com/results?{query_string}" # Get video IDs from search results. @@ -66,12 +66,12 @@ def scrape(query, include, exclude, quiet, verbose, overwrite, limit): "postprocessors": [ { "key": "FFmpegExtractAudio", - "preferredcodec": "opus", + "preferredcodec": "ogg", "preferredquality": "192", } ], } - ydl = youtube_dl.YoutubeDL(download_options) + ydl = yt.YoutubeDL(download_options) # Fetch metadata. video_info = ydl.extract_info(video_url, download=False) diff --git a/pyproject.toml b/pyproject.toml index e4e966c..6d8a338 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,11 +18,12 @@ classifiers = [ "Programming Language :: Python :: 3", ] dependencies = [ - "youtube-dl @ git+https://github.com/ytdl-org/youtube-dl@fa7f0effbe4e14fcf70e1dc4496371c9862b64b9", - "tqdm", + "mediapipe", "requests", "soundcloud-lib", - "mediapipe", + "soundfile", + "tqdm", + "yt-dlp", ] dynamic = ["version"]