|
@@ -17,7 +17,7 @@ import random, string
|
|
|
##
|
|
##
|
|
|
## - Multi-thread conversion to audio format
|
|
## - Multi-thread conversion to audio format
|
|
|
##
|
|
##
|
|
|
-## - Logging and Verbosity levels
|
|
|
|
|
|
|
+## - Logging
|
|
|
##
|
|
##
|
|
|
## - Check for dependencies
|
|
## - Check for dependencies
|
|
|
## - Tor?
|
|
## - Tor?
|
|
@@ -29,6 +29,10 @@ import random, string
|
|
|
## - check for dependencies on start
|
|
## - check for dependencies on start
|
|
|
## - youtube-dl
|
|
## - youtube-dl
|
|
|
## - tor (if used)
|
|
## - tor (if used)
|
|
|
|
|
+##
|
|
|
|
|
+## - Download the first X results from YoutubeSearch and pick best result
|
|
|
|
|
+##
|
|
|
|
|
+## - increase timeout in YoutubeSearch
|
|
|
|
|
|
|
|
##Vars
|
|
##Vars
|
|
|
if os.path.exists('config.ini'):
|
|
if os.path.exists('config.ini'):
|
|
@@ -39,7 +43,7 @@ else:
|
|
|
print("Exiting...")
|
|
print("Exiting...")
|
|
|
exit(1)
|
|
exit(1)
|
|
|
|
|
|
|
|
-VERSION="0.0.2"
|
|
|
|
|
|
|
+VERSION="0.0.3"
|
|
|
DOWNLOAD=config['DEFAULT'].getboolean('Download') #Download True/False
|
|
DOWNLOAD=config['DEFAULT'].getboolean('Download') #Download True/False
|
|
|
MUSICFILE=config['DEFAULT']['Musicfile'] #location of text file containing songs
|
|
MUSICFILE=config['DEFAULT']['Musicfile'] #location of text file containing songs
|
|
|
RETRIES=config['DEFAULT'].getint('Retries') #Number of retries to search for songs
|
|
RETRIES=config['DEFAULT'].getint('Retries') #Number of retries to search for songs
|
|
@@ -146,8 +150,6 @@ def buildlist(jsondata, write=False):
|
|
|
for i in range(len(tracks)):
|
|
for i in range(len(tracks)):
|
|
|
tracks[i] = tracks[i] + ", " + Artist
|
|
tracks[i] = tracks[i] + ", " + Artist
|
|
|
|
|
|
|
|
- print(tracks)
|
|
|
|
|
-
|
|
|
|
|
if write:
|
|
if write:
|
|
|
with open('list.txt', 'w') as f:
|
|
with open('list.txt', 'w') as f:
|
|
|
for j in range (len(tracks)):
|
|
for j in range (len(tracks)):
|
|
@@ -185,8 +187,9 @@ def buildfolders(artist, album=""):
|
|
|
try:
|
|
try:
|
|
|
os.makedirs(DESTFOLDER)
|
|
os.makedirs(DESTFOLDER)
|
|
|
msg("Folder " + DESTFOLDER + " created", 2)
|
|
msg("Folder " + DESTFOLDER + " created", 2)
|
|
|
- except:
|
|
|
|
|
|
|
+ except Exception as e:
|
|
|
msg("Could not create destination folder!", 1)
|
|
msg("Could not create destination folder!", 1)
|
|
|
|
|
+ msg(e, 1)
|
|
|
|
|
|
|
|
def readlist(file):
|
|
def readlist(file):
|
|
|
msg("Starting readlist", 3)
|
|
msg("Starting readlist", 3)
|
|
@@ -207,21 +210,28 @@ def readlist(file):
|
|
|
f.close()
|
|
f.close()
|
|
|
return music
|
|
return music
|
|
|
|
|
|
|
|
|
|
+def searchlinks(links):
|
|
|
|
|
+ ## Takes a list of dictionaries and parses the results
|
|
|
|
|
+ ## Discards bad choices
|
|
|
|
|
+ ## Returns a dictionary of one entry (best result)
|
|
|
|
|
+ for link in links:
|
|
|
|
|
+ print(link)
|
|
|
|
|
+ print("\n")
|
|
|
|
|
+ sys.exit()
|
|
|
|
|
+
|
|
|
def parselist(musiclist):
|
|
def parselist(musiclist):
|
|
|
msg("Starting parselist", 3)
|
|
msg("Starting parselist", 3)
|
|
|
global ITERATOR
|
|
global ITERATOR
|
|
|
if ITERATOR == 0 and DOWNLOAD:
|
|
if ITERATOR == 0 and DOWNLOAD:
|
|
|
buildfolders(musiclist[0]['Artist'])
|
|
buildfolders(musiclist[0]['Artist'])
|
|
|
- ## Build File Structure using buildfolders
|
|
|
|
|
- ## Somehow have downloads save to this folder without knowing the file name?
|
|
|
|
|
- ## Perhaps with a flag in youtube-dl
|
|
|
|
|
ITERATOR+=1
|
|
ITERATOR+=1
|
|
|
for song in musiclist:
|
|
for song in musiclist:
|
|
|
# searchterm = song['Title'] + " " + song['Artist'] + ' lyrics HD'
|
|
# searchterm = song['Title'] + " " + song['Artist'] + ' lyrics HD'
|
|
|
searchterm = song['Title'] + " " + song['Artist']
|
|
searchterm = song['Title'] + " " + song['Artist']
|
|
|
dictlink={}
|
|
dictlink={}
|
|
|
try:
|
|
try:
|
|
|
- ytresult = YoutubeSearch(searchterm, max_results=1).to_dict() ##increase timeout!!
|
|
|
|
|
|
|
+ ytresult = YoutubeSearch(searchterm, max_results=5).to_dict() ##increase timeout!!
|
|
|
|
|
+# searchlinks(ytresult)
|
|
|
link = 'https://youtube.com' + ytresult[0]['link']
|
|
link = 'https://youtube.com' + ytresult[0]['link']
|
|
|
logresults.append(song['Title'] + ", " + song['Artist'] + " Link Created")
|
|
logresults.append(song['Title'] + ", " + song['Artist'] + " Link Created")
|
|
|
if DOWNLOAD:
|
|
if DOWNLOAD:
|
|
@@ -236,8 +246,13 @@ def parselist(musiclist):
|
|
|
|
|
|
|
|
def downloadsong(link, song):
|
|
def downloadsong(link, song):
|
|
|
msg("Starling Downloadsong for " + song['Title'], 3)
|
|
msg("Starling Downloadsong for " + song['Title'], 3)
|
|
|
|
|
+ msg("Downloadsong DESTFOLDER: " + DESTFOLDER, 3)
|
|
|
try:
|
|
try:
|
|
|
- os.system("youtube-dl --extract-audio --audio-format best --audio-quality 0 --output '" + DESTFOLDER + "%(title)s.%(ext)s' --ignore-errors " + link)
|
|
|
|
|
|
|
+#####
|
|
|
|
|
+##Fix Destination Path
|
|
|
|
|
+##HOW DID I DO THIS BEFORE??
|
|
|
|
|
+#####
|
|
|
|
|
+ os.system("youtube-dl --extract-audio --audio-format best --audio-quality 0 --output '%(title)s.%(ext)s' --ignore-errors " + link)
|
|
|
completed.append(song['songnum'])
|
|
completed.append(song['songnum'])
|
|
|
logresults.append(song['Title'] + ", " + song['Artist'] + " Audio downloaded")
|
|
logresults.append(song['Title'] + ", " + song['Artist'] + " Audio downloaded")
|
|
|
msg(song['Title'] + " Download Complete!", 2)
|
|
msg(song['Title'] + " Download Complete!", 2)
|