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

@ -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