Пример #1
0
        "media": "movie",
        "name": "Citizen Kane",
        "year": 1941,
    },
    "Les Misérables": {
        "id_imdb": "tt10199590",
        "id_tmdb": 586863,
        "media": "movie",
        "name": "Les Misérables",
        "year": 2019,
    },
}

TEST_DATE = date(2010, 12, 9)

RUSSIAN_LANG = Language.parse("ru")


class E2EResult(NamedTuple):
    code: int
    out: str


class MockRequestResponse:
    def __init__(self, status: int, content: str) -> None:
        self.status_code = status
        self.content = content

    def json(self) -> Dict[str, Any]:
        from json import loads
Пример #2
0
def test_language_parse__str(value):
    expected = Language("English", "en", "eng")
    actual = Language.parse(value)
    assert actual == expected
Пример #3
0
 def _parse(self, file_path: PurePath):
     path_data = {}
     options = {"type": self._settings.media}
     raw_data = dict(guessit(str(file_path), options))
     if isinstance(raw_data.get("season"), list):
         raw_data = dict(guessit(str(file_path.parts[-1]), options))
     for k, v in raw_data.items():
         if hasattr(v, "alpha3"):
             try:
                 path_data[k] = Language.parse(v)
             except MnamerException:
                 continue
         elif isinstance(v, (int, str, date)):
             path_data[k] = v
         elif isinstance(v, list) and all(
             [isinstance(_, (int, str)) for _ in v]
         ):
             path_data[k] = v[0]
     if self._settings.media:
         media_type = self._settings.media
     elif path_data.get("type"):
         media_type = MediaType(path_data["type"])
     else:
         media_type = None
     meta_cls = {
         MediaType.EPISODE: MetadataEpisode,
         MediaType.MOVIE: MetadataMovie,
         None: Metadata,
     }[media_type]
     self.metadata = meta_cls(language=self._settings.language)
     self.metadata.quality = (
         " ".join(
             path_data[key]
             for key in path_data
             if key
             in (
                 "audio_codec",
                 "audio_profile",
                 "screen_size",
                 "source",
                 "video_codec",
                 "video_profile",
             )
         )
         or None
     )
     self.metadata.group = path_data.get("release_group")
     self.metadata.container = file_path.suffix or None
     if not self.metadata.language:
         try:
             self.metadata.language = path_data.get("language")
         except MnamerException:
             pass
     try:
         self.metadata.language_sub = path_data.get("subtitle_language")
     except MnamerException:
         pass
     if self.metadata.media is MediaType.MOVIE:
         self.metadata.name = path_data.get("title")
         self.metadata.year = path_data.get("year")
     elif self.metadata.media is MediaType.EPISODE:
         self.metadata.date = path_data.get("date")
         self.metadata.episode = path_data.get("episode")
         self.metadata.season = path_data.get("season")
         self.metadata.series = path_data.get("title")
         alternative_title = path_data.get("alternative_title")
         if alternative_title:
             self.metadata.series = (
                 f"{self.metadata.series} {alternative_title}"
             )
Пример #4
0
def test_language_parse__bl():
    expected = Language("English", "en", "eng")
    actual = Language.parse(BabelLang("eng"))
    assert actual == expected