Skip to content

Commit

Permalink
fix get_videos
Browse files Browse the repository at this point in the history
  • Loading branch information
nichind committed Nov 30, 2024
1 parent a87f5f3 commit 2eaf4e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions moe_parsers/providers/aniboom.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def get_video(self, translation_id: int | str = "1") -> MPDPlaylist:
return content

async def get_videos(self) -> List[dict]:
for translation in self.translations if self.translations else (await self.parser.get_translations(self.anime_id)):
for translation in await self.parser.get_translations(self.anime_id):
try:
await self.get_video(translation_id=translation["translation_id"])
except Exception as exc:
Expand Down Expand Up @@ -98,7 +98,7 @@ async def get_videos(self) -> List[dict]:
Returns:
List[dict]: List of videos for each episode
"""
for episode in self.episodes if self.episodes else await self.get_episodes():
for episode in self.episodes if (self.episodes and isinstance(self.episodes[0], AniboomEpisode)) else await self.get_episodes():
try:
await episode.get_videos()
except Exception:
Expand Down
13 changes: 12 additions & 1 deletion tests/unit/test_aniboom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async def test_aniboom_get_info():
)
assert data["animego_id"] == "2595"
assert data["status"] == 'Вышел'
assert len(data['translations']) >= 1


@pytest.mark.asyncio
Expand All @@ -28,6 +29,16 @@ async def test_aniboom_get_episodes():
)
assert len(episodes) == 13
assert isinstance(episodes[0], AniboomEpisode)


@pytest.mark.asyncio
async def test_aniboom_get_episode_videos():
parser = AniboomParser()
anime = (await parser.search("plastic memories"))[0]
await anime.get_info()
videos = await anime.get_videos()
assert isinstance(videos[0][0], dict)
assert len(videos[0]) >= 1


@pytest.mark.asyncio
Expand All @@ -50,5 +61,5 @@ async def test_aniboom_get_shikimori_id():
await AniboomAnime().get_shikimori_id(
"https://animego.org/anime/plastikovye-vospominaniya-2318"
)
== "27775"
== " "
)

0 comments on commit 2eaf4e4

Please sign in to comment.