Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: chapter extraction (toonily) (#41)

NTFSvolume250a48bbaa38
diff --git a/cyberdrop_dl/crawlers/toonily.py b/cyberdrop_dl/crawlers/toonily.py
index a35800aa7..a82d6600f 100644
--- a/cyberdrop_dl/crawlers/toonily.py
+++ b/cyberdrop_dl/crawlers/toonily.py
@@ -12,7 +12,7 @@ class Selector:
CHAPTER = ".wp-manga-chapter a"
IMAGE = ".reading-content .page-break.no-gaps img"
SERIES_TITLE = ".post-title > h1"
- CHAPTER_TITLE = "#chapter-heading"
+ NAV_BREADCUMBS = ".wp-manga-nav .breadcrumb li"
class ToonilyCrawler(Crawler):
@@ -26,14 +26,12 @@ class ToonilyCrawler(Crawler):
async def fetch(self, scrape_item: ScrapeItem) -> None:
match scrape_item.url.parts[1:]:
- case ["serie", _, *rest]:
- match rest:
- case []:
- return await self.series(scrape_item)
- case [chapter] if chapter.startswith("chapter-"):
- return await self.chapter(scrape_item)
-
- raise ValueError
+ case ["serie", _]:
+ return await self.series(scrape_item)
+ case ["serie", _, chapter] if chapter.startswith("chapter-"):
+ return await self.chapter(scrape_item)
+ case _:
+ raise ValueError
@error_handling_wrapper
async def series(self, scrape_item: ScrapeItem) -> None:
@@ -50,7 +48,8 @@ class ToonilyCrawler(Crawler):
async def chapter(self, scrape_item: ScrapeItem) -> None:
soup = await self.request_soup(scrape_item.url, impersonate=True)
- series_name, chapter_title = css.select_text(soup, Selector.CHAPTER_TITLE).split(" - ", 1)
+ *_, series_name, chapter_title = (css.text(bc) for bc in soup.select(Selector.NAV_BREADCUMBS))
+
if scrape_item.type != FILE_HOST_PROFILE:
series_title = self.create_title(series_name)
scrape_item.add_to_parent_title(series_title)
diff --git a/tests/crawlers/test_cases/toonily.py b/tests/crawlers/test_cases/toonily.py
index 85a96f6ba..20da8743b 100644
--- a/tests/crawlers/test_cases/toonily.py
+++ b/tests/crawlers/test_cases/toonily.py
@@ -4,28 +4,40 @@ TEST_CASES = [
"https://toonily.com/serie/black-crow/",
[
{
- "url": "https://cdn.toonily.com/chapters/manga_66d8f7bfa8ed9/03ae6f538b989573c121b28f7af4f38a/01.jpg",
+ "url": "https://data.tnlycdn.com/chapters/manga_66d8f7bfa8ed9/03ae6f538b989573c121b28f7af4f38a/01.jpg",
"filename": "01.jpg",
- "referer": "https://toonily.com/serie/black-crow/chapter-1",
+ "referer": "https://toonily.com/serie/black-crow-6780cc7a/chapter-1",
"album_id": None,
"datetime": 1725498328,
- "download_folder": r"re:Black Crow \(Toonily\)/Chapter 1",
+ "download_folder": r"re:Black Crow (Toonily)/Chapter 1",
}
],
1634,
),
(
- "https://toonily.com/serie/black-crow/chapter-1/",
+ "https://toonily.com/serie/black-crow-6780cc7a/chapter-1/",
[
{
- "url": "https://cdn.toonily.com/chapters/manga_66d8f7bfa8ed9/03ae6f538b989573c121b28f7af4f38a/01.jpg",
+ "url": "https://data.tnlycdn.com/chapters/manga_66d8f7bfa8ed9/03ae6f538b989573c121b28f7af4f38a/01.jpg",
"filename": "01.jpg",
- "referer": "https://toonily.com/serie/black-crow/chapter-1",
+ "referer": "https://toonily.com/serie/black-crow-6780cc7a/chapter-1",
"album_id": None,
"datetime": 1725498328,
- "download_folder": r"re:Black Crow \(Toonily\)/Chapter 1",
+ "download_folder": r"re:Black Crow (Toonily)/Chapter 1",
}
],
50,
),
+ (
+ "https://toonily.com/serie/glorious-homecoming-440a49b5/chapter-6/",
+ [
+ {
+ "url": "ANY",
+ "referer": "https://toonily.com/serie/glorious-homecoming-440a49b5/chapter-6",
+ "album_id": None,
+ "download_folder": r"re:Glorious Homecoming (Toonily)/Chapter 6",
+ }
+ ],
+ 13,
+ ),
]