Skip to content

Commit 70bd5d5

Browse files
authored
Fixed Assrt provider crash on empty filelist and CJK title matching failure
1 parent 3cc5f79 commit 70bd5d5

File tree

1 file changed

+17
-0
lines changed
  • custom_libs/subliminal_patch/providers

1 file changed

+17
-0
lines changed

custom_libs/subliminal_patch/providers/assrt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,23 @@ def id(self):
128128
@property
129129
def download_link(self):
130130
detail = self._get_detail()
131+
if not detail:
132+
return None
131133
return detail['url']
132134

133135
def get_matches(self, video):
134136
self.matches = guess_matches(video, guessit(self.video_name))
137+
# If matching fails for series, retry after stripping leading CJK characters.
138+
# Assrt often returns video names with Chinese titles prefixed to the English
139+
# release name (e.g. "瑞克和莫蒂.Rick.and.Morty.S07E10..."), which causes
140+
# guessit to produce a combined title that won't match the series name from
141+
# Sonarr/Radarr.
142+
if (isinstance(video, Episode) and self.video_name
143+
and not {"series", "season", "episode"}.issubset(self.matches)):
144+
cleaned = re.sub(r'^[\u4e00-\u9fff]+[.\s]+', '', self.video_name)
145+
if cleaned != self.video_name:
146+
fallback_matches = guess_matches(video, guessit(cleaned))
147+
self.matches |= fallback_matches
135148
return self.matches
136149

137150

@@ -230,6 +243,10 @@ def list_subtitles(self, video, languages):
230243
return self.query(languages, video)
231244

232245
def download_subtitle(self, subtitle):
246+
if not subtitle.download_link:
247+
logger.warning('No download link available for subtitle %s, skipping', subtitle.subtitle_id)
248+
subtitle.content = None
249+
return
233250
sleep(get_request_delay(self.max_request_per_minute))
234251
r = self.session.get(subtitle.download_link, timeout=15)
235252
check_status_code(r)

0 commit comments

Comments
 (0)