Added opensubtitlescom settings to include AI translated subtitles in search results.

pull/2342/head
morpheus65535 11 months ago
parent 7c40bfec1e
commit 5739b9ad08

@ -201,6 +201,7 @@ validators = [
Validator('opensubtitlescom.username', must_exist=True, default='', is_type_of=str, cast=str),
Validator('opensubtitlescom.password', must_exist=True, default='', is_type_of=str, cast=str),
Validator('opensubtitlescom.use_hash', must_exist=True, default=True, is_type_of=bool),
Validator('opensubtitlescom.include_ai_translated', must_exist=True, default=False, is_type_of=bool),
# addic7ed section
Validator('addic7ed.username', must_exist=True, default='', is_type_of=str, cast=str),

@ -240,6 +240,7 @@ def get_providers_auth():
'opensubtitlescom': {'username': settings.opensubtitlescom.username,
'password': settings.opensubtitlescom.password,
'use_hash': settings.opensubtitlescom.use_hash,
'include_ai_translated': settings.opensubtitlescom.include_ai_translated,
'api_key': 's38zmzVlW7IlYruWi7mHwDYl2SfMQoC1'
},
'podnapisi': {

@ -286,6 +286,11 @@ export const ProviderList: Readonly<ProviderInfo[]> = [
key: "use_hash",
name: "Use Hash",
},
{
type: "switch",
key: "include_ai_translated",
name: "Include AI translated subtitles in search results",
},
],
},
{

@ -162,7 +162,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
video_types = (Episode, Movie)
def __init__(self, username=None, password=None, use_hash=True, api_key=None):
def __init__(self, username=None, password=None, use_hash=True, include_ai_translated=False, api_key=None):
if not all((username, password)):
raise ConfigurationError('Username and password must be specified')
@ -181,6 +181,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
self.password = password
self.video = None
self.use_hash = use_hash
self.include_ai_translated = include_ai_translated
self._started = None
def initialize(self):
@ -300,7 +301,8 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
res = self.retry(
lambda: self.checked(
lambda: self.session.get(self.server_url + 'subtitles',
params=(('ai_translated', 'exclude'),
params=(('ai_translated', 'exclude' if not self.include_ai_translated
else 'include'),
('episode_number', self.video.episode),
('imdb_id', imdb_id if not title_id else None),
('languages', langs),
@ -317,7 +319,8 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
res = self.retry(
lambda: self.checked(
lambda: self.session.get(self.server_url + 'subtitles',
params=(('ai_translated', 'exclude'),
params=(('ai_translated', 'exclude' if not self.include_ai_translated
else 'include'),
('id', title_id if title_id else None),
('imdb_id', imdb_id if not title_id else None),
('languages', langs),

Loading…
Cancel
Save