-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconvertermusica.py
27 lines (23 loc) · 939 Bytes
/
convertermusica.py
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
from pathlib import Path
import os
import yt_dlp
def download_music():
with open(r"_Caminho_de_um_arquivo_de_texto_com_os_links_das_músicas_no_Youtube") as musicas_txt:
for linha in musicas_txt:
link = linha
path = (r"_Diretório_para_onde_as_músicas_vão_")
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': os.path.join(path, '%(title)s.%(ext)s'),
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'ffmpeg_location': r'_Caminho_para_o_executável_do_FFmpeg_',
}
#Fazer o dowload
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([link])
print("Download completo")
download_music()