@@ -65,7 +65,8 @@ def delete_album_art():
6565 phfp = None
6666 else :
6767 raise Exception (
68- "ERROR: Invalid value {config['album_art_placeholder']} for `album_art_placeholder` option"
68+ f"ERROR: Invalid value { config ['album_art_placeholder' ]} "
69+ "for `album_art_placeholder` option"
6970 )
7071 if phfp :
7172 shutil .copy (phfp , artfp )
@@ -285,15 +286,22 @@ def update_metadata(player, metadata, manager):
285286 get_new_lyrics (artist , title )
286287 logger .debug ("Returning" )
287288
289+
288290def get_new_lyrics (artist , title ):
291+ def finalize ():
292+ global lyrics
293+ lyrics ["secs" ] = np .array (lyrics ["secs" ])
294+ lyrics ["max_len" ] = max ([len (x ) for x in lyrics ["text" ]])
289295 global lyrics
290- lyrics = {"secs" : np . array ( [0 ]) , "text" : ["[INTRO]" ], "last_ix" : - 1 }
296+ lyrics = {"secs" : [0 ], "text" : ["[INTRO]" ], "last_ix" : - 1 }
291297 lt = syncedlyrics .search (
292298 f"{ artist } { title } " ,
293299 allow_plain_format = False ,
294- providers = config ["lyrics_providers" ]
300+ providers = config ["lyrics_providers" ],
295301 )
296302 if lt is None :
303+ logger .debug ("No lyrics, returning" )
304+ finalize ()
297305 return
298306 lt = lt .split ("\n " )
299307 for i , line in enumerate (lt ):
@@ -305,13 +313,14 @@ def get_new_lyrics(artist, title):
305313 text = m .group (2 ).strip ()
306314 if text == "" :
307315 text = "[INTERMISSION]"
308- np . append ( lyrics ["secs" ], [ secs ] )
316+ lyrics ["secs" ]. append ( secs )
309317 lyrics ["text" ].append (text )
310318 # DEBUG
311- # print (i, line, "->", "[" + str(secs) + "] ", text)
319+ logger . debug (i , line , "->" , "[" + str (secs ) + "] " , text )
312320 lyrics ["text" ].append ("[OUTRO]" )
313- np .append (lyrics ["secs" ], [lyrics ["secs" ][- 1 ]+ 1 ])
314- lyrics ["max_len" ] = max ([len (x ) for x in lyrics ["text" ]])
321+ lyrics ["secs" ].append (lyrics ["secs" ][- 1 ] + 1 )
322+ finalize ()
323+
315324
316325def left_text (s ):
317326 le = len (s )
@@ -363,7 +372,7 @@ def update_progressbar(manager, player):
363372 # with the "mpris:length" key.
364373 # The length must be given in microseconds,
365374 # and be represented as a signed 64-bit integer
366- # see: https://specifications.freedesktop.org/mpris-spec/2.2/Track_List_Interface.html
375+ # see: https://specifications.freedesktop.org/mpris-spec/2.2/Track_List_Interface.html # noqa: E501
367376 length = int (pmetadata ["mpris:length" ])
368377 except KeyError :
369378 logger .debug (
@@ -429,7 +438,7 @@ def update_progressbar(manager, player):
429438 curr_line = None
430439 if lyrics :
431440 ll = lyrics .get ("max_len" , 3 )
432- s .append ("-" * ll )
441+ s .append ("-" * ll )
433442
434443 # DEBUG
435444 # print(f"lyrics['secs']={lyrics['secs']}")
0 commit comments