-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyoutube.py
More file actions
38 lines (31 loc) · 864 Bytes
/
youtube.py
File metadata and controls
38 lines (31 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import sys
import yt_dlp
pasta_saida = r"C:\Users\Dias\Music"
if not os.path.exists(pasta_saida):
os.makedirs(pasta_saida)
url = input("Link (vídeo ou playlist): ").strip()
if not url:
print("Nenhum link inserido. Saindo...")
sys.exit()
opts = {
'format': 'bestaudio/best',
'outtmpl': os.path.join(pasta_saida, '%(title).50s.%(ext)s'),
'ignoreerrors': True,
'geo_bypass': True,
'nocheckcertificate': True,
'quiet': False,
'noplaylist': False,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
print("\nIniciando download...")
try:
with yt_dlp.YoutubeDL(opts) as ydl:
ydl.download([url])
print(f"\nSucesso! Áudios salvos em {pasta_saida}")
except Exception as e:
print(f"\nErro no download: {e}")