If song_url is none, just return.

This commit is contained in:
codezjx 2017-07-06 22:57:45 +08:00
parent e492deb771
commit f5bc763ab3
2 changed files with 4 additions and 4 deletions

View File

@ -71,10 +71,7 @@ class CloudApi(object):
params = {'ids': [song_id], 'br': bit_rate, 'csrf_token': csrf} params = {'ids': [song_id], 'br': bit_rate, 'csrf_token': csrf}
result = self.post_request(url, params) result = self.post_request(url, params)
song_url = result['data'][0]['url'] song_url = result['data'][0]['url']
if song_url is None: return song_url
print('Song {} is not available due to copyright issue. => {}'.format(song_id, result))
else:
return song_url
def get_hot_songs(self, artist_id): def get_hot_songs(self, artist_id):
""" """

View File

@ -45,6 +45,9 @@ def download_song_by_song(song, download_folder, sub_folder=True):
# download song # download song
song_url = api.get_song_url(song_id) song_url = api.get_song_url(song_id)
if song_url is None:
print('Song <<{}>> is not available due to copyright issue!'.format(song_name))
return
is_already_download = download_file(song_url, song_file_name, song_download_folder) is_already_download = download_file(song_url, song_file_name, song_download_folder)
if is_already_download: if is_already_download:
print('Mp3 file already download:', song_file_name) print('Mp3 file already download:', song_file_name)