From 8acb488fba1bc804c7ef379c7d683a1eb786039e Mon Sep 17 00:00:00 2001 From: josdion Date: Sun, 31 May 2020 19:01:53 +0300 Subject: [PATCH] delete unsupported subtitle archive files from cache --- libs/subliminal_patch/providers/subssabbz.py | 1 + libs/subliminal_patch/providers/subsunacs.py | 1 + libs/subliminal_patch/providers/yavkanet.py | 9 +++++---- libs/subliminal_patch/providers/yifysubtitles.py | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/subliminal_patch/providers/subssabbz.py b/libs/subliminal_patch/providers/subssabbz.py index 1b365ea2d..386e3c19f 100644 --- a/libs/subliminal_patch/providers/subssabbz.py +++ b/libs/subliminal_patch/providers/subssabbz.py @@ -255,4 +255,5 @@ class SubsSabBzProvider(Provider): 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 [] diff --git a/libs/subliminal_patch/providers/subsunacs.py b/libs/subliminal_patch/providers/subsunacs.py index 59656a08b..19c5eff86 100644 --- a/libs/subliminal_patch/providers/subsunacs.py +++ b/libs/subliminal_patch/providers/subsunacs.py @@ -277,4 +277,5 @@ class SubsUnacsProvider(Provider): 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 [] diff --git a/libs/subliminal_patch/providers/yavkanet.py b/libs/subliminal_patch/providers/yavkanet.py index 70a8ad830..6de60ef35 100644 --- a/libs/subliminal_patch/providers/yavkanet.py +++ b/libs/subliminal_patch/providers/yavkanet.py @@ -25,13 +25,13 @@ from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST logger = logging.getLogger(__name__) + class YavkaNetSubtitle(Subtitle): """YavkaNet Subtitle.""" provider_name = 'yavkanet' - def __init__(self, langauge, filename, type, video, link, fps): - super(YavkaNetSubtitle, self).__init__(langauge) - self.langauge = langauge + def __init__(self, language, filename, type, video, link, fps): + super(YavkaNetSubtitle, self).__init__(language) self.filename = filename self.page_link = link self.type = type @@ -66,7 +66,7 @@ class YavkaNetSubtitle(Subtitle): if ((video_filename == subtitle_filename) or (self.single_file is True and video_filename in self.notes.upper())): - matches.add('hash') + matches.add('hash') if video.year and self.year == video.year: matches.add('year') @@ -212,4 +212,5 @@ class YavkaNetProvider(Provider): 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 [] diff --git a/libs/subliminal_patch/providers/yifysubtitles.py b/libs/subliminal_patch/providers/yifysubtitles.py index 560806efe..59d683577 100644 --- a/libs/subliminal_patch/providers/yifysubtitles.py +++ b/libs/subliminal_patch/providers/yifysubtitles.py @@ -178,6 +178,7 @@ class YifySubtitlesProvider(Provider): self._process_archive(ZipFile(archive_stream), subtitle) else: logger.error('Ignore unsupported archive %r', request.headers) + region.delete(cache_key) def _process_archive(self, archive_stream, subtitle): for file_name in archive_stream.namelist():