mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-24 00:33:27 +00:00
HDBits provider: add search filters
This commit is contained in:
parent
bee6919979
commit
d6579417ba
1 changed files with 14 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
import functools
|
import functools
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from babelfish import language_converters
|
from babelfish import language_converters
|
||||||
|
@ -42,6 +43,7 @@ class HDBitsSubtitle(Subtitle):
|
||||||
|
|
||||||
_SPECIAL_LANG_MAP = {"uk": ("eng",), "br": ("por", "BR"), "gr": ("ell",)}
|
_SPECIAL_LANG_MAP = {"uk": ("eng",), "br": ("por", "BR"), "gr": ("ell",)}
|
||||||
_ALLOWED_EXTENSIONS = (".ass", ".srt", ".zip", ".rar")
|
_ALLOWED_EXTENSIONS = (".ass", ".srt", ".zip", ".rar")
|
||||||
|
_FILTER = re.compile("extra|commentary|lyrics|forced")
|
||||||
|
|
||||||
|
|
||||||
def _get_language(code):
|
def _get_language(code):
|
||||||
|
@ -125,6 +127,9 @@ class HDBitsProvider(Provider):
|
||||||
if language is None:
|
if language is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if not _is_allowed(subtitle):
|
||||||
|
continue
|
||||||
|
|
||||||
if language not in languages:
|
if language not in languages:
|
||||||
logger.debug("Ignoring language: %r !~ %r", language, languages)
|
logger.debug("Ignoring language: %r !~ %r", language, languages)
|
||||||
continue
|
continue
|
||||||
|
@ -161,6 +166,15 @@ class HDBitsProvider(Provider):
|
||||||
subtitle.content = response.content
|
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)
|
@functools.lru_cache(2048)
|
||||||
def _memoized_episode_guess(content):
|
def _memoized_episode_guess(content):
|
||||||
# Use include to save time from unnecessary checks
|
# Use include to save time from unnecessary checks
|
||||||
|
|
Loading…
Reference in a new issue