diff --git a/libs/subliminal_patch/providers/subtitulamostv.py b/libs/subliminal_patch/providers/subtitulamostv.py index 08239768c..065e4563d 100644 --- a/libs/subliminal_patch/providers/subtitulamostv.py +++ b/libs/subliminal_patch/providers/subtitulamostv.py @@ -4,8 +4,6 @@ import logging import os import re import io -import rarfile -import zipfile from babelfish import language_converters from guessit import guessit @@ -26,42 +24,63 @@ server_url = 'https://subtitulamos.tv/' class SubtitulamosTVSubtitle(Subtitle): provider_name = 'subtitulamostv' + hash_verifiable = False - def __init__(self, subtitle_id, language, release_group, url, matches): - super(SubtitulamosTVSubtitle, self).__init__(language, page_link=url) - self.subtitle_id = subtitle_id - self.release_group = release_group - self.download_url = url + def __init__(self, language, page_link, download_link, description, title, matches, release_info): + super(SubtitulamosTVSubtitle, self).__init__(language, hearing_impaired=False, + page_link=page_link, release_info=release_info, encoding="windows-1252") + self.download_link = download_link + self.description = description.lower() + self.title = title self.matches = matches @property def id(self): - return self.subtitle_id - - @property - def download_link(self): - return self.download_url + return self.download_link def get_matches(self, video): matches = self.matches - if isinstance(video, Episode): - matches |= guess_matches(video, guessit( - self.release_group, {'type': 'episode'}), partial=True) + # release_group + if video.release_group and video.release_group.lower() in self.description: + matches.add('release_group') + + # resolution + if video.resolution and video.resolution.lower() in self.description: + matches.add('resolution') + + # format + if video.format: + formats = [video.format.lower()] + if formats[0] == "web-dl": + formats.append("webdl") + formats.append("webrip") + formats.append("web ") + for frmt in formats: + if frmt.lower() in self.description: + matches.add('format') + break + + # video_codec + if video.video_codec: + video_codecs = [video.video_codec.lower()] + if video_codecs[0] == "h264": + formats.append("x264") + elif video_codecs[0] == "h265": + formats.append("x265") + for vc in formats: + if vc.lower() in self.description: + matches.add('video_codec') + break return matches class SubtitulamosTVProvider(Provider): """Subtitulamostv Provider""" - languages = {Language.fromietf(l) for l in ['en','es-AR','es-ES']} + languages = {Language.fromietf(l) for l in ['en','es']} video_types = (Episode,) - # def __init__(self): - # if not token: - # raise ConfigurationError('Token must be specified') - # self.token = token - def initialize(self): self.session = Session() self.session.headers = { @@ -74,8 +93,8 @@ class SubtitulamosTVProvider(Provider): # query the server result = None matches = set() - - q = "%s %dx%02d" % (video.series, video.season, video.episode) + year = (" (%d)" % video.year) if video.year else "" + q = "%s%s %dx%02d" % (video.series, year, video.season, video.episode) logger.debug('Searching subtitles "%s"', q) res = self.session.get( @@ -93,20 +112,16 @@ class SubtitulamosTVProvider(Provider): for lang_m in re.finditer(r"