30
30
import coloredlogs .converter
31
31
from rich .progress import Progress
32
32
from tidalapi import Album , Mix , Playlist , Quality , Track , UserPlaylist , Video
33
+ from tidalapi .artist import Artist
33
34
from tidalapi .session import SearchTypes
34
35
35
36
from tidal_dl_ng .config import Settings , Tidal
@@ -178,10 +179,10 @@ def _populate_quality(self, ui_target: QtWidgets.QComboBox, options: type[Qualit
178
179
179
180
def _populate_search_types (self , ui_target : QtWidgets .QComboBox , options : SearchTypes ):
180
181
for item in options :
181
- if item and item . __name__ != "Artist" :
182
+ if item :
182
183
ui_target .addItem (item .__name__ , item )
183
184
184
- self .cb_search_type .setCurrentIndex (1 )
185
+ self .cb_search_type .setCurrentIndex (2 )
185
186
186
187
def _init_tree_results (self , tree : QtWidgets .QTableWidget ):
187
188
tree .setColumnHidden (5 , True )
@@ -321,10 +322,14 @@ def populate_tree_results(self, results: [ResultItem], parent: QtWidgets.QTreeWi
321
322
self .s_tr_results_add_top_level_item .emit (child )
322
323
323
324
def populate_tree_result_child (self , item : [Track | Video | Mix | Album | Playlist ], index_count_digits : int ):
325
+ duration : str = ""
326
+
324
327
# TODO: Duration needs to be calculated later to properly fill with zeros.
325
- # Format seconds to mm:ss.
326
- m , s = divmod (item .duration_sec , 60 )
327
- duration : str = f"{ m :02d} :{ s :02d} "
328
+ if item .duration_sec > - 1 :
329
+ # Format seconds to mm:ss.
330
+ m , s = divmod (item .duration_sec , 60 )
331
+ duration : str = f"{ m :02d} :{ s :02d} "
332
+
328
333
# Since sorting happens only by string, we need to pad the index and add 1 (to avoid start at 0)
329
334
index : str = str (item .position + 1 ).zfill (index_count_digits )
330
335
@@ -337,7 +342,7 @@ def populate_tree_result_child(self, item: [Track | Video | Mix | Album | Playli
337
342
child .setText (4 , duration )
338
343
child .setData (5 , QtCore .Qt .ItemDataRole .UserRole , item .obj )
339
344
340
- if isinstance (item .obj , Mix | Playlist | Album ):
345
+ if isinstance (item .obj , Mix | Playlist | Album | Artist ):
341
346
# Add a disabled dummy child, so expansion arrow will appear. This Child will be replaced on expansion.
342
347
child_dummy : QtWidgets .QTreeWidgetItem = QtWidgets .QTreeWidgetItem ()
343
348
@@ -442,6 +447,17 @@ def search_result_to_model(self, items: [*SearchTypes]) -> [ResultItem]:
442
447
obj = item ,
443
448
)
444
449
450
+ result .append (result_item )
451
+ elif isinstance (item , Artist ):
452
+ result_item : ResultItem = ResultItem (
453
+ position = idx ,
454
+ artist = item .name ,
455
+ title = "" ,
456
+ album = "" ,
457
+ duration_sec = - 1 ,
458
+ obj = item ,
459
+ )
460
+
445
461
result .append (result_item )
446
462
447
463
return result
@@ -521,7 +537,7 @@ def on_list_items_show(self, item: QtWidgets.QTreeWidgetItem):
521
537
522
538
def list_items_show_result (
523
539
self ,
524
- media_list : Album | Playlist | Mix | None = None ,
540
+ media_list : Album | Playlist | Mix | Artist | None = None ,
525
541
point : QtCore .QPoint | None = None ,
526
542
parent : QtWidgets .QTreeWidgetItem = None ,
527
543
) -> None :
@@ -530,7 +546,7 @@ def list_items_show_result(
530
546
media_list = item .data (3 , QtCore .Qt .ItemDataRole .UserRole )
531
547
532
548
# Get all results
533
- media_items : [Track | Video ] = items_results_all (media_list )
549
+ media_items : [Track | Video | Album ] = items_results_all (media_list )
534
550
result : [ResultItem ] = self .search_result_to_model (media_items )
535
551
536
552
self .populate_tree_results (result , parent = parent )
@@ -597,7 +613,7 @@ def on_tr_results_expanded(self, list_item: QtWidgets.QTreeWidgetItem) -> None:
597
613
598
614
if load_children :
599
615
list_item .removeChild (list_item .child (0 ))
600
- media_list : [Mix | Album | Playlist ] = list_item .data (5 , QtCore .Qt .ItemDataRole .UserRole )
616
+ media_list : [Mix | Album | Playlist | Artist ] = list_item .data (5 , QtCore .Qt .ItemDataRole .UserRole )
601
617
602
618
self .list_items_show_result (media_list = media_list , parent = list_item )
603
619
0 commit comments