Skip to content

Commit

Permalink
feat(source): add genre detection for webtoons
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoeggy committed Oct 6, 2022
1 parent aca07c4 commit d8fb07f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion mandown/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def init_metadata(
),
) -> None:
"""
Initialise a folder with metadata to be converted with Mandown, optionally fetching metadata from an internet source.
Initialise a folder with metadata to be converted with Mandown, optionally
fetching metadata from an internet source.
"""
if (path / MD_METADATA_FILE).is_file():
return typer.echo(
Expand Down
10 changes: 6 additions & 4 deletions mandown/sources/source_webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
# pylint: disable=invalid-name


import re

import feedparser
Expand Down Expand Up @@ -35,20 +36,21 @@ def fetch_metadata(self) -> BaseMetadata:
feed = feedparser.parse(
f"https://www.webtoons.com/{self._title_path}/rss?title_no={self._title_no}"
)
feed = feedparser.parse(
f"https://www.webtoons.com/{self._title_path}/rss?title_no={self._title_no}"
)

page = self._get_soup()

authors: list[str] = feed["entries"][0].author.split("/")
authors = [s.strip() for s in authors]
title: str = feed["channel"]["title"]
cover_art: str = feed["channel"]["image"]["href"]
description: str = feed["channel"]["description"].strip()
genre: str = page.select_one(".genre").text

return BaseMetadata(
title,
authors,
f"https://www.webtoons.com/{self._title_path}/list?title_no={self._title_no}",
[], # TODO: webtoons does have genres but they have to be scraped
[genre],
description,
cover_art,
)
Expand Down

0 comments on commit d8fb07f

Please sign in to comment.