@@ -41,17 +41,20 @@ def match_spotify_tracks_in_plex(
41
41
title = artist_name .replace ("'" , "" ),
42
42
)
43
43
if not artist_tracks_in_plex :
44
- logger .debug (f"No results found for artist: { artist_name } " )
45
- missing_tracks .append ((track_name , artist_name ))
46
- continue
44
+ artist_tracks_in_plex = music_library .search (
45
+ title = artist_name .replace ("'" , "" ),
46
+ )
47
+ if not artist_tracks_in_plex :
48
+ logger .debug (f"No results found for artist: { artist_name } " )
49
+ missing_tracks .append ((track_name , artist_name ))
50
+ continue
47
51
48
52
try :
49
- track_name_no_apostrophe = track_name .replace ("'" , "" )
50
53
plex_track = next (
51
54
(
52
- track .track (title = track_name_no_apostrophe )
55
+ track .track (title = track_name )
53
56
for track in artist_tracks_in_plex
54
- if track .track (title = track_name_no_apostrophe )
57
+ if track .track (title = track_name )
55
58
),
56
59
None ,
57
60
)
@@ -67,6 +70,26 @@ def match_spotify_tracks_in_plex(
67
70
plex_track = None
68
71
69
72
if not plex_track :
73
+ try :
74
+ track_name_no_apostrophe = track_name .replace ("'" , "" )
75
+ plex_track = next (
76
+ (
77
+ track .track (title = track_name_no_apostrophe )
78
+ for track in artist_tracks_in_plex
79
+ if track .track (title = track_name_no_apostrophe )
80
+ ),
81
+ None ,
82
+ )
83
+ except NotFound :
84
+ logger .debug (
85
+ f"Track '{ track_name } ' by '{ artist_name } ' not found in Plex." ,
86
+ )
87
+ plex_track = None
88
+ except (Exception , BadRequest ) as plex_search_exception :
89
+ logger .debug (
90
+ f"Exception trying to search for artist '{ artist_name } ', track '{ track_name } ': { plex_search_exception } " ,
91
+ )
92
+ plex_track = None
70
93
logger .debug ("Song not in Plex!" )
71
94
logger .debug (
72
95
f"Found artists for '{ artist_name } ' ({ len (artist_tracks_in_plex )} )" ,
0 commit comments