Skip to content

Commit 5c45468

Browse files
shailesh-vaidyashailesh-vaidya
shailesh-vaidya
authored and
shailesh-vaidya
committed
Added support to download audio output only
Signed-off-by: shailesh-vaidya <Shailesh Vaidya>
1 parent 6590c5e commit 5c45468

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Youtube Downloader/youtubeDownloader.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ def my_hook(d):
55
print(f"Done downloading, now post-processing ... File saved as: {d['filename']}")
66

77
ydl_opts = {
8-
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best',
98
'ffmpeg_location': r'Youtube Downloader\bin',
109
'progress_hooks': [my_hook],
1110
'outtmpl': '%(title)s.%(ext)s',
11+
'restrictfilenames': 'True',
1212
}
1313

1414

@@ -25,9 +25,14 @@ def downloader():
2525
else:
2626
URLS.append(input('Enter Video URL: '))
2727

28+
question = input("Do you want audio output only (Y/n): ").lower()
29+
if question == 'y':
30+
ydl_opts['format'] = 'bestaudio[ext=m4a]/best,'
31+
else:
32+
ydl_opts['format'] = 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best,'
33+
2834
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
2935
ydl.download(URLS)
30-
31-
36+
3237
if __name__ == "__main__":
3338
downloader()

0 commit comments

Comments
 (0)