summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2021-03-30 23:21:53 -0400
committermorpheus65535 <[email protected]>2021-03-30 23:21:53 -0400
commitb11d037d2ef3ada93b3280ad41421bb22003bab3 (patch)
treeecc38f083123b6bbc5b5d45e62d3759bb10ea58e
parentb6c7b18ce9c83222029eba0bb230bae2d483d5d0 (diff)
downloadbazarr-b11d037d2ef3ada93b3280ad41421bb22003bab3.tar.gz
bazarr-b11d037d2ef3ada93b3280ad41421bb22003bab3.zip
no log: Fine-tuning fix for tvsubtitles provider
-rw-r--r--libs/subliminal/providers/tvsubtitles.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/libs/subliminal/providers/tvsubtitles.py b/libs/subliminal/providers/tvsubtitles.py
index f11e2a476..a819d7ebc 100644
--- a/libs/subliminal/providers/tvsubtitles.py
+++ b/libs/subliminal/providers/tvsubtitles.py
@@ -220,13 +220,16 @@ class TVsubtitlesProvider(Provider):
r.raise_for_status()
# generate the download link from the sliced strings in the page source (js)
- download_link_part = re.findall(r'(?<=s\d\=\ \')(.*?)(?=\'\;)', r.text)
- r = self.session.get(self.server_url + ''.join(download_link_part), timeout=10)
- r.raise_for_status()
+ download_link_part = re.findall(r'(?<=s\d=\s\')(.*?)(?=\';\n)', r.text)
+ if len(download_link_part):
+ download = self.session.get(self.server_url + ''.join(download_link_part), timeout=10)
+ download.raise_for_status()
- # open the zip
- with ZipFile(io.BytesIO(r.content)) as zf:
- if len(zf.namelist()) > 1:
- raise ProviderError('More than one file to unzip')
+ # open the zip
+ with ZipFile(io.BytesIO(download.content)) as zf:
+ if len(zf.namelist()) > 1:
+ raise ProviderError('More than one file to unzip')
- subtitle.content = fix_line_ending(zf.read(zf.namelist()[0]))
+ subtitle.content = fix_line_ending(zf.read(zf.namelist()[0]))
+ else:
+ raise ProviderError('Cannot get download link')