Fix for #1104. Searching for one language after the other when more then one language is requested. Previously, PT was being prioritized over others.

pull/1173/head
Louis Vézina 4 years ago
parent 99318bbde1
commit 7a2e6ab24f

@ -290,6 +290,8 @@ class LegendasdivxProvider(Provider):
_searchurl = self.searchurl _searchurl = self.searchurl
subtitles = []
if isinstance(video, Movie): if isinstance(video, Movie):
querytext = video.imdb_id if video.imdb_id else video.title querytext = video.imdb_id if video.imdb_id else video.title
@ -298,11 +300,15 @@ class LegendasdivxProvider(Provider):
querytext = quote(quote(querytext)) querytext = quote(quote(querytext))
# language query filter # language query filter
if isinstance(languages, (tuple, list, set)): if not isinstance(languages, (tuple, list, set)):
language_ids = ','.join(sorted(l.opensubtitles for l in languages)) languages = [languages]
if 'por' in language_ids: # prioritize portuguese subtitles
for language in languages:
logger.debug("Legendasdivx.pt :: searching for %s subtitles.", language)
language_id = language.opensubtitles
if 'por' in language_id:
lang_filter = '&form_cat=28' lang_filter = '&form_cat=28'
elif 'pob' in language_ids: elif 'pob' in language_id:
lang_filter = '&form_cat=29' lang_filter = '&form_cat=29'
else: else:
lang_filter = '' lang_filter = ''
@ -359,7 +365,7 @@ class LegendasdivxProvider(Provider):
num_pages = min(MAX_PAGES, num_pages) num_pages = min(MAX_PAGES, num_pages)
# process first page # process first page
subtitles = self._process_page(video, bsoup) subtitles += self._process_page(video, bsoup)
# more pages? # more pages?
if num_pages > 1: if num_pages > 1:

Loading…
Cancel
Save