-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinks_downloader.py
70 lines (59 loc) · 1.61 KB
/
links_downloader.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Author: Danilo Nascimento
# E-mail: [email protected]
from yt_dlp import YoutubeDL
import sys
# Script to download multiple videos or music from a .txt file containing their respective links
# Pre-Requisites:
# yt-dlp
# ffmpeg
# Usage Steps:
# 1. python links_downlaoder.py (mp3/mp4) <links.txt>
# 2. Enjoy the downloaded files at same location as the .py
try:
Type = sys.argv[1]
links_txt = sys.argv[2]
file = open(links_txt, "r")
except:
print("Error missing arguments!")
print("python links_downloader.py (mp3/mp4) <links.txt>")
sys.exit(0)
if Type.lower() == "mp3":
# yt-dlp API Call
ydl_opts = {
'format': 'bestaudio/best',
"writethumbnail": True,
"outtmpl": "%(title)s.%(ext)s",
'postprocessors': [
{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '320',
},
{
"key": "FFmpegMetadata",
},
{
"key": "EmbedThumbnail",
},
],
}
print("\n Download Completed...Enjoy!")
elif Type.lower() == "mp4":
# yt-dlp API Call
ydl_opts = {
'format': 'bestvideo+bestaudio/best',
"writethumbnail": True,
"outtmpl": "%(title)s.%(ext)s",
'postprocessors': [
{
"key": "FFmpegMetadata",
},
{
"key": "EmbedThumbnail",
},
],
}
with YoutubeDL(ydl_opts) as ydl:
for link in file:
ydl.download(link)
print("\n\nDownload Completed...Enjoy!")