flyingrub / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.18k stars 324 forks source link

TypeError: can only concatenate str (not "NoneType") to str #453

Open awsms opened 11 months ago

awsms commented 11 months ago
Traceback (most recent call last):
  File "/home/me/.local/bin/scdl", line 8, in <module>
    sys.exit(main())
  File "/home/me/.local/lib/python3.8/site-packages/scdl/scdl.py", line 239, in main
    download_url(client, **python_args)
  File "/home/me/.local/lib/python3.8/site-packages/scdl/scdl.py", line 344, in download_url
    download_track(client, track, exit_on_fail=kwargs.get("strict_playlist"), **kwargs)
  File "/home/me/.local/lib/python3.8/site-packages/scdl/scdl.py", line 712, in download_track
    filename, is_already_downloaded = download_original_file(client, track, title, playlist_info, **kwargs)
  File "/home/me/.local/lib/python3.8/site-packages/scdl/scdl.py", line 567, in download_original_file
    filename += ext
TypeError: can only concatenate str (not "NoneType") to str

always getting this error on https://soundcloud.com/stanlepard/kurplaxin-by-vibramax

max-ishere commented 8 months ago

It seems the track doesnt have an extension and soundcloud didnt label it with Content-Type: (mime type). So the propper solution would probably be to implement functionality like unix file command:

$ file Kurplaxin\ by\ Vibramax.unknown 
Kurplaxin by Vibramax.unknown: RIFF (little-endian) data, WAVE audio

As a temporary solution you can open the location of the script and add the following before line 633:

=        # Find file extension
=        mime = r.headers.get("content-type")
=        ext = ext or mimetypes.guess_extension(mime)
+
+        if ext == "" or ext == None:
+            ext = ".unknown"
+
=        filename += ext

ext here is the file extension.