Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions ncm/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def download_song_by_song(song, download_folder, sub_folder=True):
return
is_already_download = download_file(song_url, song_file_name, song_download_folder)
if is_already_download:
print('Mp3 file already download:', song_file_name)
try:
print('Mp3 file already download:', song_file_name)
except:
print('Mp3 file already download:', song_file_name.encode("GBK", 'ignore'))
return

# download cover
Expand Down Expand Up @@ -114,11 +117,17 @@ def refresh(self, count):
# Update progress if down size > 10k
if (self.count - self.prev_count) > 10240:
self.prev_count = self.count
print(self.__get_info(), end=self.end_str)
try:
print(self.__get_info(), end=self.end_str)
except:
print(self.__get_info().encode("GBK", 'ignore'), end=self.end_str)
# Finish downloading
if self.count >= self.total:
self.end_str = '\n'
print(self.__get_info(), end=self.end_str)
try:
print(self.__get_info(), end=self.end_str)
except:
print(self.__get_info().encode("GBK", 'ignore'), end=self.end_str)


def format_string(string):
Expand Down
6 changes: 5 additions & 1 deletion ncm/file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ def resize_img(file_path, max_size=(640, 640), quality=90):

if img.size[0] > max_size[0] or img.size[1] > max_size[1]:
img.thumbnail(max_size, Image.ANTIALIAS)
img.save(file_path, quality=quality)
try:
img.save(file_path, quality=quality)
except:
img = img.convert('RGB')
img.save(file_path, quality=quality)


def add_metadata_to_song(file_path, cover_path, song):
Expand Down
5 changes: 4 additions & 1 deletion ncm/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ def download_playlist_songs(playlist_id):
folder_name = format_string(playlist_name) + ' - playlist'
folder_path = os.path.join(config.DOWNLOAD_DIR, folder_name)
for i, song in enumerate(songs):
print('{}: {}'.format(i + 1, song['name']))
try:
print('{}: {}'.format(i + 1, song['name']))
except:
print('{}: {}'.format(i + 1, song['name'].encode("GBK", 'ignore')))
download_song_by_song(song, folder_path, False)


Expand Down