From 5adbfe526d60baaf4eb24941270efd77f6b37388 Mon Sep 17 00:00:00 2001 From: enduser420 <91022934+enduser420@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:29:11 +0530 Subject: [PATCH] [tcbscans] support other domains --- gallery_dl/extractor/tcbscans.py | 19 +++++++++++++------ test/results/tcbscans.py | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/gallery_dl/extractor/tcbscans.py b/gallery_dl/extractor/tcbscans.py index de6f3ee9..71431ada 100644 --- a/gallery_dl/extractor/tcbscans.py +++ b/gallery_dl/extractor/tcbscans.py @@ -4,19 +4,23 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. -"""Extractors for https://tcbscans.com/""" +"""Extractors for https://tcbscans.me/""" from .common import ChapterExtractor, MangaExtractor from .. import text -BASE_PATTERN = r"(?:https?://)?(?:tcbscans|onepiecechapters)\.com" +BASE_PATTERN = (r"(?:https?://)?(?:tcb(?:-backup\.bihar-mirchi|scans)" + r"|onepiecechapters)\.(?:com|me)") class TcbscansChapterExtractor(ChapterExtractor): category = "tcbscans" - root = "https://tcbscans.com" pattern = BASE_PATTERN + r"(/chapters/\d+/[^/?#]+)" - example = "https://tcbscans.com/chapters/12345/MANGA-chapter-123" + example = "https://tcbscans.me/chapters/12345/MANGA-chapter-123" + + def __init__(self, match): + self.root = text.root_from_url(match.group(0)) + ChapterExtractor.__init__(self, match) def images(self, page): return [ @@ -39,10 +43,13 @@ class TcbscansChapterExtractor(ChapterExtractor): class TcbscansMangaExtractor(MangaExtractor): category = "tcbscans" - root = "https://tcbscans.com" chapterclass = TcbscansChapterExtractor pattern = BASE_PATTERN + r"(/mangas/\d+/[^/?#]+)" - example = "https://tcbscans.com/mangas/123/MANGA" + example = "https://tcbscans.me/mangas/123/MANGA" + + def __init__(self, match): + self.root = text.root_from_url(match.group(0)) + MangaExtractor.__init__(self, match) def chapters(self, page): data = { diff --git a/test/results/tcbscans.py b/test/results/tcbscans.py index 1b77a79b..b3d0cb54 100644 --- a/test/results/tcbscans.py +++ b/test/results/tcbscans.py @@ -5,6 +5,7 @@ # published by the Free Software Foundation. from gallery_dl.extractor import tcbscans +from gallery_dl import exception __tests__ = ( @@ -34,12 +35,28 @@ __tests__ = ( "chapter_minor": "", "lang" : "en", "language" : "English", + "#exception" : exception.HttpError, }, { "#url" : "https://onepiecechapters.com/chapters/44/ace-novel-manga-adaptation-chapter-1", "#category": ("", "tcbscans", "chapter"), "#class" : tcbscans.TcbscansChapterExtractor, + "#exception": exception.HttpError, +}, + +{ + "#url" : "https://tcb-backup.bihar-mirchi.com/chapters/7719/jujutsu-kaisen-chapter-258", + "#category": ("", "tcbscans", "chapter"), + "#class" : tcbscans.TcbscansChapterExtractor, + "#pattern" : r"https://cdn\.[^/]+/(file|attachments/[^/]+)/[^/]+/[^.]+\.\w+", + "#count" : 15, + + "manga" : "Jujutsu Kaisen", + "chapter" : 258, + "chapter_minor": "", + "lang" : "en", + "language" : "English", }, { @@ -58,12 +75,20 @@ __tests__ = ( "#pattern" : tcbscans.TcbscansChapterExtractor.pattern, "#range" : "1-50", "#count" : 50, + "#exception": exception.HttpError, }, { "#url" : "https://onepiecechapters.com/mangas/15/hunter-x-hunter", "#category": ("", "tcbscans", "manga"), "#class" : tcbscans.TcbscansMangaExtractor, + "#exception": exception.HttpError, +}, + +{ + "#url" : "https://tcbscans.me/mangas/4/jujutsu-kaisen", + "#category": ("", "tcbscans", "manga"), + "#class" : tcbscans.TcbscansMangaExtractor, }, )