Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def download_files(playlist):
- open_text_file = open(playlist + '.txt', 'r')
- read_text_file = open_text_file.read().split('\n')
- for i in read_text_file:
- link = api_vk.audio.search(q=i)
- sleep(1)
- if len(i) == 0:
- print "File name is empty. Skipped."
- continue
- elif link[0] == 0:
- print i + " not found. Skipped."
- continue
- elif os.path.isfile(i + ".mp3"):
- print i + " is exists. Skipped."
- continue
- else:
- link = api_vk.audio.search(q=i, auto_complete=1, sort=2, count=1)[1]['url']
- downloaded_file = urllib.URLopener()
- downloaded_file.retrieve(link, i + '.mp3')
- sleep(3)
- print "\nAll files are downloaded.\nGood bye!"
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement