scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.3k stars 331 forks source link

Charachter Encoding Problem on Windows #30

Closed mauricebasement closed 9 years ago

mauricebasement commented 9 years ago

As tracktitles often contain some fancy hip special chars scdl is not able to rename the downloaded file according to the title on soundcloud, as Windows filenames cannot contain this chars. So I am thinking about implementing a "special char elimination method", as the special chars can also cause problems when trying to set tags for the mp3. The method should be optional, as these problems seem not to occur on Unix based systems. What do you think about that?

mauricebasement commented 9 years ago

Favorite n°3 Downloading Chet Faker - I'm Into You (Monkeyneck Remix) FREE DL 100% [......................................................] 5096175 / 5096175 Settings tags... Error trying to set the tags...

Chet Faker - I'm Into You (Monkeyneck Remix) FREE DL.mp3 Downloaded.

Favorite n°4 Downloading Lykke Li - No Rest For The Wicked (Joris Voorn Remix) 100% [......................................................] 5857697 / 5857697 Settings tags... Error trying to set the tags...

Lykke Li - No Rest For The Wicked (Joris Voorn Remix).mp3 Downloaded.

Favorite n°5 Downloading Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix) 100% [......................................................] 4655646 / 4655646T raceback (most recent call last): File "C:\Python34\lib\shutil.py", line 522, in move os.rename(src, real_dst) OSError: [WinError 123] The filename, directory name or volume label syntax is i ncorrect: 'C:\Users\Moritz\scdl\gvXbdPexFgxh.128.mp3.sv8jl_cr.tmp' -> 'barta ndbaker - Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python34\Scripts\scdl-script.py", line 9, in load_entry_point('scdl==v1.0.5', 'console_scripts', 'scdl')() File "C:\Python34\lib\site-packages\scdl\scdl.py", line 92, in main download_user_favorites(who_am_i()) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 261, in downloaduser favorites download_track(track) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 323, in download_track

wget.download(url, filename)

File "C:\Python34\lib\site-packages\wget.py", line 320, in download shutil.move(tmpfile, filename) File "C:\Python34\lib\shutil.py", line 534, in move copy2(src, real_dst) File "C:\Python34\lib\shutil.py", line 244, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Python34\lib\shutil.py", line 108, in copyfile with open(dst, 'wb') as fdst: OSError: [Errno 22] Invalid argument: 'bartandbaker - Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

C:\Users\Moritz>scdl me -f -c --addtofile Soundcloud Downloader Downloading to D:\scdl...

Hello Moritz Keller !

Favorite n°1 Downloading Tchami x Janet Jackson - Go Deep (remix) Downloading the orginal file. 100% [....................................................] 12055148 / 12055148 Settings tags... Error trying to set the tags...

Tchami x Janet Jackson - Go Deep.mp3 Downloaded.

Favorite n°2 Downloading Rainforest Music - Podcast 36 Doctor Dru 100% [....................................................] 56513096 / 56513096 Settings tags... Error trying to set the tags...

Rainforest Music - Podcast 36 Doctor Dru.mp3 Downloaded.

Favorite n°3 Downloading Chet Faker - I'm Into You (Monkeyneck Remix) FREE DL 100% [......................................................] 5096175 / 5096175 Settings tags... Error trying to set the tags...

Chet Faker - I'm Into You (Monkeyneck Remix) FREE DL.mp3 Downloaded.

Favorite n°4 Downloading Lykke Li - No Rest For The Wicked (Joris Voorn Remix) 100% [......................................................] 5857697 / 5857697 Settings tags... Error trying to set the tags...

Lykke Li - No Rest For The Wicked (Joris Voorn Remix).mp3 Downloaded.

Favorite n°5 Downloading Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix) 100% [......................................................] 4655646 / 4655646T raceback (most recent call last): File "C:\Python34\lib\shutil.py", line 522, in move os.rename(src, real_dst) OSError: [WinError 123] The filename, directory name or volume label syntax is i ncorrect: 'D:\scdl\gvXbdPexFgxh.128.mp3.nnrocyra.tmp' -> 'bartandbaker - Bart& Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python34\Scripts\scdl-script.py", line 9, in load_entry_point('scdl==v1.0.5', 'console_scripts', 'scdl')() File "C:\Python34\lib\site-packages\scdl\scdl.py", line 92, in main download_user_favorites(who_am_i()) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 261, in downloaduser favorites download_track(track) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 323, in download_track

wget.download(url, filename)

File "C:\Python34\lib\site-packages\wget.py", line 320, in download shutil.move(tmpfile, filename) File "C:\Python34\lib\shutil.py", line 534, in move copy2(src, real_dst) File "C:\Python34\lib\shutil.py", line 244, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Python34\lib\shutil.py", line 108, in copyfile with open(dst, 'wb') as fdst: OSError: [Errno 22] Invalid argument: 'bartandbaker - Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

C:\Users\Moritz>scdl me -f -c -o4 --addtofile Soundcloud Downloader Downloading to D:\scdl...

Hello Moritz Keller !

