Ver Fonte

partial commit

mike há 5 anos atrás
pai
commit
6ee78d865b

BIN
Will Smith - Gettin' Jiggy Wit It (Official Video).webm.part


+ 0 - 11
list.txt.save

@@ -1,11 +0,0 @@
-Sick Of Life, Godsmack
-Awake, Godsmack
-Greed, Godsmack
-Bad Magick, Godsmack
-Goin' Down, Godsmack
-Mistakes, Godsmack
-Trippin', Godsmack
-Forgive Me, Godsmack
-Vampires, Godsmack
-The Journey, Godsmack
-Spiral, Godsmack

+ 0 - 0
ytsearch.save → old/ytsearch.save


+ 0 - 0
ytsearch.save.6_16_2020 → old/ytsearch.save.6_16_2020


+ 25 - 10
ytsearch

@@ -17,7 +17,7 @@ import random, string
 ##
 ## - Multi-thread conversion to audio format
 ##
-## - Logging and Verbosity levels
+## - Logging
 ##
 ## - Check for dependencies
 ##    - Tor?
@@ -29,6 +29,10 @@ import random, string
 ## - check for dependencies on start
 ##   - youtube-dl
 ##   - tor (if used)
+##
+## - Download the first X results from YoutubeSearch and pick best result
+##
+## - increase timeout in YoutubeSearch
 
 ##Vars
 if os.path.exists('config.ini'):
@@ -39,7 +43,7 @@ else:
 	print("Exiting...")
 	exit(1)
 
-VERSION="0.0.2"
+VERSION="0.0.3"
 DOWNLOAD=config['DEFAULT'].getboolean('Download')	#Download True/False
 MUSICFILE=config['DEFAULT']['Musicfile']		#location of text file containing 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)):
 		tracks[i] = tracks[i] + ", " + Artist
 
-	print(tracks)
-
 	if write:
 		with open('list.txt', 'w') as f:
 			for j in range (len(tracks)):
@@ -185,8 +187,9 @@ def buildfolders(artist, album=""):
 	try:
 		os.makedirs(DESTFOLDER)
 		msg("Folder " + DESTFOLDER + " created", 2)
-	except:
+	except Exception as e:
 		msg("Could not create destination folder!", 1)
+		msg(e, 1)
 
 def readlist(file):
 	msg("Starting readlist", 3)
@@ -207,21 +210,28 @@ def readlist(file):
 	f.close()
 	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):
 	msg("Starting parselist", 3)
 	global ITERATOR
 	if ITERATOR == 0 and DOWNLOAD:
 		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
 	for song in musiclist:
 #	  searchterm = song['Title'] + " " + song['Artist'] + ' lyrics HD'
 	  searchterm = song['Title'] + " " + song['Artist']
 	  dictlink={}
 	  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']
 	    logresults.append(song['Title'] + ", " + song['Artist'] + " Link Created")
 	    if DOWNLOAD:
@@ -236,8 +246,13 @@ def parselist(musiclist):
 
 def downloadsong(link, song):
        msg("Starling Downloadsong for " + song['Title'], 3)
+       msg("Downloadsong DESTFOLDER: " + DESTFOLDER, 3)
        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'])
          logresults.append(song['Title'] + ", " + song['Artist'] + " Audio downloaded")
          msg(song['Title'] + " Download Complete!", 2)