aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/subliminal_patch/providers
diff options
context:
space:
mode:
Diffstat (limited to 'libs/subliminal_patch/providers')
-rw-r--r--libs/subliminal_patch/providers/subdivx.py3
-rw-r--r--libs/subliminal_patch/providers/subssabbz.py30
-rw-r--r--libs/subliminal_patch/providers/subsunacs.py41
-rw-r--r--libs/subliminal_patch/providers/yavkanet.py30
-rw-r--r--libs/subliminal_patch/providers/yifysubtitles.py22
5 files changed, 76 insertions, 50 deletions
diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py
index 998460ff0..f144a4cdc 100644
--- a/libs/subliminal_patch/providers/subdivx.py
+++ b/libs/subliminal_patch/providers/subdivx.py
@@ -168,7 +168,8 @@ class SubdivxSubtitlesProvider(Provider):
download_link = self._get_download_link(subtitle)
# download zip / rar file with the subtitle
- response = self.session.get(download_link, headers={'Referer': subtitle.page_link}, timeout=30)
+ response = self.session.get(self.server_url + download_link, headers={'Referer': subtitle.page_link},
+ timeout=30)
self._check_response(response)
# open the compressed archive
diff --git a/libs/subliminal_patch/providers/subssabbz.py b/libs/subliminal_patch/providers/subssabbz.py
index 386e3c19f..960d36429 100644
--- a/libs/subliminal_patch/providers/subssabbz.py
+++ b/libs/subliminal_patch/providers/subssabbz.py
@@ -55,7 +55,12 @@ class SubsSabBzSubtitle(Subtitle):
self.video = video
self.fps = fps
self.num_cds = num_cds
- self.release_info = os.path.splitext(filename)[0]
+ self.release_info = filename
+ if fps:
+ if video.fps and float(video.fps) == fps:
+ self.release_info += " <b>[{:.3f}]</b>".format(fps)
+ else:
+ self.release_info += " [{:.3f}]".format(fps)
@property
def id(self):
@@ -168,7 +173,7 @@ class SubsSabBzProvider(Provider):
element = a_element_wrapper.find('a')
if element:
link = element.get('href')
- notes = element.get('onmouseover')
+ notes = re.sub(r'ddrivetip\(\'<div.*/></div>(.*)\',\'#[0-9]+\'\)', r'\1', element.get('onmouseover'))
title = element.get_text()
try:
@@ -248,12 +253,15 @@ class SubsSabBzProvider(Provider):
else:
logger.info('Cache file: %s', codecs.encode(cache_key, 'hex_codec').decode('utf-8'))
- archive_stream = io.BytesIO(request.content)
- if is_rarfile(archive_stream):
- return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps, num_cds)
- elif is_zipfile(archive_stream):
- return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps, num_cds)
- else:
- logger.error('Ignore unsupported archive %r', request.headers)
- region.delete(cache_key)
- return []
+ try:
+ archive_stream = io.BytesIO(request.content)
+ if is_rarfile(archive_stream):
+ return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps, num_cds)
+ elif is_zipfile(archive_stream):
+ return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps, num_cds)
+ except:
+ pass
+
+ logger.error('Ignore unsupported archive %r', request.headers)
+ region.delete(cache_key)
+ return []
diff --git a/libs/subliminal_patch/providers/subsunacs.py b/libs/subliminal_patch/providers/subsunacs.py
index 19c5eff86..137d2f7bf 100644
--- a/libs/subliminal_patch/providers/subsunacs.py
+++ b/libs/subliminal_patch/providers/subsunacs.py
@@ -55,7 +55,12 @@ class SubsUnacsSubtitle(Subtitle):
self.video = video
self.fps = fps
self.num_cds = num_cds
- self.release_info = os.path.splitext(filename)[0]
+ self.release_info = filename
+ if fps:
+ if video.fps and float(video.fps) == fps:
+ self.release_info += " <b>[{:.3f}]</b>".format(fps)
+ else:
+ self.release_info += " [{:.3f}]".format(fps)
@property
def id(self):
@@ -168,7 +173,7 @@ class SubsUnacsProvider(Provider):
element = a_element_wrapper.find('a', {'class': 'tooltip'})
if element:
link = element.get('href')
- notes = element.get('title')
+ notes = re.sub(r'(<img.*)(src=")(/)(.*.jpg">)', r"", element.get('title'))
title = element.get_text()
try:
@@ -230,11 +235,8 @@ class SubsUnacsProvider(Provider):
is_7zip = isinstance(archiveStream, SevenZipFile)
if is_7zip:
- try:
- file_content = archiveStream.readall()
- file_list = sorted(file_content)
- except:
- return []
+ file_content = archiveStream.readall()
+ file_list = sorted(file_content)
else:
file_list = sorted(archiveStream.namelist())
@@ -268,14 +270,17 @@ class SubsUnacsProvider(Provider):
else:
logger.info('Cache file: %s', codecs.encode(cache_key, 'hex_codec').decode('utf-8'))
- archive_stream = io.BytesIO(request.content)
- if is_rarfile(archive_stream):
- return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps, num_cds)
- elif is_zipfile(archive_stream):
- return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps, num_cds)
- elif archive_stream.seek(0) == 0 and is_7zfile(archive_stream):
- return self.process_archive_subtitle_files(SevenZipFile(archive_stream), language, video, link, fps, num_cds)
- else:
- logger.error('Ignore unsupported archive %r', request.headers)
- region.delete(cache_key)
- return []
+ try:
+ archive_stream = io.BytesIO(request.content)
+ if is_rarfile(archive_stream):
+ return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps, num_cds)
+ elif is_zipfile(archive_stream):
+ return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps, num_cds)
+ elif archive_stream.seek(0) == 0 and is_7zfile(archive_stream):
+ return self.process_archive_subtitle_files(SevenZipFile(archive_stream), language, video, link, fps, num_cds)
+ except:
+ pass
+
+ logger.error('Ignore unsupported archive %r', request.headers)
+ region.delete(cache_key)
+ return []
diff --git a/libs/subliminal_patch/providers/yavkanet.py b/libs/subliminal_patch/providers/yavkanet.py
index 6de60ef35..4555fd177 100644
--- a/libs/subliminal_patch/providers/yavkanet.py
+++ b/libs/subliminal_patch/providers/yavkanet.py
@@ -37,7 +37,12 @@ class YavkaNetSubtitle(Subtitle):
self.type = type
self.video = video
self.fps = fps
- self.release_info = os.path.splitext(filename)[0]
+ self.release_info = filename
+ if fps:
+ if video.fps and float(video.fps) == fps:
+ self.release_info += " <b>[{:.3f}]</b>".format(fps)
+ else:
+ self.release_info += " [{:.3f}]".format(fps)
@property
def id(self):
@@ -141,7 +146,7 @@ class YavkaNetProvider(Provider):
element = row.find('a', {'class': 'selector'})
if element:
link = element.get('href')
- notes = element.get('content')
+ notes = re.sub(r'(?s)<p.*><img [A-z0-9=\'/\. :;#]*>(.*)</p>', r"\1", element.get('content'))
title = element.get_text()
try:
@@ -205,12 +210,15 @@ class YavkaNetProvider(Provider):
else:
logger.info('Cache file: %s', codecs.encode(cache_key, 'hex_codec').decode('utf-8'))
- archive_stream = io.BytesIO(request.content)
- if is_rarfile(archive_stream):
- return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps)
- elif is_zipfile(archive_stream):
- return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps)
- else:
- logger.error('Ignore unsupported archive %r', request.headers)
- region.delete(cache_key)
- return []
+ try:
+ archive_stream = io.BytesIO(request.content)
+ if is_rarfile(archive_stream):
+ return self.process_archive_subtitle_files(RarFile(archive_stream), language, video, link, fps)
+ elif is_zipfile(archive_stream):
+ return self.process_archive_subtitle_files(ZipFile(archive_stream), language, video, link, fps)
+ except:
+ pass
+
+ logger.error('Ignore unsupported archive %r', request.headers)
+ region.delete(cache_key)
+ return []
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