diff options
author | destpstrzy <[email protected]> | 2024-12-21 02:54:54 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-20 20:54:54 -0500 |
commit | 320935548c28e85bbd9b0b0a6a073f1439deba31 (patch) | |
tree | 382f7d98c653ac612a8ce1bef0bad7e1afdcea27 /custom_libs | |
parent | 9d62d84ef590c65e7e9392fe82f1f2022b90bede (diff) | |
download | bazarr-320935548c28e85bbd9b0b0a6a073f1439deba31.tar.gz bazarr-320935548c28e85bbd9b0b0a6a073f1439deba31.zip |
Fixed download error with Napiprojekt providerv1.4.6-beta.34
Diffstat (limited to 'custom_libs')
-rw-r--r-- | custom_libs/subliminal_patch/providers/napiprojekt.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/custom_libs/subliminal_patch/providers/napiprojekt.py b/custom_libs/subliminal_patch/providers/napiprojekt.py index 8fabed885..b663348d8 100644 --- a/custom_libs/subliminal_patch/providers/napiprojekt.py +++ b/custom_libs/subliminal_patch/providers/napiprojekt.py @@ -47,8 +47,6 @@ class NapiProjektProvider(_NapiProjektProvider): self.only_real_names = only_real_names def query(self, language, hash): - if self.only_authors or self.only_real_names: - return None params = { 'v': 'dreambox', 'kolejka': 'false', @@ -74,11 +72,23 @@ class NapiProjektProvider(_NapiProjektProvider): return subtitle def list_subtitles(self, video, languages): - def flatten(l): - return [item for sublist in l for item in sublist] + def flatten(nested_list): + """Flatten a nested list.""" + return [item for sublist in nested_list for item in sublist] + + # Determine the source of subtitles based on conditions + hash_subtitles = [] + if not (self.only_authors or self.only_real_names): + hash_subtitles = [ + subtitle + for language in languages + if (subtitle := self.query(language, video.hashes.get('napiprojekt'))) is not None + ] + + # Scrape additional subtitles + scraped_subtitles = flatten([self._scrape(video, language) for language in languages]) - return [s for s in [self.query(l, video.hashes['napiprojekt']) for l in languages] if s is not None] + \ - flatten([self._scrape(video, l) for l in languages]) + return hash_subtitles + scraped_subtitles def download_subtitle(self, subtitle): if subtitle.content is not None: @@ -125,7 +135,7 @@ class NapiProjektProvider(_NapiProjektProvider): author = "" if self.only_authors: - if author.lower() in ["brak", "automat", "si", "chatgpt", "ai", "robot"]: + if author.lower() in ["brak", "automat", "si", "chatgpt", "ai", "robot", "maszynowe", "tłumaczenie maszynowe"]: continue if self.only_real_names: |