nathom / streamrip

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

[BUG] Tracks of a multi-disc release are not sorted into folders #575

Open jieweix opened 6 months ago

jieweix commented 6 months ago

Describe the bug

Downloaded tracks of a multi-disc release are not sorted into folders, instead all in the same folder, resulting in multiple files with names that begin with, for example, 1., which is quite confusing.

Command Used

rip --verbose -f Music --no-db url https://play.qobuz.com/album/ol8naqv1590qa

Debug Traceback

➜  ~ rip --verbose -f Music --no-db url https://play.qobuz.com/album/ol8naqv1590qa
[21:38:19] DEBUG    Showing all debug logs                                                                                                         cli.py:100
           DEBUG    Raw request signature:                                                                                                       qobuz.py:414
                    trackgetFileUrlformat_id27intentstreamtrack_id195125741705527499.1101110b251c286cfbf64d6b7105f253d9a2e                                   
           DEBUG    Hashed request signature: 1a1db9b083b99e6b27f77223c5d97b64                                                                   qobuz.py:416
           DEBUG    api_request: endpoint=track/getFileUrl, params={'request_ts': 1705527499.11011, 'request_sig':                               qobuz.py:431
                    '1a1db9b083b99e6b27f77223c5d97b64', 'track_id': '19512574', 'format_id': 27, 'intent': 'stream'}                                         
           DEBUG    Raw request signature:                                                                                                       qobuz.py:414
                    trackgetFileUrlformat_id27intentstreamtrack_id195125741705527499.1176887979549437fcc4a3faad4867b5cd25dcb                                 
           DEBUG    Hashed request signature: 3899a53627ef860eed5a421128ad683a                                                                   qobuz.py:416
           DEBUG    api_request: endpoint=track/getFileUrl, params={'request_ts': 1705527499.1176887, 'request_sig':                             qobuz.py:431
                    '3899a53627ef860eed5a421128ad683a', 'track_id': '19512574', 'format_id': 27, 'intent': 'stream'}                                         
⠋ Logging into qobuz           DEBUG    Request params {'user_id': 'hidden_userid', 'user_auth_token':                                                                      qobuz.py:181
                    'hidden_token', 'app_id': '950096963'}                         
           DEBUG    api_request: endpoint=user/login, params={'user_id': 'hidden_userid', 'user_auth_token':                                            qobuz.py:431
                    'hidden_token', 'app_id': '950096963'}                         
⠙ Logging into qobuz           DEBUG    Login resp: {'user': {'id': hidden_userid, 'publicId': 'qobuz:user:iz240AoBs2Khv', 'email': 'hidden_email_address', 'login':            qobuz.py:183
                    'hidden_email_address', 'firstname': None, 'lastname': None, 'display_name': 'Ornithorink', 'country_code': 'FR',                            
                    'language_code': 'fr', 'zone': 'FR', 'store': 'FR-fr', 'country': 'FR', 'avatar':                                                        
                    'https://www.gravatar.com/avatar/0bb9554645ce0489344d4e5aa045960f?s=50&d=mm', 'genre': 'male', 'age': 53, 'creation_date':               
                    '2019-01-13', 'subscription': {'offer': 'studio', 'periodicity': 'annual', 'start_date': '2021-12-12', 'end_date':                       
                    '2024-12-11', 'is_canceled': False, 'household_size_max': 2}, 'credential': {'id': 1272158, 'label': 'streaming-studio',                 
                    'description': 'Abonné Qobuz Studio', 'parameters': {'lossy_streaming': True, 'lossless_streaming': True, 'hires_streaming':             
                    True, 'hires_purchases_streaming': True, 'mobile_streaming': True, 'offline_streaming': True, 'hfp_purchase': False,                     
                    'included_format_group_ids': [1, 2, 3, 4], 'color_scheme': {'logo': '#B8D729'}, 'label': 'Qobuz Studio', 'short_label':                  
                    'Studio', 'source': 'subscription'}}, 'last_update': {'favorite': 1705053621, 'favorite_album': 1699368834,                              
                    'favorite_artist': 1705053621, 'favorite_track': 1702202874, 'playlist': 1703856944, 'purchase': 1639328209},                            
                    'store_features': {'download': True, 'streaming': True, 'editorial': True, 'club': False, 'wallet': True, 'weeklyq': True,               
                    'autoplay': True, 'inapp_purchase_subscripton': True, 'opt_in': True, 'music_import': True, 'radio': True},                              
                    'player_settings': [], 'externals': {}}, 'user_auth_token':                                                                              
                    'hidden_token'}                                                
           DEBUG    Logged in to Qobuz                                                                                                           qobuz.py:190
           DEBUG    request params: {'app_id': '950096963', 'album_id': 'ol8naqv1590qa', 'limit': 500, 'offset': 0}                              qobuz.py:222
           DEBUG    api_request: endpoint=album/get, params={'app_id': '950096963', 'album_id': 'ol8naqv1590qa', 'limit': 500, 'offset': 0}      qobuz.py:431
