View difference between Paste ID: 0iAHyATP and b3thTwCN
SHOW: | | - or go back to the newest paste.
1-
def download_files(playlist):
1+
2-
    open_text_file = open(playlist + '.txt', 'r')
2+
3-
    read_text_file = open_text_file.read().split('\n')
3+
4-
    for i in read_text_file:
4+
                r = urlopen(link)
5-
        link = api_vk.audio.search(q=i)
5+
                if r.headers['Content-Length'] == os.path.getize(fname):
6-
        sleep(1)
6+
                    continue
7-
        if len(i) == 0:
7+
            link = api_vk.audio.search(q=i, auto_complete=1, sort=2, count=1)[1]['url']
8-
            print "File name is empty. Skipped."
8+
            downloaded_file = urllib.URLopener()
9-
            continue
9+
            downloaded_file.retrieve(link, i + '.mp3')
10-
        elif link[0] == 0:
10+
            sleep(3)