Skip to content

Commit

Permalink
Implement a foreign language-only filter for Subscene (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
vagabondHustler committed Jun 2, 2023
2 parents 59eb503 + f9c0a46 commit 00987c7
Show file tree
Hide file tree
Showing 9 changed files with 615 additions and 428 deletions.
5 changes: 5 additions & 0 deletions src/subsearch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def __init__(self) -> None:
if self.file_exist is False:
tab_manager.open_tab("search")
return None
self.foreign_only = io_json.get_json_key("foreign_only")

if " " in video_data.filename:
log.warning_spaces_in_filename()
Expand Down Expand Up @@ -187,6 +188,8 @@ def __init__(self, cls):
def opensubtitles(self) -> bool:
if self.cls.file_exist is False:
return True
if self.cls.foreign_only:
return True
if io_json.check_language_compatibility("opensubtitles") is False:
return True
if (
Expand All @@ -208,6 +211,8 @@ def subscene(self) -> bool:
def yifysubtitles(self) -> bool:
if self.cls.file_exist is False:
return True
if self.cls.foreign_only:
return True
if io_json.check_language_compatibility("yifysubtitles") is False:
return True
if self.cls.release_data.tvseries:
Expand Down
11 changes: 11 additions & 0 deletions src/subsearch/data/data_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LanguageData:
alpha_1: str
alpha_2b: str
incompatibility: list[str]
subscene_id: int


@dataclass(order=True)
Expand Down Expand Up @@ -91,6 +92,7 @@ class AppConfig:

current_language: str
subtitle_type: dict[str, bool]
foreign_only: bool
percentage_threshold: int
rename_best_match: bool
context_menu: bool
Expand All @@ -107,6 +109,15 @@ class AppConfig:
non_hearing_impaired: bool


@dataclass(order=True)
class SubsceneCookie:
dark_theme: bool
sort_subtitle_by_date: str
language_filter: int
hearing_impaired: bool
foreigen_only: bool


@dataclass(frozen=True, order=True)
class ReleaseData:
"""
Expand Down
Loading

0 comments on commit 00987c7

Please sign in to comment.