diff --git a/libs/subliminal_patch/providers/titrari.py b/libs/subliminal_patch/providers/titrari.py index b0773ed75..7ac00c3d7 100644 --- a/libs/subliminal_patch/providers/titrari.py +++ b/libs/subliminal_patch/providers/titrari.py @@ -1,6 +1,7 @@ # coding=utf-8 from __future__ import absolute_import +import os import io import logging import re @@ -18,6 +19,7 @@ from .utils import FIRST_THOUSAND_OR_SO_USER_AGENTS as AGENT_LIST from subliminal.exceptions import ProviderError from subliminal.providers import ParserBeautifulSoup from subliminal.video import Episode, Movie +from subliminal.subtitle import SUBTITLE_EXTENSIONS from subzero.language import Language # parsing regex definitions @@ -95,7 +97,7 @@ class TitrariProvider(Provider, ProviderSubtitleArchiveMixin): languages = {Language(l) for l in ['ron', 'eng']} languages.update(set(Language.rebuild(l, forced=True) for l in languages)) api_url = 'https://www.titrari.ro/' - query_advanced_search = 'cautareavansata' + query_advanced_search = 'cautaredevansata' def __init__(self): self.session = None @@ -226,5 +228,21 @@ class TitrariProvider(Provider, ProviderSubtitleArchiveMixin): raise ProviderError('[#### Provider: titrari.ro] Unidentified archive type') + subtitle.releases = _get_releases_from_archive(archive) subtitle.content = self.get_subtitle_from_archive(subtitle, archive) + +def _get_releases_from_archive(archive): + releases = [] + for name in archive.namelist(): + # discard hidden files + if os.path.split(name)[-1].startswith('.'): + continue + + # discard non-subtitle files + if not name.lower().endswith(SUBTITLE_EXTENSIONS): + continue + + releases.append(os.path.splitext(os.path.split(name)[1])[0]) + + return releases