def download_songs(song_link_list, folder): for s in song_link_list['data']['songList']: if s['linkinfo'].has_key('320'): link = s['linkinfo']['320']['songLink'] else: link = s['linkinfo']['128']['songLink'] print '--------------------------downloading----------------' print link filename = s['songName'] print filename info = { 'title': s['songName'], 'album': s['albumName'], 'artist': s['artistName'], 'track_num': song_link_list['data']['songList'].index(s) } output_file = os.path.join(folder, filename+'.mp3') r = requests.get(link, headers=HEADERS, stream=True) r.encoding = 'utf-8' with open(output_file, 'wb') as output: for chunk in r.iter_content(1024): if not chunk: break output.write(chunk) dl.set_song_info(output_file, info) print '------------------------complete--------------------'
def download_songs(song_link_list, folder): for s in song_link_list['data']['songList']: if s['linkinfo'].has_key('320'): link = s['linkinfo']['320']['songLink'] else: link = s['linkinfo']['128']['songLink'] print '--------------------------downloading----------------' print link filename = s['songName'] print filename info = { 'title': s['songName'], 'album': s['albumName'], 'artist': s['artistName'], 'track_num': song_link_list['data']['songList'].index(s) } output_file = os.path.join(folder, filename + '.mp3') r = requests.get(link, headers=HEADERS, stream=True) r.encoding = 'utf-8' with open(output_file, 'wb') as output: for chunk in r.iter_content(1024): if not chunk: break output.write(chunk) dl.set_song_info(output_file, info) print '------------------------complete--------------------'
def download_songs(songs, folder): for s in songs: link = s['mp3Url'] print '--------------------------downloading----------------' print link filename = s['name'] print filename info = { 'title': s['name'], 'album': s['album']['name'], 'artist': s['artists'][0]['name'], 'track_num': songs.index(s) } output_file = os.path.join(folder, filename+'.mp3') r = requests.get(link, headers=HEADERS, stream=True) r.encoding = 'utf-8' with open(output_file, 'wb') as output: for chunk in r.iter_content(1024): if not chunk: break output.write(chunk) dl.set_song_info(output_file, info) print '--------------------------complete--------------------'
def download_songs(songs, folder): for s in songs: link = s['mp3Url'] print '--------------------------downloading----------------' print link filename = s['name'] print filename info = { 'title': s['name'], 'album': s['album']['name'], 'artist': s['artists'][0]['name'], 'track_num': songs.index(s) } output_file = os.path.join(folder, filename + '.mp3') r = requests.get(link, headers=HEADERS, stream=True) r.encoding = 'utf-8' with open(output_file, 'wb') as output: for chunk in r.iter_content(1024): if not chunk: break output.write(chunk) dl.set_song_info(output_file, info) print '--------------------------complete--------------------'