Merge pull request #1174 from vitiko98/opensubtitles-matches

Fix source score matching in subtitle.py
pull/1183/head
morpheus65535 4 years ago committed by GitHub
commit 438eee94f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -6,12 +6,13 @@ import zipfile
import rarfile import rarfile
from requests import Session from requests import Session
from guessit import guessit
from subliminal import Episode, Movie from subliminal import Episode, Movie
from subliminal.exceptions import ServiceUnavailable from subliminal.exceptions import ServiceUnavailable
from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending from subliminal.subtitle import SUBTITLE_EXTENSIONS, fix_line_ending
from subliminal_patch.exceptions import APIThrottled from subliminal_patch.exceptions import APIThrottled
from subliminal_patch.providers import Provider 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 from subzero.language import Language
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -50,32 +51,14 @@ class SuchaSubtitle(Subtitle):
return self.download_link return self.download_link
def get_matches(self, video): def get_matches(self, video):
if ( if isinstance(video, Episode):
video.release_group self.found_matches |= guess_matches(
and str(video.release_group).lower() in self.filename.lower() video, guessit(self.filename, {"type": "episode"})
): )
self.found_matches.add("release_group") else:
self.found_matches |= guess_matches(
if video.source and video.source.lower() in self.guessit["source"].lower(): video, guessit(self.filename, {"type": "movie"})
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")
return self.found_matches return self.found_matches
@ -141,7 +124,7 @@ class SuchaProvider(Provider):
if imdb_id: if imdb_id:
matches.add("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 # in order to show it in the manual search
filename = i["pseudo_file"] filename = i["pseudo_file"]
if ( if (

@ -104,7 +104,7 @@ class Subtitle(Subtitle_):
def make_picklable(self): 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
""" """
return self return self
@ -377,7 +377,7 @@ class Subtitle(Subtitle_):
def get_modified_content(self, format="srt", debug=False): def get_modified_content(self, format="srt", debug=False):
""" """
:return: string :return: string
""" """
if not self.mods: if not self.mods:
return fix_text(self.content.decode(encoding=self.get_encoding()), **ftfy_defaults).encode( return fix_text(self.content.decode(encoding=self.get_encoding()), **ftfy_defaults).encode(
@ -404,7 +404,8 @@ class ModifiedSubtitle(Subtitle):
MERGED_FORMATS = { MERGED_FORMATS = {
"TV": ("HDTV", "SDTV", "AHDTV", "UHDTV"), "TV": ("HDTV", "SDTV", "AHDTV", "UHDTV"),
"Air": ("SATRip", "DVB", "PPV"), "Air": ("SATRip", "DVB", "PPV"),
"Disk": ("DVD", "HD-DVD", "BluRay") "Disk-HD": ("HD-DVD", "Blu-ray"),
"Disk-SD": ("DVD", "VHS"),
} }
MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k]) MERGED_FORMATS_REV = dict((v.lower(), k.lower()) for k in MERGED_FORMATS for v in MERGED_FORMATS[k])

Loading…
Cancel
Save