exislow / tidal-dl-ng

TIDAL Media Downloader Next Generation! Up to HiRes Lossless / TIDAL MAX 24-bit, 192 kHz.
GNU Affero General Public License v3.0
300 stars 24 forks source link

[Bug] Cannot download certain songs due to index out of range error #156

Open Toastie opened 2 months ago

Toastie commented 2 months ago

What happened?

When downloading certain albums (e.g. https://tidal.com/browse/album/51332528?u) downloading will reliably crash on the same song, when the GUI is used the log shows HTTP Error 429 but no other logs.

For the before mentioned album the offending track is Disk 2, Track 15, Memories That You Call (Instrumental) https://tidal.com/browse/track/51332556?u

Attempting to download the individual track also does not work, though if the CL version is used some log output is produced (see below) including a index out of range error.

Python version used is 3.11.9

Version App

0.15.6

What operating system are you seeing the problem on?

Windows

Relevant log output

tidal-dl-ng dl https://tidal.com/browse/track/51332556?u
Let us check, if you are already logged in... Yep, looks good! You are logged in.
╭───────────────────────────────────────────────── Download Progress ──────────────────────────────────────────────────╮
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
│                                                                                                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidalapi\media.py:670   │
│ in from_mpd                                                                                      │
│                                                                                                  │
│   667 │   @staticmethod                                                                          │
│   668 │   def from_mpd(mpd_manifest) -> "DashInfo":                                              │
│   669 │   │   try:                                                                               │
│ ❱ 670 │   │   │   return DashInfo(mpd_manifest)                                                  │
│   671 │   │   except:                                                                            │
│   672 │   │   │   raise ManifestDecodeError                                                      │
│   673                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ mpd_manifest = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><MPD                               │ │
│ │                xmlns="urn:mpeg:dash:schema:mpd:2011"'+1497                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidalapi\media.py:719   │
│ in __init__                                                                                      │
│                                                                                                  │
│   716 │   │   )                                                                                  │
│   717 │   │   # self.chunkcount = mpd.periods[0].adaptation_sets[0].representations[0].segment   │
│   718 │   │   self.last_chunk_size = (                                                           │
│ ❱ 719 │   │   │   mpd.periods[0]                                                                 │
│   720 │   │   │   .adaptation_sets[0]                                                            │
│   721 │   │   │   .representations[0]                                                            │
│   722 │   │   │   .segment_templates[0]                                                          │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │     mpd = <mpegdash.nodes.MPEGDASH object at 0x000002E006249110>                             │ │
│ │ mpd_xml = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><MPD                                    │ │
│ │           xmlns="urn:mpeg:dash:schema:mpd:2011"'+1497                                        │ │
│ │    self = <tidalapi.media.DashInfo object at 0x000002E006249B90>                             │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidal_dl_ng\cli.py:197  │
│ in download                                                                                      │
│                                                                                                  │
│   194 │   │   │   if media_type in [MediaType.TRACK, MediaType.VIDEO]:                           │
│   195 │   │   │   │   download_delay: bool = bool(settings.data.download_delay and urls.index(   │
│   196 │   │   │   │                                                                              │
│ ❱ 197 │   │   │   │   dl.item(                                                                   │
│   198 │   │   │   │   │   media_id=item_id, media_type=media_type, file_template=file_template   │
│   199 │   │   │   │   )                                                                          │
│   200 │   │   │   elif media_type in [MediaType.ALBUM, MediaType.PLAYLIST, MediaType.MIX, Medi   │
│                                                                                                  │
│ ╭───────────────────────────────────────── locals ─────────────────────────────────────────╮     │
│ │            ctx = <click.core.Context object at 0x000002E0061F25D0>                       │     │
│ │             dl = <tidal_dl_ng.download.Download object at 0x000002E006678450>            │     │
│ │ download_delay = False                                                                   │     │
│ │  file_template = 'Tracks/{artist_name} - {track_title}{track_explicit}'                  │     │
│ │      file_urls = None                                                                    │     │
│ │      fn_logger = <tidal_dl_ng.helper.wrapper.LoggerWrapped object at 0x000002E006678410> │     │
│ │           item = 'https://tidal.com/browse/track/51332556?u'                             │     │
│ │        item_id = '51332556'                                                              │     │
│ │     media_type = <MediaType.TRACK: 'track'>                                              │     │
│ │       progress = <rich.progress.Progress object at 0x000002E006248F50>                   │     │
│ │ progress_table = <rich.table.Table object at 0x000002E006678490>                         │     │
│ │       settings = <tidal_dl_ng.config.Settings object at 0x000002E00625F950>              │     │
│ │           urls = ['https://tidal.com/browse/track/51332556?u']                           │     │
│ │  urls_pos_last = 0                                                                       │     │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯     │
│                                                                                                  │
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidal_dl_ng\download.py │
│ :221 in item                                                                                     │
│                                                                                                  │
│   218 │   │   │   if quality_audio:                                                              │
│   219 │   │   │   │   quality_audio_old: Quality = self.adjust_quality_audio(quality_audio)      │
│   220 │   │   │                                                                                  │
│ ❱ 221 │   │   │   file_extension = media.get_stream().get_stream_manifest().file_extension       │
│   222 │   │   │   # Use M4A extension for MP4 audio tracks, because it looks better and is com   │
│   223 │   │   │   file_extension = AudioExtensions.M4A if file_extension == AudioExtensions.MP   │
│   224                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────── locals ────────────────────────────────────╮                │
│ │ download_delay = False                                                        │                │
│ │  file_template = 'Tracks/{artist_name} - {track_title}{track_explicit}'       │                │
│ │          media = <tidalapi.media.Track object at 0x000002E0066786D0>          │                │
│ │       media_id = '51332556'                                                   │                │
│ │     media_type = <MediaType.TRACK: 'track'>                                   │                │
│ │  quality_audio = None                                                         │                │
│ │  quality_video = None                                                         │                │
│ │           self = <tidal_dl_ng.download.Download object at 0x000002E006678450> │                │
│ │ video_download = True                                                         │                │
│ ╰───────────────────────────────────────────────────────────────────────────────╯                │
│                                                                                                  │
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidalapi\media.py:518   │
│ in get_stream_manifest                                                                           │
│                                                                                                  │
│   515 │   │   return self.bit_depth, self.sample_rate                                            │
│   516 │                                                                                          │
│   517 │   def get_stream_manifest(self) -> "StreamManifest":                                     │
│ ❱ 518 │   │   return StreamManifest(self)                                                        │
│   519 │                                                                                          │
│   520 │   def get_manifest_data(self) -> str:                                                    │
│   521 │   │   try:                                                                               │
│                                                                                                  │
│ ╭────────────────────────── locals ───────────────────────────╮                                  │
│ │ self = <tidalapi.media.Stream object at 0x000002E006695A10> │                                  │
│ ╰─────────────────────────────────────────────────────────────╯                                  │
│                                                                                                  │
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidalapi\media.py:556   │
│ in __init__                                                                                      │
│                                                                                                  │
│   553 │   │   self.manifest_mime_type = stream.manifest_mime_type                                │
│   554 │   │   if stream.is_MPD:                                                                  │
│   555 │   │   │   # See https://ottverse.com/structure-of-an-mpeg-dash-mpd/ for more details     │
│ ❱ 556 │   │   │   self.dash_info = DashInfo.from_mpd(stream.get_manifest_data())                 │
│   557 │   │   │   self.urls = self.dash_info.urls                                                │
│   558 │   │   │   self.codecs = self.dash_info.codecs                                            │
│   559 │   │   │   self.mime_type = self.dash_info.mime_type                                      │
│                                                                                                  │
│ ╭─────────────────────────────── locals ────────────────────────────────╮                        │
│ │   self = <tidalapi.media.StreamManifest object at 0x000002E0062D8CD0> │                        │
│ │ stream = <tidalapi.media.Stream object at 0x000002E006695A10>         │                        │
│ ╰───────────────────────────────────────────────────────────────────────╯                        │
│                                                                                                  │
│ C:\Users\kopis\AppData\Local\Programs\Python\Python311\Lib\site-packages\tidalapi\media.py:672   │
│ in from_mpd                                                                                      │
│                                                                                                  │
│   669 │   │   try:                                                                               │
│   670 │   │   │   return DashInfo(mpd_manifest)                                                  │
│   671 │   │   except:                                                                            │
│ ❱ 672 │   │   │   raise ManifestDecodeError                                                      │
│   673 │                                                                                          │
│   674 │   def __init__(self, mpd_xml):                                                           │
│   675 │   │   mpd = MPEGDASHParser.parse(                                                        │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ mpd_manifest = '<?xml version=\'1.0\' encoding=\'UTF-8\'?><MPD                               │ │
│ │                xmlns="urn:mpeg:dash:schema:mpd:2011"'+1497                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Your settings

{"skip_existing": "exact", "lyrics_embed": false, "lyrics_file": true, "video_download": false, "download_delay": false, "download_base_path": "D:\\Musik", "quality_audio": "HI_RES_LOSSLESS", "quality_video": "360", "format_album": "{album_title}{album_explicit} - {album_artist}/{album_track_num} - {track_title}", "format_playlist": "Playlists/{playlist_name}/{artist_name} - {track_title}", "format_mix": "Mix/{mix_name}/{artist_name} - {track_title}", "format_track": "Tracks/{artist_name} - {track_title}{track_explicit}", "format_video": "Videos/{artist_name} - {track_title}{track_explicit}", "video_convert_mp4": false, "path_binary_ffmpeg": "C:\\Users\\user\\AppData\\Local\\Microsoft\\WinGet\\Links\\ffmpeg.exe", "metadata_cover_dimension": "1280", "extract_flac": true, "downgrade_on_hi_res": false}
romner-set commented 1 month ago

I can reproduce the error on linux with the linked track, I'm also getting the same error trying to download https://listen.tidal.com/album/281047811, song #7