Fix source score matching in subtitle.py

Changed score matching logic for sucha
pull/1174/head
vitiko98 4 years ago
parent 951f2f8a03
commit 8e59cf5fed

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

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

Loading…
Cancel
Save