[batoto] improve v2 manga URL pattern
and add tests
This commit is contained in:
@@ -11,7 +11,7 @@ from .. import text, exception
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
BASE_PATTERN = (r"(?:https?://)?"
|
BASE_PATTERN = (r"(?:https?://)?"
|
||||||
r"(?:(?:ba|d|w)to\.to|\.to|(?:batotoo|mangatoto)\.com)")
|
r"(?:(?:ba|d|w)to\.to|(?:batotoo|mangatoto)\.com)")
|
||||||
|
|
||||||
|
|
||||||
class BatotoBase():
|
class BatotoBase():
|
||||||
@@ -76,12 +76,13 @@ class BatotoMangaExtractor(BatotoBase, MangaExtractor):
|
|||||||
"""Extractor for bato.to manga"""
|
"""Extractor for bato.to manga"""
|
||||||
reverse = False
|
reverse = False
|
||||||
chapterclass = BatotoChapterExtractor
|
chapterclass = BatotoChapterExtractor
|
||||||
pattern = BASE_PATTERN + r"/(?:title|series)/(\d+)[^/?#]*/?$"
|
pattern = (BASE_PATTERN +
|
||||||
|
r"/(?:title/(\d+)[^/?#]*|series/(\d+)(?:/[^/?#]*)?)/?$")
|
||||||
example = "https://bato.to/title/12345-MANGA/"
|
example = "https://bato.to/title/12345-MANGA/"
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
self.root = text.root_from_url(match.group(0))
|
self.root = text.root_from_url(match.group(0))
|
||||||
self.manga_id = match.group(1)
|
self.manga_id = match.group(1) or match.group(2)
|
||||||
url = "{}/title/{}".format(self.root, self.manga_id)
|
url = "{}/title/{}".format(self.root, self.manga_id)
|
||||||
MangaExtractor.__init__(self, match, url)
|
MangaExtractor.__init__(self, match, url)
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,21 @@ __tests__ = (
|
|||||||
"#class" : batoto.BatotoChapterExtractor,
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
"#count" : 66,
|
"#count" : 66,
|
||||||
|
|
||||||
"manga" : "I Shall Master this Family! [Official]",
|
|
||||||
"title" : "Observing",
|
|
||||||
"chapter" : 8,
|
"chapter" : 8,
|
||||||
|
"chapter_id" : 1681030,
|
||||||
|
"chapter_minor": "",
|
||||||
|
"count" : 66,
|
||||||
|
"date" : "dt:2021-05-15 18:51:37",
|
||||||
|
"extension" : "webp",
|
||||||
|
"filename" : str,
|
||||||
|
"manga" : "I Shall Master this Family! [Official]",
|
||||||
|
"manga_id" : 86408,
|
||||||
|
"page" : range(1, 66),
|
||||||
|
"title" : "Observing",
|
||||||
|
"volume" : 0,
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://bato.to/title/104929-86-eighty-six-official/1943513-vol_1-ch_5",
|
"#url" : "https://bato.to/title/104929-86-eighty-six-official/1943513-vol_1-ch_5",
|
||||||
"#comment" : "volume (vol) in url",
|
"#comment" : "volume (vol) in url",
|
||||||
@@ -25,19 +36,25 @@ __tests__ = (
|
|||||||
"#class" : batoto.BatotoChapterExtractor,
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
"#count" : 7,
|
"#count" : 7,
|
||||||
|
|
||||||
"manga" : "86--EIGHTY-SIX (Official)",
|
"manga" : "86--EIGHTY-SIX (Official)",
|
||||||
"title" : "The Spearhead Squadron's Power",
|
"title" : "The Spearhead Squadron's Power",
|
||||||
"volume" : 1,
|
"volume" : 1,
|
||||||
"chapter" : 5,
|
"chapter": 5,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://bato.to/title/113742-futsutsuka-na-akujo-de-wa-gozaimasu-ga-suuguu-chouso-torikae-den-official",
|
"#url" : "https://bato.to/title/113742-futsutsuka-na-akujo-de-wa-gozaimasu-ga-suuguu-chouso-torikae-den-official",
|
||||||
"#category": ("", "batoto", "manga"),
|
"#category": ("", "batoto", "manga"),
|
||||||
"#class" : batoto.BatotoMangaExtractor,
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
"#count" : ">= 21",
|
"#count" : ">= 21",
|
||||||
|
|
||||||
|
"chapter" : int,
|
||||||
|
"chapter_minor": str,
|
||||||
|
"date" : "type:datetime",
|
||||||
"manga" : "Futsutsuka na Akujo de wa Gozaimasu ga - Suuguu Chouso Torikae Den (Official)",
|
"manga" : "Futsutsuka na Akujo de wa Gozaimasu ga - Suuguu Chouso Torikae Den (Official)",
|
||||||
|
"manga_id" : 113742,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://bato.to/title/104929-86-eighty-six-official",
|
"#url" : "https://bato.to/title/104929-86-eighty-six-official",
|
||||||
"#comment" : "Manga with number in name",
|
"#comment" : "Manga with number in name",
|
||||||
@@ -45,8 +62,9 @@ __tests__ = (
|
|||||||
"#class" : batoto.BatotoMangaExtractor,
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
"#count" : ">= 18",
|
"#count" : ">= 18",
|
||||||
|
|
||||||
"manga" : "86--EIGHTY-SIX (Official)",
|
"manga": "86--EIGHTY-SIX (Official)",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://bato.to/title/140046-the-grand-duke-s-fox-princess-mgchan",
|
"#url" : "https://bato.to/title/140046-the-grand-duke-s-fox-princess-mgchan",
|
||||||
"#comment" : "Non-English translation (Indonesian)",
|
"#comment" : "Non-English translation (Indonesian)",
|
||||||
@@ -54,12 +72,63 @@ __tests__ = (
|
|||||||
"#class" : batoto.BatotoMangaExtractor,
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
"#count" : ">= 29",
|
"#count" : ">= 29",
|
||||||
|
|
||||||
"manga" : "The Grand Duke’s Fox Princess ⎝⎝MGCHAN⎠⎠",
|
"manga": "The Grand Duke’s Fox Princess ⎝⎝MGCHAN⎠⎠",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"#url" : "https://bato.to/title/134270-removed",
|
"#url" : "https://bato.to/title/134270-removed",
|
||||||
|
"#comment" : "Deleted/removed manga",
|
||||||
"#category": ("", "batoto", "manga"),
|
"#category": ("", "batoto", "manga"),
|
||||||
"#class" : batoto.BatotoMangaExtractor,
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
"#exception": exception.StopExtraction,
|
"#exception": exception.StopExtraction,
|
||||||
}
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://bato.to/title/86408/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://bato.to/chapter/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://dto.to/title/86408/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://wto.to/title/86408/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://batotoo.com/title/86408/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://mangatoto.com/title/86408/1681030",
|
||||||
|
"#category": ("", "batoto", "chapter"),
|
||||||
|
"#class" : batoto.BatotoChapterExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://bato.to/title/86408-i-shall-master-this-family-official",
|
||||||
|
"#category": ("", "batoto", "manga"),
|
||||||
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"#url" : "https://bato.to/series/86408/i-shall-master-this-family-official",
|
||||||
|
"#category": ("", "batoto", "manga"),
|
||||||
|
"#class" : batoto.BatotoMangaExtractor,
|
||||||
|
},
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user