Skip to content

Commit

Permalink
Use yt-dlp and include soundfile
Browse files Browse the repository at this point in the history
  • Loading branch information
carlthome committed Jul 4, 2023
1 parent 000981d commit fa86526
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions audioscrape/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit fa86526

Please sign in to comment.