-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (27 loc) · 984 Bytes
/
main.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
28
29
30
31
32
33
34
35
import pandas as pd
import os
from yt_dlp import YoutubeDL
def main():
input_dir = "input"
output_dir = "output"
input_fetched = os.listdir(input_dir)
input_fetched = [x for x in input_fetched if x.endswith(".csv")]
for file in input_fetched:
filename = os.path.splitext(file)[0]
print(filename)
songs_df = pd.read_csv(input_dir + "/" + file, header=None)
URLS = list(songs_df[0])
ydl_opts = {
'writethumbnail': True,
'format': 'mp3/bestaudio/best',
'postprocessors': [
{'key': 'FFmpegExtractAudio', 'preferredcodec': 'mp3'},
{'key': 'FFmpegMetadata', 'add_metadata': 'True'},
{'key': 'EmbedThumbnail'}
],
'outtmpl':output_dir + '/' + filename + '/%(title)s.%(ext)s',
}
with YoutubeDL(ydl_opts) as ydl:
error_code = ydl.download(URLS)
if __name__ == "__main__":
main()