Skip to content

Commit

Permalink
Support unicode names and files
Browse files Browse the repository at this point in the history
  • Loading branch information
mnzaki committed Oct 6, 2015
1 parent b6d00bb commit 3264fc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scdl/scdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def dl_tracks(self, tracks):
artist_folder = self.download_path + track['artist'] + '/'
if not os.path.isdir(artist_folder):
os.mkdir(artist_folder)
track_filename = artist_folder + "{0}.mp3".format(track['safe_title'])
artwork_filename = artist_folder + ".{0}-artwork.jpg".format(track['safe_title'])
track_filename = unicode(artist_folder) + u"{0}.mp3".format(track['safe_title'])
artwork_filename = unicode(artist_folder) + u".{0}-artwork.jpg".format(track['safe_title'])
if not self.silent:
sys.stdout.write(colors.HEADER + "Downloading: " + colors.END + colors.OKBLUE + "{0}".format(track['title']) + colors.END + "\n")
sys.stdout.write(unicode(colors.HEADER + "Downloading: " + colors.END + colors.OKBLUE) + u"{0}".format(track['title']) + unicode(colors.END + "\n"))
urllib.urlretrieve(url=track['stream_url'], filename=track_filename, reporthook=(None if self.silent else self.dl_progress))
# reset variables so next track's report hook doesn't malfunction
self.download_progress = 0
Expand All @@ -94,8 +94,9 @@ def dl_tracks(self, tracks):
embed_artwork(track_filename, artwork_filename)
os.remove(artwork_filename)
track_filename_list.append(track_filename)
except:
except e:
# in case of failure, just move on to next track
print e
continue
return track_filename_list

Expand Down Expand Up @@ -149,6 +150,5 @@ def download(url, download_path, silent=True):
print
print colors.HEADER + "The following files were downloaded successfully:" + colors.END
for i, filename in enumerate(list_of_downloaded_filenames):
print "\t" + colors.HEADER + str(i+1) + ". " + colors.END + colors.OKBLUE + " {0}".format(filename[len(dest):].split('/')[1]) + colors.END
print unicode("\t" + colors.HEADER + str(i+1) + ". " + colors.END + colors.OKBLUE) + u" {0}".format(filename[len(dest):].split('/')[1]) + unicode(colors.END)
print colors.OKGREEN + "Finished." + colors.END

0 comments on commit 3264fc5

Please sign in to comment.