summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2023-10-10 03:37:45 -0400
committerVitiko <[email protected]>2023-10-10 03:37:45 -0400
commitbee6919979409ccbc6e8174b117d091ec8d2e0c2 (patch)
treea8c4694f64af20f2679901a6c43d99b945deb2bf
parent0031abcea4b7a054e55d96005ec9d0eb76490691 (diff)
downloadbazarr-bee6919979409ccbc6e8174b117d091ec8d2e0c2.tar.gz
bazarr-bee6919979409ccbc6e8174b117d091ec8d2e0c2.zip
EmbeddedSubtitles provider: add blacklist supportv1.3.1-beta.10
-rw-r--r--libs/subliminal_patch/providers/embeddedsubtitles.py5
-rw-r--r--libs/subliminal_patch/providers/utils.py22
2 files changed, 24 insertions, 3 deletions
diff --git a/libs/subliminal_patch/providers/embeddedsubtitles.py b/libs/subliminal_patch/providers/embeddedsubtitles.py
index 828648432..b1d7b12f9 100644
--- a/libs/subliminal_patch/providers/embeddedsubtitles.py
+++ b/libs/subliminal_patch/providers/embeddedsubtitles.py
@@ -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)
diff --git a/libs/subliminal_patch/providers/utils.py b/libs/subliminal_patch/providers/utils.py
index f06f75e34..032e7eebf 100644
--- a/libs/subliminal_patch/providers/utils.py
+++ b/libs/subliminal_patch/providers/utils.py
@@ -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"