@@ -155,7 +155,7 @@ def __repr__(self) -> str:
155155 abs_string = (
156156 ''
157157 if self .absolute_number is None
158- else '_A ' + str (self .absolute_number )
158+ else '-A ' + str (self .absolute_number )
159159 )
160160
161161 return (
@@ -238,23 +238,41 @@ def __eq__(self, other: 'EpisodeInfo | PlexEpisode | object') -> bool:
238238 (self .tvdb_id , other .tvdb_id ),
239239 (self .tvrage_id , other .tvrage_id ),
240240 ]:
241+ # Interface ID comparison
241242 if (isinstance (this_id , InterfaceID )
242- and isinstance (other_id , InterfaceID )):
243+ and isinstance (other_id , InterfaceID )
244+ ):
245+ # If neither ID is actually defined, skip this
246+ if not this_id or not other_id :
247+ continue
243248 if this_id .equals (other_id ):
244249 id_matches += 1
250+ # Do not increment mismatch because interface IDs are
251+ # not strictly comparable
252+ continue
253+
254+ # Regular ID comparison - if this ID is defined and matches,
255+ # count it
245256 if this_id is not None and this_id == other_id :
246257 id_matches += 1
247- elif (this_id is not None and other_id is not None
248- and this_id != other_id ):
258+ # Both IDs are defined but do not match, count as mismatch
259+ elif (this_id is not None
260+ and other_id is not None
261+ and this_id != other_id
262+ ):
249263 id_mismatches += 1
250264
251- # More than one ID match is equality, more than one mismatch is
252- # an inequality
253- if id_matches > 1 :
254- return True
255- if (id_matches == 1
256- and self .season_number == other .season_number
257- and self .episode_number == other .episode_number ):
265+ # More than one ID match is an equality, one match and index
266+ # match is equality, and more than one ID mismatch is not a
267+ # match
268+ if (
269+ (id_matches > 1 and id_matches > id_mismatches )
270+ or (
271+ id_matches == 1
272+ and self .season_number == other .season_number
273+ and self .episode_number == other .episode_number
274+ )
275+ ):
258276 return True
259277 if id_mismatches > 1 :
260278 return False
0 commit comments