mirror of
https://github.com/morpheus65535/bazarr
synced 2025-01-03 05:25:28 +00:00
Fixed download error with Napiprojekt provider
This commit is contained in:
parent
9d62d84ef5
commit
320935548c
1 changed files with 17 additions and 7 deletions
|
@ -47,8 +47,6 @@ class NapiProjektProvider(_NapiProjektProvider):
|
||||||
self.only_real_names = only_real_names
|
self.only_real_names = only_real_names
|
||||||
|
|
||||||
def query(self, language, hash):
|
def query(self, language, hash):
|
||||||
if self.only_authors or self.only_real_names:
|
|
||||||
return None
|
|
||||||
params = {
|
params = {
|
||||||
'v': 'dreambox',
|
'v': 'dreambox',
|
||||||
'kolejka': 'false',
|
'kolejka': 'false',
|
||||||
|
@ -74,11 +72,23 @@ class NapiProjektProvider(_NapiProjektProvider):
|
||||||
return subtitle
|
return subtitle
|
||||||
|
|
||||||
def list_subtitles(self, video, languages):
|
def list_subtitles(self, video, languages):
|
||||||
def flatten(l):
|
def flatten(nested_list):
|
||||||
return [item for sublist in l for item in sublist]
|
"""Flatten a nested list."""
|
||||||
|
return [item for sublist in nested_list for item in sublist]
|
||||||
|
|
||||||
return [s for s in [self.query(l, video.hashes['napiprojekt']) for l in languages] if s is not None] + \
|
# Determine the source of subtitles based on conditions
|
||||||
flatten([self._scrape(video, l) for l in languages])
|
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 hash_subtitles + scraped_subtitles
|
||||||
|
|
||||||
def download_subtitle(self, subtitle):
|
def download_subtitle(self, subtitle):
|
||||||
if subtitle.content is not None:
|
if subtitle.content is not None:
|
||||||
|
@ -125,7 +135,7 @@ class NapiProjektProvider(_NapiProjektProvider):
|
||||||
author = ""
|
author = ""
|
||||||
|
|
||||||
if self.only_authors:
|
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
|
continue
|
||||||
|
|
||||||
if self.only_real_names:
|
if self.only_real_names:
|
||||||
|
|
Loading…
Reference in a new issue