|
|
|
@ -26,16 +26,22 @@ class SubsSabBzSubtitle(Subtitle):
|
|
|
|
|
"""SubsSabBz Subtitle."""
|
|
|
|
|
provider_name = 'subssabbz'
|
|
|
|
|
|
|
|
|
|
def __init__(self, langauge, filename, type):
|
|
|
|
|
def __init__(self, langauge, filename, type, video, link):
|
|
|
|
|
super(SubsSabBzSubtitle, self).__init__(langauge)
|
|
|
|
|
self.langauge = langauge
|
|
|
|
|
self.filename = filename
|
|
|
|
|
self.page_link = link
|
|
|
|
|
self.type = type
|
|
|
|
|
self.video = video
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def id(self):
|
|
|
|
|
return self.filename
|
|
|
|
|
|
|
|
|
|
def make_picklable(self):
|
|
|
|
|
self.content = None
|
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
def get_matches(self, video):
|
|
|
|
|
matches = set()
|
|
|
|
|
|
|
|
|
@ -130,15 +136,22 @@ class SubsSabBzProvider(Provider):
|
|
|
|
|
return [s for l in languages for s in self.query(l, video)]
|
|
|
|
|
|
|
|
|
|
def download_subtitle(self, subtitle):
|
|
|
|
|
if subtitle.content:
|
|
|
|
|
pass
|
|
|
|
|
else:
|
|
|
|
|
seeking_subtitle_file = subtitle.filename
|
|
|
|
|
arch = self.download_archive_and_add_subtitle_files(subtitle.page_link, subtitle.language, subtitle.video)
|
|
|
|
|
for s in arch:
|
|
|
|
|
if s.filename == seeking_subtitle_file:
|
|
|
|
|
subtitle.content = s.content
|
|
|
|
|
|
|
|
|
|
def process_archive_subtitle_files(self, archiveStream, language, video):
|
|
|
|
|
def process_archive_subtitle_files(self, archiveStream, language, video, link):
|
|
|
|
|
subtitles = []
|
|
|
|
|
type = 'episode' if isinstance(video, Episode) else 'movie'
|
|
|
|
|
for file_name in archiveStream.namelist():
|
|
|
|
|
if file_name.lower().endswith(('.srt', '.sub')):
|
|
|
|
|
logger.info('Found subtitle file %r', file_name)
|
|
|
|
|
subtitle = SubsSabBzSubtitle(language, file_name, type)
|
|
|
|
|
subtitle = SubsSabBzSubtitle(language, file_name, type, video, link)
|
|
|
|
|
subtitle.content = archiveStream.read(file_name)
|
|
|
|
|
subtitles.append(subtitle)
|
|
|
|
|
return subtitles
|
|
|
|
@ -152,8 +165,8 @@ class SubsSabBzProvider(Provider):
|
|
|
|
|
|
|
|
|
|
archive_stream = io.BytesIO(request.content)
|
|
|
|
|
if is_rarfile(archive_stream):
|
|
|
|
|
return self.process_archive_subtitle_files( RarFile(archive_stream), language, video )
|
|
|
|
|
return self.process_archive_subtitle_files( RarFile(archive_stream), language, video, link )
|
|
|
|
|
elif is_zipfile(archive_stream):
|
|
|
|
|
return self.process_archive_subtitle_files( ZipFile(archive_stream), language, video )
|
|
|
|
|
return self.process_archive_subtitle_files( ZipFile(archive_stream), language, video, link )
|
|
|
|
|
else:
|
|
|
|
|
raise ValueError('Not a valid archive')
|
|
|
|
|