⠙ Resolving URLs...           DEBUG    Pending tracks: [PendingTrack(id=175689128, album=AlbumMetadata(info=AlbumInfo(id='175689127', quality=3, container='FLAC',   album.py:84
                    label='Kairos', explicit=False, sampling_rate=96, bit_depth=24, booklets=[{'id': 152674, 'file_format_id': 21, 'name':                   
                    'Livret Numérique', 'description': 'Alfonso Gomez - Morton Feldman: Late Works for Piano', 'url':                                        
                    'https://static.qobuz.com/goodies/47/000152674.pdf', 'original_url': 'https://static.qobuz.com/goodies/47/000152674.pdf'}]),             
                    album='Morton Feldman: Late Works for Piano', albumartist='Alfonso Gomez', year='2021', genre=['Classique'],                             
                    covers=Covers(('original', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_org.jpg', 'Music/Morton Feldman Late              
                    Works for Piano (Alfonso Gomez)/cover.jpg')                                                                                              
                    ('large', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_600.jpg', 'Music/Morton Feldman Late Works for Piano               
                    (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg')                                                                                
                    ('small', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_230.jpg', None)                                                    
                    ('thumbnail', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_50.jpg', None)), tracktotal=3, disctotal=3,                    
                    albumcomposer='Morton Feldman', comment=None, compilation=None, copyright='2021 HNE Rights GmbH 2021 KAIROS',                            
                    date='2021-12-01', description=None, encoder=None, grouping=None, lyrics=None, purchase_date=None),                                      
                    client=<streamrip.client.qobuz.QobuzClient object at 0x7f282db79f10>, config=<streamrip.config.Config object at                          
                    0x7f282dd11350>, folder='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)',                                                     
                    db=Database(downloads=<streamrip.db.Dummy object at 0x7f282daff550>, failed=<streamrip.db.Failed object at 0x7f282daff410>),             
                    cover_path='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg'),                         
                    PendingTrack(id=175689129, album=AlbumMetadata(info=AlbumInfo(id='175689127', quality=3, container='FLAC', label='Kairos',               
                    explicit=False, sampling_rate=96, bit_depth=24, booklets=[{'id': 152674, 'file_format_id': 21, 'name': 'Livret Numérique',               
                    'description': 'Alfonso Gomez - Morton Feldman: Late Works for Piano', 'url':                                                            
                    'https://static.qobuz.com/goodies/47/000152674.pdf', 'original_url': 'https://static.qobuz.com/goodies/47/000152674.pdf'}]),             
                    album='Morton Feldman: Late Works for Piano', albumartist='Alfonso Gomez', year='2021', genre=['Classique'],                             
                    covers=Covers(('original', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_org.jpg', 'Music/Morton Feldman Late              
                    Works for Piano (Alfonso Gomez)/cover.jpg')                                                                                              
                    ('large', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_600.jpg', 'Music/Morton Feldman Late Works for Piano               
                    (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg')                                                                                
                    ('small', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_230.jpg', None)                                                    
                    ('thumbnail', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_50.jpg', None)), tracktotal=3, disctotal=3,                    
                    albumcomposer='Morton Feldman', comment=None, compilation=None, copyright='2021 HNE Rights GmbH 2021 KAIROS',                            
                    date='2021-12-01', description=None, encoder=None, grouping=None, lyrics=None, purchase_date=None),                                      
                    client=<streamrip.client.qobuz.QobuzClient object at 0x7f282db79f10>, config=<streamrip.config.Config object at                          
                    0x7f282dd11350>, folder='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)',                                                     
                    db=Database(downloads=<streamrip.db.Dummy object at 0x7f282daff550>, failed=<streamrip.db.Failed object at 0x7f282daff410>),             
                    cover_path='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg'),                         
                    PendingTrack(id=175689130, album=AlbumMetadata(info=AlbumInfo(id='175689127', quality=3, container='FLAC', label='Kairos',               
                    explicit=False, sampling_rate=96, bit_depth=24, booklets=[{'id': 152674, 'file_format_id': 21, 'name': 'Livret Numérique',               
                    'description': 'Alfonso Gomez - Morton Feldman: Late Works for Piano', 'url':                                                            
                    'https://static.qobuz.com/goodies/47/000152674.pdf', 'original_url': 'https://static.qobuz.com/goodies/47/000152674.pdf'}]),             
                    album='Morton Feldman: Late Works for Piano', albumartist='Alfonso Gomez', year='2021', genre=['Classique'],                             
                    covers=Covers(('original', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_org.jpg', 'Music/Morton Feldman Late              
                    Works for Piano (Alfonso Gomez)/cover.jpg')                                                                                              
                    ('large', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_600.jpg', 'Music/Morton Feldman Late Works for Piano               
                    (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg')                                                                                
                    ('small', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_230.jpg', None)                                                    
                    ('thumbnail', 'https://static.qobuz.com/images/covers/qa/90/ol8naqv1590qa_50.jpg', None)), tracktotal=3, disctotal=3,                    
                    albumcomposer='Morton Feldman', comment=None, compilation=None, copyright='2021 HNE Rights GmbH 2021 KAIROS',                            
                    date='2021-12-01', description=None, encoder=None, grouping=None, lyrics=None, purchase_date=None),                                      
                    client=<streamrip.client.qobuz.QobuzClient object at 0x7f282db79f10>, config=<streamrip.config.Config object at                          
                    0x7f282dd11350>, folder='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)',                                                     
                    db=Database(downloads=<streamrip.db.Dummy object at 0x7f282daff550>, failed=<streamrip.db.Failed object at 0x7f282daff410>),             
                    cover_path='Music/Morton Feldman Late Works for Piano (Alfonso Gomez)/__artwork/cover-1377645805102132150.jpg')]                         
           DEBUG    request params: {'app_id': '950096963', 'track_id': 175689128, 'limit': 500, 'offset': 0}                                    qobuz.py:222
           DEBUG    api_request: endpoint=track/get, params={'app_id': '950096963', 'track_id': 175689128, 'limit': 500, 'offset': 0}            qobuz.py:431
           DEBUG    request params: {'app_id': '950096963', 'track_id': 175689129, 'limit': 500, 'offset': 0}                                    qobuz.py:222
           DEBUG    api_request: endpoint=track/get, params={'app_id': '950096963', 'track_id': 175689129, 'limit': 500, 'offset': 0}            qobuz.py:431
           DEBUG    request params: {'app_id': '950096963', 'track_id': 175689130, 'limit': 500, 'offset': 0}                                    qobuz.py:222
           DEBUG    api_request: endpoint=track/get, params={'app_id': '950096963', 'track_id': 175689130, 'limit': 500, 'offset': 0}            qobuz.py:431
           DEBUG    Raw request signature:                                                                                                       qobuz.py:414
                    trackgetFileUrlformat_id27intentstreamtrack_id1756891281705527499.6336083979549437fcc4a3faad4867b5cd25dcb                                
           DEBUG    Hashed request signature: 07e5de5b93e394455d07751c323de45b                                                                   qobuz.py:416
           DEBUG    api_request: endpoint=track/getFileUrl, params={'request_ts': 1705527499.6336083, 'request_sig':                             qobuz.py:431
                    '07e5de5b93e394455d07751c323de45b', 'track_id': 175689128, 'format_id': 27, 'intent': 'stream'}                                          
           DEBUG    Raw request signature:                                                                                                       qobuz.py:414
                    trackgetFileUrlformat_id27intentstreamtrack_id1756891301705527499.7132125979549437fcc4a3faad4867b5cd25dcb                                
           DEBUG    Hashed request signature: 63ff5ef7f63379fcf8197b691ac7a3eb                                                                   qobuz.py:416
           DEBUG    api_request: endpoint=track/getFileUrl, params={'request_ts': 1705527499.7132125, 'request_sig':                             qobuz.py:431
                    '63ff5ef7f63379fcf8197b691ac7a3eb', 'track_id': 175689130, 'format_id': 27, 'intent': 'stream'}                                          
           DEBUG    Raw request signature:                                                                                                       qobuz.py:414
                    trackgetFileUrlformat_id27intentstreamtrack_id1756891291705527499.7189806979549437fcc4a3faad4867b5cd25dcb                                
           DEBUG    Hashed request signature: 822a7672703f6fe948843261714bfbbb                                                                   qobuz.py:416
           DEBUG    api_request: endpoint=track/getFileUrl, params={'request_ts': 1705527499.7189806, 'request_sig':                             qobuz.py:431
                    '822a7672703f6fe948843261714bfbbb', 'track_id': 175689129, 'format_id': 27, 'intent': 'stream'}                                          
[21:39:01] DEBUG    Tagging with [('TITLE', 'Palais de Mari (1986)'), ('ARTIST', 'Alfonso Gomez'), ('ALBUM', 'Morton Feldman: Late Works for    tagger.py:253
                    Piano'), ('ALBUMARTIST', 'Alfonso Gomez'), ('COMPOSER', 'Morton Feldman'), ('YEAR', '2021'), ('GENRE', 'Classique'),                     
                    ('COPYRIGHT', '2021 HNE Rights GmbH 2021 KAIROS'), ('TRACKNUMBER', '01'), ('DISCNUMBER', '02'), ('TRACKTOTAL', '03'),                    
                    ('DISCTOTAL', '03'), ('DATE', '2021-12-01'), ('ISRC', 'ATK941510602')]                                                                   
[21:39:56] DEBUG    Tagging with [('TITLE', 'For Bunita Marcus (1985)'), ('ARTIST', 'Alfonso Gomez'), ('ALBUM', 'Morton Feldman: Late Works for tagger.py:253
                    Piano'), ('ALBUMARTIST', 'Alfonso Gomez'), ('COMPOSER', 'Morton Feldman'), ('YEAR', '2021'), ('GENRE', 'Classique'),                     
                    ('COPYRIGHT', '2021 HNE Rights GmbH 2021 KAIROS'), ('TRACKNUMBER', '01'), ('DISCNUMBER', '01'), ('TRACKTOTAL', '03'),                    
                    ('DISCTOTAL', '03'), ('DATE', '2021-12-01'), ('ISRC', 'ATK941510601')]                                                                   
[21:40:06] DEBUG    Tagging with [('TITLE', 'Triadic Memories (1981)'), ('ARTIST', 'Alfonso Gomez'), ('ALBUM', 'Morton Feldman: Late Works for  tagger.py:253
                    Piano'), ('ALBUMARTIST', 'Alfonso Gomez'), ('COMPOSER', 'Morton Feldman'), ('YEAR', '2021'), ('GENRE', 'Classique'),                     
                    ('COPYRIGHT', '2021 HNE Rights GmbH 2021 KAIROS'), ('TRACKNUMBER', '01'), ('DISCNUMBER', '03'), ('TRACKTOTAL', '03'),                    
                    ('DISCTOTAL', '03'), ('DATE', '2021-12-01'), ('ISRC', 'ATK941510603')]                                                                   
───────────────────────────────────────────────────── Downloading Morton Feldman: Late Works for Piano ──────────────────────────────────────────────────────
[21:40:08] DEBUG    Removing dirs {'Music/Morton Feldman Late Works for Piano (Alfonso Gomez)/__artwork'}

Config File

Default, except account credentials and quality settings

Operating System

Arch Linux with kernel 6.7.0

streamrip version

2.0.2

Screenshots and recordings

No response

Additional context

It would also be helpful to provide discnumber as an available key for track formatting, so that, although in the same folders, the filename of disc 1 track 1 would begin with 1.01 and the filename of disc 2 track 3 would begin with 2.03, etc.

naiches commented 5 months ago

+1

bidsalon commented 4 months ago

Please support "Part" & "Part/Total" metadata, thank you.

A sample output from the linux command "mediainfo",

This is Disc 3,

Track name/Position : 01 Part : 03 Part/Total : 06

This is Disc 4,

Track name/Position : 01 Part : 04 Part/Total : 06

BJReplay commented 1 month ago

Adding to this, an option to support {discnumber} and {disctotal} would be great - for example

# Available keys: "albumartist", "title", "year", "bit_depth", "sampling_rate",
# "id", "discnumber", "disctotal" and "albumcomposer"
folder_format = "{albumartist}/{title}[ Disc {discnumber} of {disctotal}]"

CueRipper supports a great variable - see http://cue.tools/wiki/CUETools_Templates %discnumberandname% when %disctotal% > 1 is replaced by [%discnumber%] of %disctotal%[ - %discname%], else undefined.

`%discnumberandname% is the neatest way of including a conditionally null variable that is excluded by [square brackets] when empty for multi-disk albums

mortalis13 commented 1 month ago

With the default configuration I have folders "Disc 1", "Disc 2" and "Disc 3". Maybe the older version didn't do that but the latest one does. And I'd say the config file has to be posted, "default" can mean different thing for different versions. I suppose the disc_subdirectories option controls this behaviour.