nathom / streamrip

A scriptable music downloader for Qobuz, Tidal, SoundCloud, and Deezer
GNU General Public License v3.0
2.7k stars 244 forks source link

[BUG] Error while trying to download a song from SoundCloud #270

Closed b1scoito closed 2 years ago

b1scoito commented 2 years ago

Describe the bug

When I try to download a SoundCloud song I get this error: unsupported operand type(s) for /=: 'NoneType' and 'int'

Command Used

$ rip url https://soundcloud.com/chediak/delirios

Debug Traceback

DEBUG:streamrip:Config loaded
DEBUG:streamrip:client_id: zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym, app_version: 1641983405
DEBUG:streamrip:Fetching url https://api-v2.soundcloud.com/announcements with params {'client_id': 'zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym', 'app_version': '1641983405', 'app_locale': 'en'}
DEBUG:streamrip:Fetching url https://api-v2.soundcloud.com/resolve?url=https://soundcloud.com/chediak/delirios with params {'client_id': 'zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym', 'app_version': '1641983405', 'app_locale': 'en'}
DEBUG:streamrip:{'artwork_url': 'https://i1.sndcdn.com/artworks-KH4deSoum7w2UHOH-WbPZ1g-large.jpg',
 'caption': None,
 'comment_count': 13,
 'commentable': True,
 'created_at': '2021-11-18T01:43:50Z',
 'description': 'Essa é pra dar rolê de carro no GTA Vice City.\n'
                '\n'
                'Download liberado, sejam felizes, se for tocar no rolê me '
                'marca no stories <3\n'
                '\n'
                'Te amo @vhoor!',
 'display_date': '2021-11-18T01:43:50Z',
 'download_count': 64,
 'downloadable': True,
 'duration': 182883,
 'embeddable_by': 'all',
 'full_duration': 182883,
 'genre': 'Drum & Bass',
 'has_downloads_left': True,
 'id': 1162186507,
 'kind': 'track',
 'label_name': None,
 'last_modified': '2021-11-18T01:43:51Z',
 'license': 'all-rights-reserved',
 'likes_count': 158,
 'media': {'transcodings': [{'duration': 182883,
                             'format': {'mime_type': 'audio/mpeg',
                                        'protocol': 'hls'},
                             'preset': 'mp3_0_1',
                             'quality': 'sq',
                             'snipped': False,
                             'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/8167ab03-9a58-461a-baba-6220d4352921/stream/hls'},
                            {'duration': 182883,
                             'format': {'mime_type': 'audio/mpeg',
                                        'protocol': 'progressive'},
                             'preset': 'mp3_0_1',
                             'quality': 'sq',
                             'snipped': False,
                             'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/8167ab03-9a58-461a-baba-6220d4352921/stream/progressive'},
                            {'duration': 182864,
                             'format': {'mime_type': 'audio/ogg; codecs="opus"',
                                        'protocol': 'hls'},
                             'preset': 'opus_0_0',
                             'quality': 'sq',
                             'snipped': False,
                             'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/2ba117e6-f8da-417e-a012-f68296c52635/stream/hls'}]},
 'monetization_model': 'NOT_APPLICABLE',
 'permalink': 'delirios',
 'permalink_url': 'https://soundcloud.com/chediak/delirios',
 'playback_count': 2057,
 'policy': 'ALLOW',
 'public': True,
 'publisher_metadata': {'contains_music': True,
                        'id': 1162186507,
                        'urn': 'soundcloud:tracks:1162186507'},
 'purchase_title': None,
 'purchase_url': None,
 'release_date': None,
 'reposts_count': 12,
 'secret_token': None,
 'sharing': 'public',
 'state': 'finished',
 'station_permalink': 'track-stations:1162186507',
 'station_urn': 'soundcloud:system-playlists:track-stations:1162186507',
 'streamable': True,
 'tag_list': 'jungle miami',
 'title': 'FBC & Vhoor - Delírios (Chediak Remix)',
 'track_authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJnZW8iOiJCUiIsInN1YiI6IiIsInJpZCI6Ijg4MWI3ZDI2LTI0YzctNDJjZS04YjI1LWUyYjQxZTZiYTAxZCIsImlhdCI6MTY0MjA4NjQyN30.FF-YWhERq5mc2hWizbetK9t7F-cCdaLLBo1KseCgwoI',
 'track_format': 'single-track',
 'uri': 'https://api.soundcloud.com/tracks/1162186507',
 'urn': 'soundcloud:tracks:1162186507',
 'user': {'avatar_url': 'https://i1.sndcdn.com/avatars-y6B2ecvvOqOvX5en-RfU2EA-large.jpg',
          'badges': {'pro': False, 'pro_unlimited': False, 'verified': True},
          'city': '',
          'comments_count': 1481,
          'country_code': 'BR',
          'created_at': '2015-03-08T04:01:52Z',
          'creator_subscription': {'product': {'id': 'free'}},
          'creator_subscriptions': [{'product': {'id': 'free'}}],
          'description': 'MÚSICA ELÉTRICA •°°°×',
          'first_name': 'Pedro',
          'followers_count': 9535,
          'followings_count': 2001,
          'full_name': 'Pedro Chediak',
          'groups_count': 0,
          'id': 142148760,
          'kind': 'user',
          'last_modified': '2022-01-11T02:25:11Z',
          'last_name': 'Chediak',
          'likes_count': 5290,
          'permalink': 'chediak',
          'permalink_url': 'https://soundcloud.com/chediak',
          'playlist_count': 17,
          'playlist_likes_count': 78,
          'reposts_count': None,
          'station_permalink': 'artist-stations:142148760',
          'station_urn': 'soundcloud:system-playlists:artist-stations:142148760',
          'track_count': 61,
          'uri': 'https://api.soundcloud.com/users/142148760',
          'urn': 'soundcloud:users:142148760',
          'username': 'Chediak',
          'verified': True,
          'visuals': {'enabled': True,
                      'tracking': None,
                      'urn': 'soundcloud:users:142148760',
                      'visuals': [{'entry_time': 0,
                                   'urn': 'soundcloud:visuals:148580421',
                                   'visual_url': 'https://i1.sndcdn.com/visuals-000142148760-hVVRax-original.jpg'}]}},
 'user_id': 142148760,
 'visuals': None,
 'waveform_url': 'https://wave.sndcdn.com/ga8v6xbsnWJY_m.json'}
