Fixed Titrari provider #1438

This commit is contained in:
morpheus65535 2021-06-14 15:29:39 -04:00
parent bd0a2fe004
commit f4df07fb83

View file

@ -1,6 +1,7 @@
# coding=utf-8 # coding=utf-8
from __future__ import absolute_import from __future__ import absolute_import
import os
import io import io
import logging import logging
import re 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.exceptions import ProviderError
from subliminal.providers import ParserBeautifulSoup from subliminal.providers import ParserBeautifulSoup
from subliminal.video import Episode, Movie from subliminal.video import Episode, Movie
from subliminal.subtitle import SUBTITLE_EXTENSIONS
from subzero.language import Language from subzero.language import Language
# parsing regex definitions # parsing regex definitions
@ -95,7 +97,7 @@ class TitrariProvider(Provider, ProviderSubtitleArchiveMixin):
languages = {Language(l) for l in ['ron', 'eng']} languages = {Language(l) for l in ['ron', 'eng']}
languages.update(set(Language.rebuild(l, forced=True) for l in languages)) languages.update(set(Language.rebuild(l, forced=True) for l in languages))
api_url = 'https://www.titrari.ro/' api_url = 'https://www.titrari.ro/'
query_advanced_search = 'cautareavansata' query_advanced_search = 'cautaredevansata'
def __init__(self): def __init__(self):
self.session = None self.session = None
@ -226,5 +228,21 @@ class TitrariProvider(Provider, ProviderSubtitleArchiveMixin):
raise ProviderError('[#### Provider: titrari.ro] Unidentified archive type') raise ProviderError('[#### Provider: titrari.ro] Unidentified archive type')
subtitle.releases = _get_releases_from_archive(archive)
subtitle.content = self.get_subtitle_from_archive(subtitle, 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