aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/subliminal_patch/providers/yifysubtitles.py
diff options
context:
space:
mode:
Diffstat (limited to 'libs/subliminal_patch/providers/yifysubtitles.py')
-rw-r--r--libs/subliminal_patch/providers/yifysubtitles.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/libs/subliminal_patch/providers/yifysubtitles.py b/libs/subliminal_patch/providers/yifysubtitles.py
index 59d683577..e41dc6c69 100644
--- a/libs/subliminal_patch/providers/yifysubtitles.py
+++ b/libs/subliminal_patch/providers/yifysubtitles.py
@@ -95,7 +95,7 @@ class YifySubtitlesProvider(Provider):
]
languages = {Language(l, c) for (_, l, c) in YifyLanguages}
- server_url = 'https://www.yifysubtitles.com'
+ server_urls = ['https://yifysubtitles.org', 'https://www.yifysubtitles.com']
video_types = (Movie,)
def initialize(self):
@@ -112,20 +112,20 @@ class YifySubtitlesProvider(Provider):
def terminate(self):
self.session.close()
- def _parse_row(self, row, languages):
+ def _parse_row(self, row, languages, server_url):
td = row.findAll('td')
rating = int(td[0].text)
sub_lang = td[1].text
release = re.sub(r'^subtitle ', '', td[2].text)
sub_link = td[2].find('a').get('href')
- sub_link = re.sub(r'^/subtitles/', self.server_url + '/subtitle/', sub_link) + '.zip'
+ page_link = server_url + sub_link
+ sub_link = re.sub(r'^/subtitles/', server_url + '/subtitle/', sub_link) + '.zip'
hi = True if td[3].find('span', {'class': 'hi-subtitle'}) else False
uploader = td[4].text
- page_link = self.server_url + td[5].find('a').get('href')
_, l, c = next(x for x in self.YifyLanguages if x[0] == sub_lang)
lang = Language(l, c)
- if languages & set([lang]):
+ if languages & {lang}:
return [YifySubtitle(lang, page_link, release, uploader, sub_link, rating, hi)]
return []
@@ -134,9 +134,13 @@ class YifySubtitlesProvider(Provider):
subtitles = []
logger.info('Searching subtitle %r', imdb_id)
- response = self.session.get(self.server_url + '/movie-imdb/' + imdb_id,
- allow_redirects=False, timeout=10,
- headers={'Referer': self.server_url})
+ for server_url in self.server_urls:
+ response = self.session.get(server_url + '/movie-imdb/' + imdb_id,
+ allow_redirects=False, timeout=10,
+ headers={'Referer': server_url})
+ if response.status_code == 200:
+ break
+
response.raise_for_status()
if response.status_code != 200:
@@ -150,7 +154,7 @@ class YifySubtitlesProvider(Provider):
for row in rows:
try:
- subtitles = subtitles + self._parse_row(row, languages)
+ subtitles = subtitles + self._parse_row(row, languages, server_url)
except Exception as e:
pass