EmbeddedSubtitles provider: add blacklist support

pull/2213/head v1.3.1-beta.10
Vitiko 1 year ago
parent 0031abcea4
commit bee6919979

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
import functools
import logging
import hashlib
import logging
import os
import re
import shutil
@ -14,10 +14,12 @@ from fese import container
from fese import FFprobeSubtitleStream
from fese import FFprobeVideoContainer
from fese import tags
from fese.exceptions import ExtractionError
from fese.exceptions import InvalidSource
from subliminal_patch.core import Episode
from subliminal_patch.core import Movie
from subliminal_patch.providers import Provider
from subliminal_patch.providers.utils import blacklist_on
from subliminal_patch.subtitle import Subtitle
from subzero.language import Language
@ -185,6 +187,7 @@ class EmbeddedSubtitlesProvider(Provider):
"series" if isinstance(video, Episode) else "movie",
)
@blacklist_on(ExtractionError)
def download_subtitle(self, subtitle: EmbeddedSubtitle):
path = self._get_subtitle_path(subtitle)

@ -12,6 +12,7 @@ from guessit import guessit
import pysubs2
import rarfile
from subliminal.subtitle import fix_line_ending
from subliminal_patch.exceptions import MustGetBlacklisted
from subliminal_patch.core import Episode
from subliminal_patch.subtitle import guess_matches
@ -23,6 +24,22 @@ logger = logging.getLogger(__name__)
_MatchingSub = namedtuple("_MatchingSub", ("file", "priority", "context"))
def blacklist_on(*exc_types):
"Raise MustGetBlacklisted if any of the exc_types are raised."
def decorator(method):
def wrapper(self, subtitle):
try:
return method(self, subtitle)
except exc_types:
logger.error("Sending blacklist exception", exc_info=True)
raise MustGetBlacklisted(subtitle.id, subtitle.media_type)
return wrapper
return decorator
def _get_matching_sub(
sub_names, forced=False, episode=None, episode_title=None, **kwargs
):
@ -169,11 +186,12 @@ def update_matches(
video,
release_info: Union[str, Iterable[str]],
split="\n",
**guessit_options
**guessit_options,
):
"""Update matches set from release info string or Iterable.
Use the split parameter to iterate over the set delimiter; set None to avoid split."""
Use the split parameter to iterate over the set delimiter; set None to avoid split.
"""
guessit_options["type"] = "episode" if isinstance(video, Episode) else "movie"

Loading…
Cancel
Save