-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ult_guit_download.py
82 lines (68 loc) · 2.35 KB
/
ult_guit_download.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
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/env python
import sys, threading
from modules.UltimateDownloader.ultimatedownloader import UltimateDownloader
from modules.YouTubeDownloader.youtubedownloader import YoutubeDownloader
options = {
"downloadTab": False,
"downloadYT": False,
"tab_url": None, # Accepts UG urls
"youtube_url": None, # Accepts any youtube url mobile/shortened/normal
"youtube_type": "audio", # Accepts (audio, best, 1080, 720),
"bulkYT": False
}
for a in sys.argv:
if "guitar.com" in a:
options["downloadTab"] = True
options["tab_url"] = a
elif a in ["--bulk", "--bt", "--bulktube"]:
options["bulkYT"] = True
elif "youtu" in a:
options["downloadYT"] = True
options["youtube_url"] = a
elif "ytype=" in a:
#options["youtube_type"]
options["youtube_type"] = a.split("=")[1].replace('"', '')
if options["youtube_type"] not in ["audio", "best", "1080", "720"]:
print("Youtube media type not valid try one of these [audio, best, 1080, 720] (default to Audio Only)")
options["youtube_type"] = "audio"
def processTab():
UltDown = UltimateDownloader()
if options["downloadTab"] and options["tab_url"]:
UltDown.setURL(options["tab_url"])
UltDown.getTab()
def processYoutube():
YouDown = YoutubeDownloader(options["youtube_type"])
if options["downloadYT"] and options["youtube_url"]:
YouDown.setVideoURL(options["youtube_url"])
YouDown.download()
def downloadYT(url=""):
try:
YouDown = YoutubeDownloader(options["youtube_type"])
YouDown.setVideoURL(url)
YouDown.download()
except:
print(f"[DOWNLOAD ERROR] - {url}")
def bulkYoutube():
urls = openYTBulkFile()
print(f"{len(urls)} bulk urls to be processed...")
YouDown = YoutubeDownloader(options["youtube_type"])
bulkThreads = []
for url in urls:
# YouDown.setVideoURL(url)
# YouDown.download()
t = threading.Thread(target=downloadYT, args=(url,))
t.start()
bulkThreads.append(t)
for t in bulkThreads:
t.join()
def openYTBulkFile():
result = None
with open("youtube_list", "r") as ytFile:
result = ytFile.read()
result = result.split("\n")
return result
if not options["bulkYT"]:
processTab()
processYoutube()
else:
bulkYoutube()