Spotify-downloader: Invalid Characters in Titles

Created on 19 Feb 2018  路  8Comments  路  Source: spotDL/spotify-downloader

  • [x] Using latest version as provided on the master branch
  • [ ] [Searched](https://github.com/ritiek/spotify-downloader/issues?utf8=%E2%9C%93&q=is%3Aissue) for similar issues including closed ones

What is the purpose of your issue?

  • [x] Bug
  • [x] Feature Request
  • [ ] Question
  • [ ] Other

Description

Titles that include characters such as question marks and semi-colons can't be saved.
Maybe it would be better if there was an option to edit those title in command prompt when such a problem occurs.

Log

C:\Users\user>spotdl.py -s https://open.spotify.com/track/0oPnyCLqcn2ZNzwy5pLKDR
--log-level=DEBUG
DEBUG: Python version: 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 17:26:49) [MSC v.1900
32 bit (Intel)]
DEBUG: Platform: Windows-7-6.1.7601-SP1
DEBUG: {'album': None,
'avconv': False,
'config': None,
'download_only_metadata': False,
'dry_run': False,
'file_format': '{artist} - {track_name}',
'folder': 'Music',
'input_ext': '.m4a',
'list': None,
'log_level': 10,
'manual': False,
'music_videos_only': False,
'no_metadata': False,
'no_spaces': False,
'output_ext': '.mp3',
'overwrite': 'skip',
'playlist': None,
'song': 'https://open.spotify.com/track/0oPnyCLqcn2ZNzwy5pLKDR',
'username': None}
DEBUG: Fetching metadata for given track URL
DEBUG: Fetching lyrics
DEBUG: {'album': {'album_type': 'album',
'artists': [{'external_urls': {'spotify': 'https://open.spotify.c
om/artist/0FRKTwQSToXpCxYMhyUzYY'},
'href': 'https://api.spotify.com/v1/artists/0FRKTwQS
ToXpCxYMhyUzYY',
'id': '0FRKTwQSToXpCxYMhyUzYY',
'name': 'Have A Nice Life',
'type': 'artist',
'uri': 'spotify:artist:0FRKTwQSToXpCxYMhyUzYY'}],
'external_urls': {'spotify': 'https://open.spotify.com/album/6MH3
CAXp8AN8ELrbex18dM'},
'href': 'https://api.spotify.com/v1/albums/6MH3CAXp8AN8ELrbex18dM
',
'id': '6MH3CAXp8AN8ELrbex18dM',
'images': [{'height': 640,
'url': 'https://i.scdn.co/image/affb17e9a0ca038a43231
ec4a8556a5cfeb7c014',
'width': 640},
{'height': 300,
'url': 'https://i.scdn.co/image/8d3e05ba3a8205b2b9dd4
db8210b71450afe78a3',
'width': 300},
{'height': 64,
'url': 'https://i.scdn.co/image/d63498ffbb80063a7cd71
87d5ddf2a2cbcb55e56',
'width': 64}],
'name': 'Deathconsciousness',
'release_date': '2008-01-01',
'release_date_precision': 'day',
'type': 'album',
'uri': 'spotify:album:6MH3CAXp8AN8ELrbex18dM'},
'artists': [{'external_urls': {'spotify': 'https://open.spotify.com/artist/
0FRKTwQSToXpCxYMhyUzYY'},
'href': 'https://api.spotify.com/v1/artists/0FRKTwQSToXpCxYMhy
UzYY',
'id': '0FRKTwQSToXpCxYMhyUzYY',
'name': 'Have A Nice Life',
'type': 'artist',
'uri': 'spotify:artist:0FRKTwQSToXpCxYMhyUzYY'}],
'copyright': '(C) 2014 The Flenser',
'disc_number': 1,
'duration': 386.5,
'explicit': False,
'external_ids': {'isrc': 'USA2Z1410818'},
'external_urls': {'spotify': 'https://open.spotify.com/track/0oPnyCLqcn2ZNz
wy5pLKDR'},
'genre': 'Blackgaze',
'href': 'https://api.spotify.com/v1/tracks/0oPnyCLqcn2ZNzwy5pLKDR',
'id': '0oPnyCLqcn2ZNzwy5pLKDR',
'lyrics': 'Everything you do is planned out in advancen'
'The stars push their dark wills down on youn'
'And wolves all tear themselves apart better in packsn'
"That's just a function we'll have to work on throughn"
'We are machines that eat and breathe and look really cooln'
"You're reacting just the way I thought you wouldn"
"But I've replaced my heart with metal partsn"
"And I'm working just fine, but I can't get it to startn"
'We are machines that breathe and weep and look really good train
ed '
'to killn'
"Send me back in time and I'll bring us back in linen"
'Just tell me whose mother I have to killn'
"I'm fine like I've always been, except I don't remember-whenn"
"My conscience wasn't acting up againn"
"We're living on borrowed timen"
'And it looks like they want it back',
'name': 'Holy Fucking Shit: 40,000',
'popularity': 36,
'preview_url': 'https://p.scdn.co/mp3-preview/ea1a2f0b9d702c40ca8bc9dd202f4
64e80d6b84e?cid=4fe3fecfe5334023a1472516cc99d805',
'publisher': 'The Flenser',
'release_date': '2008-01-01',
'total_tracks': 13,
'track_number': 9,
'type': 'track',
'uri': 'spotify:track:0oPnyCLqcn2ZNzwy5pLKDR',
'year': '2008'}
DEBUG: query: {'part': 'snippet', 'maxResults': 50, 'type': 'video', 'q': 'Have
A Nice Life - Holy Fucking Shit: 40,000'}
DEBUG: query_results: {'part': 'contentDetails,snippet,statistics', 'maxResults'
: 50, 'id': '8RtSOK2p61s,rGfJ_vJYj8c,0tsvZ22GLVU,HUYapbZ2P0U,awcDQiM145U,i0ggZWm
iLi4,cPKqB_qIBZg,-_5nOws5a6A,AdEWlIUEJ_c,u6-_eXmsGXg,XIROM9aeGNQ,jwcsFcJKqgw,GdF
yd6yr03A,MH-kXWhKHcM,lRII5-vy1xA,W3BSjY-ZNiU,Nf8UaWE3M8s,LI3s68dB-vM,iV_sIFSgqr0
,jB0l5Xl9CO8,ShWYTGh-NXo,I1kE1M7v16k,kec5Mjs9rTs,uV1tNopQJt8,WIEcT1cYkQM,70lp_Vx
Zbkc,LEI_GdHYLD4,6UZBSocz0JQ,PuPY4sHGLGU,gXa7muRuasc,0Cg6qk-MPSg,v_h6CxsG0k4,M3k
g5TZftdA,1uRe0tAAVns,P4nmbJ_88yo,MA8TVz7ojd8,YpE9gW3ZYXY,5Fakb3OfDr0,JAVmWaLHUNQ
,3cosuCnJSYE,4LL8Un5vwog,iHgmZjiUGBU,GCw4NJsPMR0,uL-ZMlLc6MI,i1adIISaXnw,cTTm7FB
8X68,xeYUokADbaQ,RG__UzFGjsM,MPNwgKGWym4,znKODrmsYSk'}
INFO: Have a Nice Life - Holy Fucking Shit: 40,000 (http://www.youtube.com/watch
?v=8RtSOK2p61s)
DEBUG: Refining songname from "Have a Nice Life - Holy Fucking Shit: 40,000" to
"Have A Nice Life - Holy Fucking Shit: 40,000"
DEBUG: Cleaning any temp files and checking if "Have A Nice Life - Holy Fucking
Shit: 40,000" already exists
DEBUG: Downloading from URL: https://r3---sn-uxaxjvhxbt2u-j5pr.googlevideo.com/v
ideoplayback?mime=audio%2Fmp4&dur=388.237&itag=140&expire=1519095784&ip=41.239.6
0.59&gir=yes&mm=31%2C29&source=youtube&mn=sn-uxaxjvhxbt2u-j5pr%2Csn-hgn7rn7y&ei=
iDuLWsHqDsy6VoHKv7AI&id=o-AG3Lctv3zhVgk2KBHhLuk3o0znIqWL3oZPSmtnz_Y3Dc&ms=au%2Cr
du&mt=1519074059&pl=21&mv=m&fvip=3&key=yt6&initcwndbps=78750&ipbits=0&c=WEB&spar
ams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2C
lmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&clen=6233358&
requiressl=yes&lmt=1408169827619042&keepalive=yes&signature=8BE05B4657ACDB3ABF74
E1B7CE903E1D3D3D957A.4252AC68AD5730692B0800B11761F4AB5A6AEA00&ratebypass=yes
DEBUG: Saving to: Music\Have A Nice Life - Holy Fucking Shit: 40,000.m4a
Traceback (most recent call last):ed. Rate: [ 54 KB/s]. ETA: [0 secs]
File "C:\Users\user\Downloads\spotify-downloader-master\spotdl.py", line 183,
in
download_single(raw_song=const.args.song)
File "C:\Users\user\Downloads\spotify-downloader-master\spotdl.py", line 152,
in download_single
if youtube_tools.download_song(input_song, content):
File "C:\Users\user\Downloads\spotify-downloader-mastercore\youtube_tools.py"
, line 51, in download_song
link.download(filepath=filepath)
File "C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-package
s\pafy\backend_shared.py", line 664, in download
os.rename(temp_filepath, filepath)
OSError: [WinError 87] The parameter is incorrect: 'Music\Have A Nice Life - Ho
ly Fucking Shit: 40,000.m4a.temp' -> 'Music\Have A Nice Life - Holy Fucking Shi
t: 40,000.m4a'

Debug for title with :

bug

Most helpful comment

It's been getting on my nerves the last few days, so I decided to use this temporary solution instead.
I opened spotdl.py and added after line 144 the following code:

for x in ["/", "\\", "<", ">", "?", ":", "*", '"', "|"]:
        if songname.find(x) != -1:
            songname = songname.replace(x, "")

It should be able to replace all invalid characters, but it won't ask for prompt.
Also, before I end this comment I want to thank the creator and the contributors for this awesome application. I've been depending on it more often nowadays.

All 8 comments

Can confirm
I'd like the option to change filename in an argument, like --filename "Ou Est Le Soleil" So I don't have to worry about the accented "U"
Track 13. O霉 Est Le Soleil? (Remastered 2017) (http://www.youtube.com/watch?v=VS
M5ChQm5eI)

Another issue is tracks that have a '/' in the name, I have a few extra directories now, "Paul McCartney - Uncle Albert" and "Paul McCartney - Say Say Say - Radio Edit"... infinite loop of "fails"

It's been getting on my nerves the last few days, so I decided to use this temporary solution instead.
I opened spotdl.py and added after line 144 the following code:

for x in ["/", "\\", "<", ">", "?", ":", "*", '"', "|"]:
        if songname.find(x) != -1:
            songname = songname.replace(x, "")

It should be able to replace all invalid characters, but it won't ask for prompt.
Also, before I end this comment I want to thank the creator and the contributors for this awesome application. I've been depending on it more often nowadays.

Thanks, that seems to work in most song titles - I don't know python very well, but I do know you probably need to do something about "霉", whether "\u00f9" or just straight up escaping the character "\霉"... Once I figure this out I will update your little fix to account for accented letters, and a few other characters.

Thanks to both ritiek and ifdyourgoats for the application and the little fix, respectively.

Sorry, I am a bit busy at the moment. I'll take a good look on this issue later on.

I can also confirm that @ifdyourgoats code works as expected. I used to get errors / extraneous directories, but with this addition - no more!

@ritiek It would seem that "slugify" in the program's internals doesn't handle sanitization of the filename at the right time. I haven't gone too far through it, but it should be a simple fix that will also handle weird unicode characters?

@ifdyourgoats code is perfect, but it might be better if we replace those special characters with "-" or other placeholders so it won't look weird.

I'd like the option to change filename in an argument, like --filename "Ou Est Le Soleil" So I don't have to worry about the accented "U"

It is possible to set custom filenames by passing --file-format FILE_FORMAT option via command line or by modifying file-format in config.yml.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikhailZex picture MikhailZex  路  5Comments

Maxino22 picture Maxino22  路  4Comments

ritiek picture ritiek  路  5Comments

GUI
adrcotfas picture adrcotfas  路  5Comments

jjboy91 picture jjboy91  路  5Comments