99
1010logging .basicConfig (level = logging .INFO )
1111
12+ def colorize_red (text : str ) -> str :
13+ """
14+ Add ANSI red color codes to text for terminal display.
15+ Returns the text wrapped in red color codes.
16+ """
17+ return f"\033 [31m{ text } \033 [0m"
18+
1219def search_musicbrainz_recording (artist : str , title : str , album : str = None ) -> str :
1320 """
1421 Query MusicBrainz for the recording MBID given artist, title, and optional album.
@@ -118,7 +125,7 @@ def build_lidarr_json(songs: List[Dict]) -> (List[Dict], List[Dict]):
118125 found .append ({"MusicBrainzId" : mbid })
119126 else :
120127 not_found .append (song )
121- logging .info (f"[{ idx } /{ len (songs )} ] { song ['artist' ]} - { song ['title' ]} => MBID: { mbid if mbid else 'NOT FOUND' } " )
128+ logging .info (f"[{ idx } /{ len (songs )} ] { song ['artist' ]} - { song ['title' ]} => MBID: { mbid if mbid else colorize_red ( 'NOT FOUND' ) } " )
122129 time .sleep (1 ) # MusicBrainz rate limit for anonymous requests
123130 return found , not_found
124131
@@ -135,7 +142,7 @@ def build_albums_json(albums: List[Dict]) -> (List[Dict], List[Dict]):
135142 found .append ({"MusicBrainzId" : mbid })
136143 else :
137144 not_found .append (album )
138- logging .info (f"[{ idx } /{ len (albums )} ] { album ['artist' ]} - { album ['album' ]} => MBID: { mbid if mbid else 'NOT FOUND' } " )
145+ logging .info (f"[{ idx } /{ len (albums )} ] { album ['artist' ]} - { album ['album' ]} => MBID: { mbid if mbid else colorize_red ( 'NOT FOUND' ) } " )
139146 time .sleep (1 ) # MusicBrainz rate limit for anonymous requests
140147 return found , not_found
141148
@@ -183,7 +190,7 @@ def recheck_not_found(output_json: str, not_found_json: str):
183190 logging .info (f"[{ idx } /{ len (not_found_items )} ] { song ['artist' ]} - { song ['title' ]} => MBID: { mbid } " )
184191 else :
185192 still_not_found .append (song )
186- logging .info (f"[{ idx } /{ len (not_found_items )} ] { song ['artist' ]} - { song ['title' ]} => STILL NOT FOUND" )
193+ logging .info (f"[{ idx } /{ len (not_found_items )} ] { song ['artist' ]} - { song ['title' ]} => { colorize_red ( ' STILL NOT FOUND' ) } " )
187194 time .sleep (1 ) # MusicBrainz rate limit for anonymous requests
188195
189196 # Append newly found MBIDs to existing output JSON
0 commit comments