#********** DOWNLOADING VIDEOS/CONVERTING TO MP3 ********** urls = [] currenturl = "1" while currenturl != "": currenturl = raw_input('Enter URL (just hit ENTER to stop and begin downloading): ') if currenturl == "": break urls.append(currenturl) print ("done with queue entry. Downloading videos from YouTube:") time.sleep(3) count = 1 for i in urls: if count <= 9: os.system("/usr/local/bin/youtube-dl " + i + " -o 'Track_0" + str(count) + "-_%(title)s.%(ext)s' --restrict-filenames") else: os.system("/usr/local/bin/youtube-dl " + i + " -o 'Track_" + str(count) + "-_%(title)s.%(ext)s' --restrict-filenames") count = count + 1 print ("Finished downloading queue. Finding downloaded videos: ") downloaded = [] for file in os.listdir('.'): if file.endswith(".mp4"): print file downloaded.append(file) print ("Here are the found files: ") print '[%s]' % ', '.join(map(str, downloaded)) print ("Now converting videos: ") time.sleep(3) downloaded.sort() for x in downloaded: os.system('/usr/local/bin/ffmpeg -i ' + x + " " + x + '.mp3') print ("Finished converting. Cleaning up: ") time.sleep(3) for file in os.listdir('.'): if file.endswith(".mp4"): print ("Deleting file " + file + "...") os.system("rm " + file) count = 1 for i in urls: if count <= 9: os.system("/usr/local/bin/youtube-dl -o 'Track_0" + str(count) + "_-_%(title)s.%(ext)s' --restrict-filenames " + i) else: os.system("/usr/local/bin/youtube-dl -o 'Track_" + str(count) + "_-_%(title)s.%(ext)s' --restrict-filenames " + i) count = count + 1 #********** BURNING TO CD-R ********** switch = raw_input("Would you like to burn the downloaded MP3 to CD-R? 'y' for yes or anything else for no:") if switch == "y": for file in os.listdir('.'): if file.endswith(".mp3"): os.system("/usr/local/bin/ffmpeg -i " + file + " " + file + ".wav") wave = [] for file in os.listdir('.'): if file.endswith(".wav"): wave.append(file) wave.sort() os.system("touch cd.toc") os.system("sudo chmod 777 cd.toc") f = open('cd.toc','w') f.write('CD_DA\n\n') for z in wave: f.write('\n\nTRACK AUDIO\n') f.write('AUDIOFILE "' + z + '" 0') f.close() raw_input ("Please place a blank CD-R into your CD drive, then hit ENTER:") print ("Now burning CD...") os.system("cdrdao write cd.toc") for y in wave: print ("Deleting file " + y + "...") os.system("rm " + y) os.system("rm cd.toc") else: print ("Skipping CD burning.") #********** POST-OPERATION ORGANIZATION ********** name = raw_input("Give a name to the compilation you've made:") name = name.replace(" ", "_") os.system("mkdir " + name) os.system("mv *.mp3 " + name) print("Moved MP3 into a folder called " + name + ".") print ("All finished. Enjoy! Hit Enter to terminate program.") raw_input("")