diff options
author | Vitiko <[email protected]> | 2023-10-12 02:55:45 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2023-10-12 02:55:45 -0400 |
commit | d6579417ba3b3555bff3af446bef8a56e2d7a7c6 (patch) | |
tree | 076c9d6d3d4daabed4dac7a8078305310ce28e47 | |
parent | bee6919979409ccbc6e8174b117d091ec8d2e0c2 (diff) | |
download | bazarr-d6579417ba3b3555bff3af446bef8a56e2d7a7c6.tar.gz bazarr-d6579417ba3b3555bff3af446bef8a56e2d7a7c6.zip |
HDBits provider: add search filtersv1.3.1-beta.11v1.3.1
-rw-r--r-- | libs/subliminal_patch/providers/hdbits.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libs/subliminal_patch/providers/hdbits.py b/libs/subliminal_patch/providers/hdbits.py index 09b2140a5..ddac50fc6 100644 --- a/libs/subliminal_patch/providers/hdbits.py +++ b/libs/subliminal_patch/providers/hdbits.py @@ -2,6 +2,7 @@ import functools from json import JSONDecodeError import logging +import re import time from babelfish import language_converters @@ -42,6 +43,7 @@ class HDBitsSubtitle(Subtitle): _SPECIAL_LANG_MAP = {"uk": ("eng",), "br": ("por", "BR"), "gr": ("ell",)} _ALLOWED_EXTENSIONS = (".ass", ".srt", ".zip", ".rar") +_FILTER = re.compile("extra|commentary|lyrics|forced") def _get_language(code): @@ -125,6 +127,9 @@ class HDBitsProvider(Provider): if language is None: continue + if not _is_allowed(subtitle): + continue + if language not in languages: logger.debug("Ignoring language: %r !~ %r", language, languages) continue @@ -161,6 +166,15 @@ class HDBitsProvider(Provider): subtitle.content = response.content +def _is_allowed(subtitle): + for val in (subtitle["title"], subtitle["filename"]): + if _FILTER.search(val.lower()): + logger.debug("Not allowed subtitle: %s", subtitle) + return False + + return True + + @functools.lru_cache(2048) def _memoized_episode_guess(content): # Use include to save time from unnecessary checks |