Favorite n°1 Downloading Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix) 100% [......................................................] 4655646 / 4655646T raceback (most recent call last): File "C:\Python34\lib\shutil.py", line 522, in move os.rename(src, real_dst) OSError: [WinError 123] The filename, directory name or volume label syntax is i ncorrect: 'D:\scdl\gvXbdPexFgxh.128.mp3.qw7ns9hv.tmp' -> 'bartandbaker - Bart& Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python34\Scripts\scdl-script.py", line 9, in load_entry_point('scdl==v1.0.5', 'console_scripts', 'scdl')() File "C:\Python34\lib\site-packages\scdl\scdl.py", line 92, in main download_user_favorites(who_am_i()) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 261, in downloaduser favorites download_track(track) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 323, in download_track

wget.download(url, filename)

File "C:\Python34\lib\site-packages\wget.py", line 320, in download shutil.move(tmpfile, filename) File "C:\Python34\lib\shutil.py", line 534, in move copy2(src, real_dst) File "C:\Python34\lib\shutil.py", line 244, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Python34\lib\shutil.py", line 108, in copyfile with open(dst, 'wb') as fdst: OSError: [Errno 22] Invalid argument: 'bartandbaker - Bart&Baker Featuring Lolly Wish "Downloaded" (Rogan Remix).mp3'

C:\Users\Moritz>scdl me -f -c -o5 --addtofile Soundcloud Downloader Downloading to D:\scdl...

Hello Moritz Keller !

Favorite n°1 Downloading Bakermat - Teach Me (Original Mix) 100% [......................................................] 5305572 / 5305572 Settings tags... Error trying to set the tags...

Bakermat - Teach Me (Original Mix).mp3 Downloaded.

Favorite n°2 Downloading Pretty Ricky ft. 50 Cent - Grind With Me (SNBRN Remix) 100% [......................................................] 4172903 / 4172903 Settings tags... Error trying to set the tags...

Pretty Ricky ft. 50 Cent - Grind With Me (SNBRN Remix).mp3 Downloaded.

Favorite n°3 Downloading Sam Feldt - Sterrenstof (Mixtape) 100% [....................................................] 58443649 / 58443649 Settings tags... Error trying to set the tags...

Sam Feldt - Sterrenstof (Mixtape).mp3 Downloaded.

Favorite n°4 Downloading Want You Here (Vocal Mix) by KR$CHN ft Rachael Ward 100% [......................................................] 5005478 / 5005478 Settings tags... Error trying to set the tags...

FutureGarage - EDM.com - Want You Here (Vocal Mix) by KR$CHN ft Rachael Ward.mp3 Downloaded.

Favorite n°5 Downloading DubRocca - Here For You [ft. Paul Akister] 100% [......................................................] 3585252 / 3585252 Settings tags... Error trying to set the tags...

Traceback (most recent call last): File "C:\Python34\Scripts\scdl-script.py", line 9, in load_entry_point('scdl==v1.0.5', 'console_scripts', 'scdl')() File "C:\Python34\lib\site-packages\scdl\scdl.py", line 92, in main download_user_favorites(who_am_i()) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 261, in downloaduser favorites download_track(track) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 343, in download_track

print(filename + ' Downloaded.')

File "C:\Python34\lib\encodings\cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u042f' in position 3: character maps to

C:\Users\Moritz>scdl me -f -c -o10 --addtofile Soundcloud Downloader Downloading to D:\scdl...

Hello Moritz Keller !

Favorite n°1 Downloading Selected Deep House 150k Mix | by Endor 100% [....................................................] 46227120 / 46227120 Settings tags... Error trying to set the tags...

Selected. - Selected Deep House 150k Mix by Endor.mp3 Downloaded.

Favorite n°2 Downloading Jacob Plant - Louder (Kennedy Jones Remix) 100% [......................................................] 4477177 / 4477177 Settings tags... Error trying to set the tags...

Trap - EDM.com - Jacob Plant - Louder (Kennedy Jones Remix).mp3 Downloaded.

Favorite n°3 Downloading Kirkegaard - Back In The 80´s 100% [......................................................] 4788975 / 4788975 Settings tags... Error trying to set the tags...

Kirkegaard (official) - Kirkegaard - Back In The 80´s.mp3 Downloaded.

Favorite n°4 Downloading Dennis Calmer - Together In The Dark 88 By Luigi Rossi Downloading the orginal file. 100% [..................................................] 144913433 / 144913433 Settings tags... Error trying to set the tags...

Dennis Calmer - Together In The Dark 88 By Luigi Rossi.mp3 Downloaded.

Favorite n°5 Traceback (most recent call last): File "C:\Python34\Scripts\scdl-script.py", line 9, in load_entry_point('scdl==v1.0.5', 'console_scripts', 'scdl')() File "C:\Python34\lib\site-packages\scdl\scdl.py", line 92, in main download_user_favorites(who_am_i()) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 261, in downloaduser favorites download_track(track) File "C:\Python34\lib\site-packages\scdl\scdl.py", line 303, in download_track

print("Downloading " + title)

File "C:\Python34\lib\encodings\cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u2013' in position 19: character maps to

C:\Users\Moritz>^A

Three char encoding issues:

  1. cannot rename downloaded Track
  2. cannot display Trackname that should be downloaded
  3. I am not sure about the tag-setting errors, they seem to occur always, so maybe have nothing to do with the char encoding.
flyingrub commented 9 years ago

we already have a blacklist of invalid character for a filename , all other char should work, it's probalby something simple that i missed. https://github.com/flyingrub/scdl/blob/master/scdl/scdl.py#L315

mauricebasement commented 9 years ago

for sure you missed " specchars

mauricebasement commented 9 years ago

Sent you a pull request with an fix for the issues.