Skip to content

Commit

Permalink
feat: Add Subtitulamos provider integration - mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyaran committed Oct 6, 2024
1 parent 9a8def3 commit 23d9e5d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions subliminal/providers/subtitulamos.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import TYPE_CHECKING, Any, ClassVar, cast

from babelfish import Language, language_converters # type: ignore[import-untyped]
from bs4 import Tag
from guessit import guessit # type: ignore[import-untyped]
from requests import Session

Expand Down Expand Up @@ -200,9 +201,16 @@ def query(
subtitles = []
for sub in soup.select('.download-button:not(unavailable)'):
# read the language
language = Language.fromsubtitulamos(sub.find_previous('div', class_='language-name').get_text().strip())
if (
sub.parent is None
or (lang_name_element := sub.find_previous('div', class_='language-name')) is None
or (version_container := sub.find_previous('div', class_='version-container')) is None
or not isinstance(version_container, Tag)
or (release_group_element := version_container.select('.version-container .text.spaced')) is None
):
continue

version_container = sub.find_previous('div', class_='version-container')
language = Language.fromsubtitulamos(lang_name_element.get_text().strip())

hearing_impaired = False

Expand All @@ -214,7 +222,7 @@ def query(
hearing_impaired = True

# read the release subtitle
release_group = version_container.select('.version-container .text.spaced')[0].getText()
release_group = release_group_element[0].getText()

# read the subtitle url
subtitle_url = self.server_url + cast(str, sub.parent.get('href', ''))
Expand Down

0 comments on commit 23d9e5d

Please sign in to comment.