scdl-org / scdl

Soundcloud Music Downloader
GNU General Public License v2.0
3.37k stars 337 forks source link

TypeError: expected str, bytes or os.PathLike object, not NoneType #332

Closed hgabs closed 4 years ago

hgabs commented 4 years ago

In some cases executing scdl -l <url> will result in the following error:

Traceback (most recent call last):
  File "/usr/bin/scdl", line 11, in <module>
    load_entry_point('scdl==1.6.12', 'console_scripts', 'scdl')()
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 182, in main
    parse_url(arguments['-l'])
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 277, in parse_url
    download_playlist(item)
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 406, in download_playlist
    download_track(track_raw, playlist_info)
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 571, in download_track
    filename = download_hls_mp3(track, title)
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 541, in download_hls_mp3
    subprocess.call(['ffmpeg', '-i', url, '-c', 'copy', filename_path, '-loglevel', 'fatal'])
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not NoneType
flyingrub commented 4 years ago

Thanks for reporting and the PR ! Do you have an example of a track I can try ? Also could you provide the full log, with --debug ?

hgabs commented 4 years ago

I do have one, but you must take into account that it is location specific.

$ scdl -l https://soundcloud.com/haydenjamesartist/just-friends-feat-boy --debug
Soundcloud Downloader
{'--addtimestamp': False,
 '--addtofile': False,
 '--debug': True,
 '--download-archive': None,
 '--error': False,
 '--extract-artist': False,
 '--flac': False,
 '--help': False,
 '--hide-progress': False,
 '--hidewarnings': False,
 '--max-size': None,
 '--min-size': None,
 '--no-playlist-folder': False,
 '--onlymp3': False,
 '--path': None,
 '--remove': False,
 '--version': False,
 '-C': False,
 '-a': False,
 '-c': False,
 '-f': False,
 '-l': 'https://soundcloud.com/haydenjamesartist/just-friends-feat-boy',
 '-m': False,
 '-n': None,
 '-o': None,
 '-p': False,
 '-s': False,
 '-t': False,
 'me': False}
Downloading to /home/human...
https://api-v2.soundcloud.com/resolve?url=https://soundcloud.com/haydenjamesartist/just-friends-feat-boy&client_id=a3e059563d7fd3372b49b37f00a00bcf
{'comment_count': 4, 'full_duration': 239068, 'downloadable': False, 'created_at': '2018-06-22T02:03:40Z', 'description': None, 'media': {'transcodings': []}, 'title': 'Just Friends', 'publisher_metadata': {'p_line_for_display': '℗ A Virgin EMI Records recording; ℗ 2018 Future Classic Pty Ltd, under exclusive license to Universal Music Operations Limited', 'artist': 'Hayden James, Boy Matthews', 'isrc': 'AUFF01800030', 'c_line': '2018 © 2018 Future Classic Pty Ltd, under exclusive license to Universal Music Operations Limited', 'upc_or_ean': '00602567816881', 'p_line': 'A Virgin EMI Records recording; ℗ 2018 Future Classic Pty Ltd, under exclusive license to Universal Music Operations Limited', 'urn': 'soundcloud:tracks:461707713', 'explicit': True, 'c_line_for_display': '© 2018 © 2018 Future Classic Pty Ltd, under exclusive license to Universal Music Operations Limited', 'contains_music': True, 'id': 461707713, 'album_title': 'Just Friends', 'release_title': 'Just Friends'}, 'duration': 239068, 'has_downloads_left': True, 'artwork_url': 'https://i1.sndcdn.com/artworks-dgVJwNDQ96d1-0-large.jpg', 'public': True, 'streamable': True, 'tag_list': '', 'genre': 'Dance', 'id': 461707713, 'reposts_count': 73, 'state': 'finished', 'label_name': None, 'last_modified': '2020-02-21T21:19:45Z', 'commentable': True, 'policy': 'BLOCK', 'visuals': None, 'kind': 'track', 'purchase_url': None, 'sharing': 'public', 'uri': 'https://api.soundcloud.com/tracks/461707713', 'secret_token': None, 'download_count': 0, 'likes_count': 1049, 'urn': 'soundcloud:tracks:461707713', 'license': 'all-rights-reserved', 'purchase_title': None, 'display_date': '2018-04-27T00:00:00Z', 'embeddable_by': 'all', 'release_date': '2018-04-27T00:00:00Z', 'user_id': 17643044, 'monetization_model': 'NOT_APPLICABLE', 'waveform_url': 'https://wave.sndcdn.com/KKQjJNfNvkK3_m.json', 'permalink': 'just-friends-feat-boy', 'permalink_url': 'https://soundcloud.com/haydenjamesartist/just-friends-feat-boy', 'user': {'avatar_url': 'https://i1.sndcdn.com/avatars-AN2BRr2uGyIikAgJ-a0QyhQ-large.jpg', 'city': 'Sydney ', 'comments_count': 29, 'country_code': 'AU', 'created_at': '2012-05-27T22:13:18Z', 'creator_subscriptions': [{'product': {'id': 'creator-pro-unlimited'}}], 'creator_subscription': {'product': {'id': 'creator-pro-unlimited'}}, 'description': '', 'followers_count': 80472, 'followings_count': 91, 'first_name': 'Hayden', 'full_name': 'Hayden James', 'groups_count': 0, 'id': 17643044, 'kind': 'user', 'last_modified': '2020-04-10T18:13:38Z', 'last_name': 'James', 'likes_count': 63, 'playlist_likes_count': 1, 'permalink': 'haydenjamesartist', 'permalink_url': 'https://soundcloud.com/haydenjamesartist', 'playlist_count': 23, 'reposts_count': None, 'track_count': 79, 'uri': 'https://api.soundcloud.com/users/17643044', 'urn': 'soundcloud:users:17643044', 'username': 'HAYDEN JAMES', 'verified': False, 'visuals': {'urn': 'soundcloud:users:17643044', 'enabled': True, 'visuals': [{'urn': 'soundcloud:visuals:94180251', 'entry_time': 0, 'visual_url': 'https://i1.sndcdn.com/visuals-000017643044-s5kAF2-original.jpg'}], 'tracking': None}}, 'playback_count': 56607}
Found a track
Downloading Just Friends
filename : Just Friends.mp3
Traceback (most recent call last):
  File "/usr/bin/scdl", line 11, in <module>
    load_entry_point('scdl==1.6.12', 'console_scripts', 'scdl')()
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 182, in main
    parse_url(arguments['-l'])
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 274, in parse_url
    download_track(item)
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 571, in download_track
    filename = download_hls_mp3(track, title)
  File "/home/human/.local/lib/python3.8/site-packages/scdl/scdl.py", line 541, in download_hls_mp3
    subprocess.call(['ffmpeg', '-i', url, '-c', 'copy', filename_path, '-loglevel', 'fatal'])
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
TypeError: expected str, bytes or os.PathLike object, not NoneType
hgabs commented 4 years ago

I was thinking that maybe it is not common to encounter such behavior. Why would one download a song that is not available for their location? The problem is that if you are downloading a set of tracks and one is not available, it will result in the error and never get to download the rest of the available tracks.

flyingrub commented 4 years ago

Okay, I did not manage to reproduce it by myself but I will trust you on this one. Thanks again for the fix :)