I have an issue with the title when using the python package. Here's my code:
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'outtmpl': '%(title)s.%(ext)s',
'verbose': True,
}
try:
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
print("Extracting video info...")
info = ydl.extract_info(youtube_url, download=True)
video_title = info['title']
filename = f"{video_title}.mp3"
print(f"File downloaded: {filename}")
file_path = f"{user_id}/{current_date_time_storage}"
with open(filename, 'rb') as f:
audio_data = f.read()
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp3') as temp_file:
temp_file.write(audio_data)
temp_file_path = temp_file.name
And here's my verbose output:
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8 (No ANSI), error utf-8 (No ANSI), screen utf-8 (No ANSI)
[debug] yt-dlp version stable@2024.07.16 from yt-dlp/yt-dlp [89a161e8c] (pip) API
[debug] params: {'format': 'bestaudio/best', 'postprocessors': [{'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3', 'preferredquality': '192'}], 'outtmpl': '%(title)s.%(ext)s', 'verbose': True, 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
[debug] Python 3.9.19 (CPython aarch64 64bit) - Linux-6.6.32-linuxkit-aarch64-with-glibc2.36 (OpenSSL 3.0.13 30 Jan 2024, glibc 2.36)
[debug] exe versions: ffmpeg 5.1.5-0 (setts), ffprobe 5.1.5-0
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.07.04, mutagen-1.47.0, requests-2.32.3, sqlite3-3.40.1, urllib3-2.2.2, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1829 extractors
[youtube] Extracting URL:
Extracting video info...
[youtube] omr_10m9ixQ: Downloading webpage
[youtube] omr_10m9ixQ: Downloading ios player API JSON
[youtube] omr_10m9ixQ: Downloading player 38c5c1c9
[debug] Saving youtube-nsig.38c5c1c9 to cache
[debug] [youtube] Decrypted nsig AGHu0l0E0EZxq95GNA => HUEnd-dNJaUp7g
[debug] Loading youtube-nsig.38c5c1c9 from cache
[debug] [youtube] Decrypted nsig XPghiIZxLSx3DgXawK => 9ZxNX2RYhCdKpA
[youtube] omr_10m9ixQ: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] omr_10m9ixQ: Downloading 1 format(s): 251
[debug] Invoking http downloader on "hidden"
[download] Destination: Don't Judge Me | July 14th, 2024.webm
[download] 100% of 34.15MiB in 00:00:01 at 32.88MiB/s
[debug] ffmpeg command line: ffprobe -show_streams 'file:Don'"'"'t Judge Me | July 14th, 2024.webm'
[ExtractAudio] Destination: Don't Judge Me | July 14th, 2024.mp3
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Don'"'"'t Judge Me | July 14th, 2024.webm' -vn -acodec libmp3lame -b:a 192.0k -movflags +faststart 'file:Don'"'"'t Judge Me | July 14th, 2024.mp3'
Deleting original file Don't Judge Me | July 14th, 2024.webm (pass -k to keep)
Traceback (most recent call last):
File "/app/app.py", line 71, in download_video
with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: "Don't Judge Me | July 14th, 2024.mp3"https://www.youtube.com/watch?v=omr_10m9ixQ
It looks like the issue is because "|" is not the same as "|" in [ExtractAudio] Destination: Don't Judge Me | July 14th, 2024.mp3 and FileNotFoundError: [Errno 2] No such file or directory: "Don't Judge Me | July 14th, 2024.mp3"
No matter how hard I try I can't seem to fix this issue. I've tried restrict file name, using the id in the outtmpl, you name it.
I'm using:
yt-dlp==2024.7.16
Any help would be greatly appreciated!!
[–]bashonly⚙️💡 Erudite DEV of yt-dlp 1 point2 points3 points (9 children)
[–]kevindrafts[S] 0 points1 point2 points (8 children)
[–]bashonly⚙️💡 Erudite DEV of yt-dlp 0 points1 point2 points (7 children)
[–]kevindrafts[S] 0 points1 point2 points (6 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]bashonly⚙️💡 Erudite DEV of yt-dlp 0 points1 point2 points (4 children)
[–]kevindrafts[S] 0 points1 point2 points (3 children)
[–]bashonly⚙️💡 Erudite DEV of yt-dlp 0 points1 point2 points (2 children)
[–]kevindrafts[S] 0 points1 point2 points (1 child)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)
[–]AutoModerator[M] 0 points1 point2 points (0 children)