1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-27 10:07:22 +00:00

core: update to subliminal_patch:head; subscene: explicitly set account filters for languages

This commit is contained in:
panni 2019-06-23 15:28:42 +02:00
parent 702038c191
commit 3d8e8ee59b

View file

@ -125,7 +125,7 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
username = None
password = None
search_throttle = 5 # seconds
search_throttle = 8 # seconds
def __init__(self, only_foreign=False, username=None, password=None):
if not all((username, password)):
@ -202,12 +202,20 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
def _create_filters(self, languages):
self.filters = dict(HearingImpaired="2")
acc_filters = self.filters.copy()
if self.only_foreign:
self.filters["ForeignOnly"] = "True"
acc_filters["ForeignOnly"] = self.filters["ForeignOnly"].lower()
logger.info("Only searching for foreign/forced subtitles")
self.filters["LanguageFilter"] = ",".join((str(language_ids[l.alpha3]) for l in languages
if l.alpha3 in language_ids))
acc_filters["SelectedIds"] = [str(language_ids[l.alpha3]) for l in languages if l.alpha3 in language_ids]
self.filters["LanguageFilter"] = ",".join(acc_filters["SelectedIds"])
last_filters = region.get("subscene_filters")
if last_filters != acc_filters:
region.set("subscene_filters", acc_filters)
logger.debug("Setting account filters to %r", acc_filters)
self.session.post("https://u.subscene.com/filter", acc_filters, allow_redirects=False)
logger.debug("Filter created: '%s'" % self.filters)
@ -289,9 +297,10 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
# re-search for episodes without explicit release name
if isinstance(video, Episode):
titles = list(set([video.series] + video.alternative_series))[:2]
# term = u"%s S%02iE%02i" % (video.series, video.season, video.episode)
more_than_one = len([video.series] + video.alternative_series) > 1
for series in set([video.series] + video.alternative_series):
more_than_one = len(titles) > 1
for series in titles:
term = u"%s - %s Season" % (series, p.number_to_words("%sth" % video.season).capitalize())
logger.debug('Searching for alternative results: %s', term)
film = self.do_search(term, session=self.session, release=False, throttle=self.search_throttle)
@ -317,8 +326,9 @@ class SubsceneProvider(Provider, ProviderSubtitleArchiveMixin):
if more_than_one:
time.sleep(self.search_throttle)
else:
more_than_one = len([video.title] + video.alternative_titles) > 1
for title in set([video.title] + video.alternative_titles):
titles = list(set([video.title] + video.alternative_titles))[:2]
more_than_one = len(titles) > 1
for title in titles:
logger.debug('Searching for movie results: %r', title)
film = self.do_search(title, year=video.year, session=self.session, limit_to=None, release=False,
throttle=self.search_throttle)