Skip to content

Commit

Permalink
feat: Add Subtitulamos provider integration - Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyaran committed Oct 6, 2024
1 parent 830a27b commit 73dbcb3
Show file tree
Hide file tree
Showing 6 changed files with 6,869 additions and 11 deletions.
4 changes: 0 additions & 4 deletions subliminal/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,3 @@ def download(

if verbose == 0:
click.echo(f"Downloaded {plural(total_subtitles, 'subtitle')}")


if __name__ == '__main__':
subliminal()
6 changes: 1 addition & 5 deletions subliminal/converters/subtitulamos.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ def __init__(self) -> None:
'English (UK)': ('eng', 'GB'),
'Brazilian': ('por', 'BR'),
}
self.to_subtitulamos: dict[LanguageTuple, str] = {
('cat',): 'Català',
('glg',): 'Galego',
('por', 'BR'): 'Brazilian',
}
self.to_subtitulamos: dict[LanguageTuple, str] = {item[1]: item[0] for item in self.from_subtitulamos.items()}
self.codes = set(self.from_subtitulamos.keys())

def convert(self, alpha3: str, country: str | None = None, script: str | None = None) -> str:
Expand Down
6 changes: 4 additions & 2 deletions subliminal/providers/subtitulamos.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def initialize(self) -> None:
def terminate(self) -> None:
"""Terminate the provider."""
self.session.close()
self.session = None

def _session_request(self, *args: Any, **kwargs: Any) -> Response:
"""Perform a GET request to the provider."""
Expand Down Expand Up @@ -191,8 +192,9 @@ def _search_url_titles(
series_response = self._query_search(series)

episode_url = self._get_episode_url(series_response[0]['show_id'], season, episode)

return self.server_url + episode_url
if episode_url:
return self.server_url + episode_url
return None

def query(
self, series: str | None = None, season: int | None = None, episode: int | None = None, year: int | None = None
Expand Down
Loading

0 comments on commit 73dbcb3

Please sign in to comment.