codezjx / netease-cloud-music-dl

Netease cloud music song downloader, with full ID3 metadata, eg: front cover image, artist name, album name, song title and so on.
MIT License
510 stars 84 forks source link

downloader: fix invalid chars in album/artist name #12

Closed weakish closed 7 years ago

weakish commented 7 years ago

If the name of an artist, an album contains the forward slash character, a.k.a. /, ncm will failed to create the directory to save the download file and will abort its execution with an exception.

For example, the album 雨のち晴れ / What's your name? contains /, which is forbidden in unix systems.

https://music.163.com/#/album?id=2569036

Commit cd3d043 replaces some special characters with white space in track name, but does not replace special characters in album and artist names.

This commit fix this issue by also replacing special characters in album and artist names.

Related issue: #7


ncm/downloader.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)

codezjx commented 7 years ago

Thanks for report this issue! I had already review you code. Why do not use the regular expression to replace illegal character? And I found the same issue if we use -hot/-a/-p options. I make a commit to fix this issue: #13 , and you can pull the newest code.

Thanks again for your PR~ ^^

weakish commented 7 years ago

Why do not use the regular expression

No particular reason. str.replace is usually easier to understand and maintain, and faster. So I tend to prefer str.replace when possible. Rethinking for this function, I realized that the regex is not complex, and the performance loss, if it exists, will be marginal. So the original re.sub does not need to be refactored to str.replace.

-hot/-a/-p options.

I forgot about them.

a commit to fix

The commit already includes the functions provided by this pull request. So I will close it.

Thanks for your project. I have been listening a lot of NetEase Cloud music, and the official web/desktop client does not satisfies my requirements. This project helps me a lot.