From 8e59cf5fed95cdefd01236c0a68001c76f9943f2 Mon Sep 17 00:00:00 2001 From: vitiko98 Date: Tue, 27 Oct 2020 19:17:40 -0400 Subject: [PATCH 1/2] Fix source score matching in subtitle.py Changed score matching logic for sucha --- libs/subliminal_patch/providers/sucha.py | 39 +++++++----------------- libs/subliminal_patch/subtitle.py | 8 +++-- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/libs/subliminal_patch/providers/sucha.py b/libs/subliminal_patch/providers/sucha.py index 05113dca8..eb1247d99 100644 --- a/libs/subliminal_patch/providers/sucha.py +++ b/libs/subliminal_patch/providers/sucha.py @@ -6,12 +6,13 @@ import zipfile import rarfile from requests import Session +from guessit import guessit from subliminal import Episode, Movie from subliminal.exceptions import ServiceUnavailable from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending from subliminal_patch.exceptions import APIThrottled from subliminal_patch.providers import Provider -from subliminal_patch.subtitle import Subtitle +from subliminal_patch.subtitle import Subtitle, guess_matches from subzero.language import Language logger = logging.getLogger(__name__) @@ -50,32 +51,14 @@ class SuchaSubtitle(Subtitle): return self.download_link def get_matches(self, video): - if ( - video.release_group - and str(video.release_group).lower() in self.filename.lower() - ): - self.found_matches.add("release_group") - - if video.source and video.source.lower() in self.guessit["source"].lower(): - self.found_matches.add("source") - - if ( - video.resolution - and video.resolution.lower() in self.guessit["resolution"].lower() - ): - self.found_matches.add("resolution") - - if ( - video.audio_codec - and video.audio_codec.lower() in self.guessit["audio_codec"].lower() - ): - self.found_matches.add("audio_codec") - - if ( - video.video_codec - and video.video_codec.lower() in self.guessit["video_codec"].lower() - ): - self.found_matches.add("video_codec") + if isinstance(video, Episode): + self.found_matches |= guess_matches( + video, guessit(self.filename, {"type": "episode"}) + ) + else: + self.found_matches |= guess_matches( + video, guessit(self.filename, {"type": "movie"}) + ) return self.found_matches @@ -141,7 +124,7 @@ class SuchaProvider(Provider): if imdb_id: matches.add("imdb_id") - # We'll add release group info (if found) to the pseudo filename + # We'll add release group info (if found) to the pseudo filename # in order to show it in the manual search filename = i["pseudo_file"] if ( diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index a2459bb39..c2c3d6935 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -104,7 +104,7 @@ class Subtitle(Subtitle_): def make_picklable(self): """ - some subtitle instances might have unpicklable objects stored; clean them up here + some subtitle instances might have unpicklable objects stored; clean them up here :return: self """ return self @@ -377,7 +377,7 @@ class Subtitle(Subtitle_): def get_modified_content(self, format="srt", debug=False): """ - :return: string + :return: string """ if not self.mods: return fix_text(self.content.decode(encoding=self.get_encoding()), **ftfy_defaults).encode( @@ -404,7 +404,9 @@ class ModifiedSubtitle(Subtitle): MERGED_FORMATS = { "TV": ("HDTV", "SDTV", "AHDTV", "UHDTV"), "Air": ("SATRip", "DVB", "PPV"), - "Disk": ("DVD", "HD-DVD", "BluRay") + "Disk-HD": ("HD-DVD", "Blu-ray"), + "Disk-SD": ("DVD", "VHS"), + "Web": ("Web"), } MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k]) From 78d9788a78ed1751961c9f651dbfb2bd0e3db593 Mon Sep 17 00:00:00 2001 From: vitiko98 Date: Sat, 31 Oct 2020 19:36:29 -0400 Subject: [PATCH 2/2] remove web merging --- libs/subliminal_patch/subtitle.py | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index c2c3d6935..7e1bbda91 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -406,7 +406,6 @@ MERGED_FORMATS = { "Air": ("SATRip", "DVB", "PPV"), "Disk-HD": ("HD-DVD", "Blu-ray"), "Disk-SD": ("DVD", "VHS"), - "Web": ("Web"), } MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k])