DEBUG:streamrip:Parsed urls: [('soundcloud', 'track', '1162186507')]
DEBUG:streamrip:Searching for {'id': '1162186507'} in database
DEBUG:streamrip:Executing SELECT EXISTS(SELECT 1 FROM downloads WHERE id=?)
DEBUG:streamrip:{'id': '1162186507'}
DEBUG:streamrip:{'downloads': {'folder': '/media/biscoito/Music', 'source_subdirectories': False, 'concurrency': {'enabled': True, 'max_connections': 3}}, 'qobuz': {'quality': 4, 'download_booklets': True, 'email': 'xxx@xxx.xxx', 'password': 'xxx', 'app_id': 'xxx', 'secrets': ['xxx', 'xxx']}, 'tidal': {'quality': 3, 'download_videos': True, 'user_id': '', 'country_code': '', 'access_token': '', 'refresh_token': '', 'token_expiry': ''}, 'deezer': {'quality': 2, 'arl': '', 'use_deezloader': True, 'deezloader_warnings': True}, 'soundcloud': {'quality': 0, 'client_id': 'zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym', 'app_version': '1641983405'}, 'youtube': {'quality': 0, 'download_videos': False, 'video_downloads_folder': ''}, 'database': {'downloads': {'enabled': True, 'path': '/root/.config/streamrip/downloads.db'}, 'failed_downloads': {'enabled': True, 'path': '/root/.config/streamrip/failed_downloads.db'}}, 'conversion': {'enabled': False, 'codec': 'ALAC', 'sampling_rate': 48000, 'bit_depth': 24, 'lossy_bitrate': 320}, 'filters': {'extras': False, 'repeats': False, 'non_albums': False, 'features': False, 'non_studio_albums': False, 'non_remaster': False}, 'artwork': {'embed': True, 'size': 'large', 'max_width': -1, 'max_height': -1, 'keep_hires_cover': True}, 'metadata': {'set_playlist_to_album': True, 'new_playlist_tracknumbers': True, 'exclude': []}, 'filepaths': {'add_singles_to_folder': True, 'folder_format': '{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]', 'track_format': '{tracknumber}. {artist} - {title}', 'restrict_characters': False}, 'lastfm': {'source': 'qobuz', 'fallback_source': 'deezer'}, 'theme': {'progress_bar': 'dainty'}, 'misc': {'version': '1.7'}}
DEBUG:streamrip:Arguments from config: {'restrict_filenames': False, 'parent_folder': '/media/biscoito/Music', 'folder_format': '{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]', 'track_format': '{tracknumber}. {artist} - {title}', 'embed_cover': True, 'embed_cover_size': 'large', 'keep_hires_cover': True, 'set_playlist_to_album': True, 'stay_temp': False, 'conversion': {'enabled': False, 'codec': 'ALAC', 'sampling_rate': 48000, 'bit_depth': 24, 'lossy_bitrate': 320}, 'concurrent_downloads': True, 'max_connections': 3, 'new_tracknumbers': True, 'download_videos': True, 'download_booklets': True, 'download_youtube_videos': False, 'youtube_video_downloads_folder': '', 'add_singles_to_folder': True, 'max_artwork_width': -1, 'max_artwork_height': -1, 'exclude_tags': []}
DEBUG:streamrip:Loading metadata
DEBUG:streamrip:Fetching url https://api-v2.soundcloud.com/tracks/1162186507 with params {'client_id': 'zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym', 'app_version': '1641983405', 'app_locale': 'en'}
DEBUG:streamrip:{'artwork_url': 'https://i1.sndcdn.com/artworks-KH4deSoum7w2UHOH-WbPZ1g-large.jpg', 'caption': None, 'commentable': True, 'comment_count': 13, 'created_at': '2021-11-18T01:43:50Z', 'description': 'Essa é pra dar rolê de carro no GTA Vice City.\n\nDownload liberado, sejam felizes, se for tocar no rolê me marca no stories <3\n\nTe amo @vhoor!', 'downloadable': True, 'download_count': 64, 'duration': 182883, 'full_duration': 182883, 'embeddable_by': 'all', 'genre': 'Drum & Bass', 'has_downloads_left': True, 'id': 1162186507, 'kind': 'track', 'label_name': None, 'last_modified': '2021-11-18T01:43:51Z', 'license': 'all-rights-reserved', 'likes_count': 158, 'permalink': 'delirios', 'permalink_url': 'https://soundcloud.com/chediak/delirios', 'playback_count': 2057, 'public': True, 'publisher_metadata': {'id': 1162186507, 'urn': 'soundcloud:tracks:1162186507', 'contains_music': True}, 'purchase_title': None, 'purchase_url': None, 'release_date': None, 'reposts_count': 12, 'secret_token': None, 'sharing': 'public', 'state': 'finished', 'streamable': True, 'tag_list': 'jungle miami', 'title': 'FBC & Vhoor - Delírios (Chediak Remix)', 'track_format': 'single-track', 'uri': 'https://api.soundcloud.com/tracks/1162186507', 'urn': 'soundcloud:tracks:1162186507', 'user_id': 142148760, 'visuals': None, 'waveform_url': 'https://wave.sndcdn.com/ga8v6xbsnWJY_m.json', 'display_date': '2021-11-18T01:43:50Z', 'media': {'transcodings': [{'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/8167ab03-9a58-461a-baba-6220d4352921/stream/hls', 'preset': 'mp3_0_1', 'duration': 182883, 'snipped': False, 'format': {'protocol': 'hls', 'mime_type': 'audio/mpeg'}, 'quality': 'sq'}, {'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/8167ab03-9a58-461a-baba-6220d4352921/stream/progressive', 'preset': 'mp3_0_1', 'duration': 182883, 'snipped': False, 'format': {'protocol': 'progressive', 'mime_type': 'audio/mpeg'}, 'quality': 'sq'}, {'url': 'https://api-v2.soundcloud.com/media/soundcloud:tracks:1162186507/2ba117e6-f8da-417e-a012-f68296c52635/stream/hls', 'preset': 'opus_0_0', 'duration': 182864, 'snipped': False, 'format': {'protocol': 'hls', 'mime_type': 'audio/ogg; codecs="opus"'}, 'quality': 'sq'}]}, 'station_urn': 'soundcloud:system-playlists:track-stations:1162186507', 'station_permalink': 'track-stations:1162186507', 'track_authorization': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJnZW8iOiJCUiIsInN1YiI6IiIsInJpZCI6Ijg4MWI3ZDI2LTI0YzctNDJjZS04YjI1LWUyYjQxZTZiYTAxZCIsImlhdCI6MTY0MjA4NjQyN30.FF-YWhERq5mc2hWizbetK9t7F-cCdaLLBo1KseCgwoI', 'monetization_model': 'NOT_APPLICABLE', 'policy': 'ALLOW', 'user': {'avatar_url': 'https://i1.sndcdn.com/avatars-y6B2ecvvOqOvX5en-RfU2EA-large.jpg', 'first_name': 'Pedro', 'followers_count': 9535, 'full_name': 'Pedro Chediak', 'id': 142148760, 'kind': 'user', 'last_modified': '2022-01-11T02:25:11Z', 'last_name': 'Chediak', 'permalink': 'chediak', 'permalink_url': 'https://soundcloud.com/chediak', 'uri': 'https://api.soundcloud.com/users/142148760', 'urn': 'soundcloud:users:142148760', 'username': 'Chediak', 'verified': True, 'city': '', 'country_code': 'BR', 'badges': {'pro': False, 'pro_unlimited': False, 'verified': True}, 'station_urn': 'soundcloud:system-playlists:artist-stations:142148760', 'station_permalink': 'artist-stations:142148760'}}

  Stack trace:

  10  /usr/local/lib/python3.8/dist-packages/cleo/application.py:314 in run
       312│
       313│             try:
     → 314│                 exit_code = self._run(io)
       315│             except Exception as e:
       316│                 if not self._catch_exceptions:

   9  /usr/local/lib/python3.8/dist-packages/rip/cli.py:604 in _run
       602│             logger.addHandler(fh)
       603│
     → 604│         super()._run(io)
       605│
       606│     def create_io(self, input=None, output=None, error_output=None):

   8  /usr/local/lib/python3.8/dist-packages/cleo/application.py:409 in _run
       407│                 io.set_input(ArgvInput(argv))
       408│
     → 409│         exit_code = self._run_command(command, io)
       410│         self._running_command = None
       411│

   7  /usr/local/lib/python3.8/dist-packages/cleo/application.py:416 in _run_command
       414│     def _run_command(self, command: Command, io: IO) -> int:
       415│         if self._event_dispatcher is None:
     → 416│             return command.run(io)
       417│
       418│         # Bind before the console.command event,

   6  /usr/local/lib/python3.8/dist-packages/cleo/commands/base_command.py:118 in run
       116│         io.input.validate()
       117│
     → 118│         status_code = self.execute(io)
       119│
       120│         if status_code is None:

   5  /usr/local/lib/python3.8/dist-packages/cleo/commands/command.py:85 in execute
        83│
        84│         try:
     →  85│             return self.handle()
        86│         except KeyboardInterrupt:
        87│             return 1

   4  /usr/local/lib/python3.8/dist-packages/rip/cli.py:87 in handle
        85│
        86│         if len(core) > 0:
     →  87│             core.download()
        88│         elif not urls and path is None:
        89│             self.line("Must pass arguments. See rip url -h.")

   3  /usr/local/lib/python3.8/dist-packages/rip/core.py:316 in download
       314│
       315│             try:
     → 316│                 item.download(**arguments)
       317│                 for item_id in item.downloaded_ids:
       318│                     self.db.add([item_id])

   2  /usr/local/lib/python3.8/dist-packages/streamrip/media.py:292 in download
        290│             secho(f"Downloading {self!s}\n", bold=True)
        291│
     →  292│         self._prepare_download(
        293│             quality=quality,
        294│             parent_folder=parent_folder,

   1  /usr/local/lib/python3.8/dist-packages/streamrip/media.py:248 in _prepare_download
        246│                 clean_format(
        247│                     kwargs.get("folder_format", FOLDER_FORMAT),
     →  248│                     self.meta.get_album_formatter(self.quality),
        249│                     restrict=kwargs.get("restrict_filenames", False),
        250│                 ),

  TypeError

  unsupported operand type(s) for /=: 'NoneType' and 'int'

  at /usr/local/lib/python3.8/dist-packages/streamrip/metadata.py:460 in get_album_formatter
      456│         :rtype: dict
      457│         """
      458│         formatter = {k: self.get(k) for k in ALBUM_KEYS}
      459│         formatter["container"] = "FLAC" if max_quality >= 2 else "MP3"
    → 460│         formatter["sampling_rate"] /= 1000
      461│         return formatter
      462│
      463│     def tags(self, container: str = "flac", exclude: Optional[set] = None) -> Generator:
      464│         """Create a generator of key, value pairs for use with mutagen.

If this was unexpected, please open a Bug Report at https://github.com/nathom/streamrip/issues/new/choose

Config File

[downloads]
# Folder where tracks are downloaded to
folder = "/media/biscoito/Music"
# Put Qobuz albums in a 'Qobuz' folder, Tidal albums in 'Tidal' etc.
source_subdirectories = false

[downloads.concurrency]
# Download (and convert) tracks all at once, instead of sequentially.
# If you are converting the tracks, or have fast internet, this will
# substantially improve processing speed.
enabled = true
# The maximum number of tracks to download at once
# If you have very fast internet, you will benefit from a higher value,
# A value that is too high for your bandwidth may cause slowdowns
max_connections = 3

[qobuz]
# 1: 320kbps MP3, 2: 16/44.1, 3: 24/<=96, 4: 24/>=96
quality = 4
# This will download booklet pdfs that are included with some albums
download_booklets = true

email = "xxx@xxx.xxx"
# This is an md5 hash of the plaintext password
password = "xxx"
# Do not change
app_id = "xxx"
# Do not change
secrets = ["xxx", "xxx"]

[tidal]
# 0: 256kbps AAC, 1: 320kbps AAC, 2: 16/44.1 "HiFi" FLAC, 3: 24/44.1 "MQA" FLAC
quality = 3
# This will download videos included in Video Albums.
download_videos = true

# Do not change any of the fields below
user_id = ""
country_code = ""
access_token = ""
refresh_token = ""
# Tokens last 1 week after refresh. This is the Unix timestamp of the expiration
# time. If you haven't used streamrip in more than a week, you may have to log
# in again using `rip config --tidal`
token_expiry = ""

[deezer]
# 0, 1, or 2
# This only applies to paid Deezer subscriptions. Those using deezloader
# are automatically limited to quality = 1
quality = 2
# An authentication cookie that allows streamrip to use your Deezer account
# See https://github.com/nathom/streamrip/wiki/Finding-Your-Deezer-ARL-Cookie
# for instructions on how to find this
arl = ""
# This allows for free 320kbps MP3 downloads from Deezer
# If an arl is provided, deezloader is never used
use_deezloader = true
# This warns you when the paid deezer account is not logged in and rip falls
# back to deezloader, which is unreliable
deezloader_warnings = true

[soundcloud]
# Only 0 is available for now
quality = 0
# This changes periodically, so it needs to be updated
client_id = "zZeR6I5DM5NMAYEhk7J9vveMqZzpCIym"
app_version = "1641983405"

[youtube]
# Only 0 is available for now
quality = 0
# Download the video along with the audio
download_videos = false
# The path to download the videos to
video_downloads_folder = ""

# This stores a list of item IDs so that repeats are not downloaded.

[database.downloads]
enabled = true
path = "/root/.config/streamrip/downloads.db"

# If a download fails, the item ID is stored here. Then, `rip repair` can be
# called to retry the downloads

[database.failed_downloads]
enabled = true
path = "/root/.config/streamrip/failed_downloads.db"

# Convert tracks to a codec after downloading them.

[conversion]
enabled = false
# FLAC, ALAC, OPUS, MP3, VORBIS, or AAC
codec = "ALAC"
# In Hz. Tracks are downsampled if their sampling rate is greater than this.
# Value of 48000 is recommended to maximize quality and minimize space
sampling_rate = 48000
# Only 16 and 24 are available. It is only applied when the bit depth is higher
# than this value.
bit_depth = 24
# Only applicable for lossy codecs
lossy_bitrate = 320

# Filter a Qobuz artist's discography. Set to 'true' to turn on a filter.

[filters]
# Remove Collectors Editions, live recordings, etc.
extras = false
# Picks the highest quality out of albums with identical titles.
repeats = false
# Remove EPs and Singles
non_albums = false
# Remove albums whose artist is not the one requested
features = false
# Skip non studio albums
non_studio_albums = false
# Only download remastered albums
non_remaster = false

[artwork]
# Write the image to the audio file
embed = true
# The size of the artwork to embed. Options: thumbnail, small, large, original.
# "original" images can be up to 30MB, and may fail embedding.
# Using "large" is recommended.
size = "large"
# Both of these options limit the size of the embedded artwork. If their values
# are larger than the actual dimensions of the image, they will be ignored.
# If either value is -1, the image is left untouched.
max_width = -1
max_height = -1
# Save the cover image at the highest quality as a seperate jpg file
keep_hires_cover = true

[metadata]
# Sets the value of the 'ALBUM' field in the metadata to the playlist's name.
# This is useful if your music library software organizes tracks based on album name.
set_playlist_to_album = true
# Replaces the original track's tracknumber with it's position in the playlist
new_playlist_tracknumbers = true
# The following metadata tags won't be applied
# See https://github.com/nathom/streamrip/wiki/Metadata-Tag-Names for more info
exclude = []

# Changes the folder and file names generated by streamrip.

[filepaths]
# Create folders for single tracks within the downloads directory using the folder_format
# template
add_singles_to_folder = true
# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
# "container", "id", and "albumcomposer"
folder_format = "{albumartist} - {title} ({year}) [{container}] [{bit_depth}B-{sampling_rate}kHz]"
# Available keys: "tracknumber", "artist", "albumartist", "composer", "title",
# and "albumcomposer"
track_format = "{tracknumber}. {artist} - {title}"
# Only allow printable ASCII characters in filenames.
restrict_characters = false

# Last.fm playlists are downloaded by searching for the titles of the tracks

[lastfm]
# The source on which to search for the tracks.
source = "qobuz"
# If no results were found with the primary source, the item is searched for
# on this one.
fallback_source = "deezer"

[theme]
# Options: "dainty" or "plain"
progress_bar = "dainty"

[misc]
# Metadata to identify this config file. Do not change.
version = "1.7"

Operating System

Ubuntu 20.04.3 LTS Kernel 5.11.0-46-generic

streamrip version

Rip (version 1.8)

Screenshots and recordings

No response

Additional context

No response

b1scoito commented 2 years ago

Thank you. There are tons of other tools that work too! It's just that this one can download from Qobuz and I wanted to have both functionalities in just one tool

b1scoito commented 2 years ago

@nathom The new update just seems to have broken everything. image

Now only SoundCloud works, Qobuz is not working (from what I've tested, and YouTube doesn't seem to work aswell...)

And the YouTube error: image

Also rip --version shows version 1.0. There's something wrong with the version because on every download it shows "Updating streamrip to v1.9..."

nathom commented 2 years ago

Thanks for the help. Just released a quick patch in v1.9.1.

b1scoito commented 2 years ago

Interesting. The issue with SoundCloud still seems to continue image