Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,6 @@ Consider all listed sites to potentially be NSFW.
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr>
<td>MangaRead</td>
<td>https://mangaread.org/</td>
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr>
<td>Mangoxo</td>
<td>https://www.mangoxo.com/</td>
Expand Down Expand Up @@ -1875,5 +1869,27 @@ Consider all listed sites to potentially be NSFW.
<td>Albums</td>
<td></td>
</tr>

<tr>
<td colspan="4"><strong>WordPressMadara based websites</strong></td>
</tr>
<tr>
<td>MangaRead</td>
<td>https://mangaread.org/</td>
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr>
<td>Toonily</td>
<td>https://toonily.com/</td>
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr>
<td>WebtoonXYZ</td>
<td>https://www.webtoon.xyz/</td>
<td>Chapters, Manga</td>
<td></td>
</tr>
</tbody>
</table>
2 changes: 1 addition & 1 deletion gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"mangahere",
"manganelo",
"mangapark",
"mangaread",
"wpmadara",
"mangoxo",
"misskey",
"motherless",
Expand Down
16 changes: 16 additions & 0 deletions gallery_dl/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ class Extractor():
request_timestamp = 0.0

def __init__(self, match):
self.log = logging.getLogger(self.category)
self.url = match.string
self._cfgpath = ("extractor", self.category, self.subcategory)
self._parentdir = ""
"""
Initialize the CommonExtractor object.

Args:
match (re.Match): The regular expression match object.

Attributes:
log (logging.Logger): The logger object for logging messages.
url (str): The URL string.
_cfgpath (tuple): The configuration path.
_parentdir (str): The parent directory.
"""
self.log = logging.getLogger(self.category)
self.url = match.string
self.match = match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""Extractors for https://mangaread.org/"""
"""Extractors for WordPressMadara based websites."""

from .common import ChapterExtractor, MangaExtractor
from .. import text, util, exception
from .common import BaseExtractor, ChapterExtractor, MangaExtractor
from .. import text, exception
import re


class MangareadBase():
"""Base class for Mangaread extractors"""
category = "mangaread"
class WPMadaraBase(BaseExtractor):
"""Base class for WordPressMadara based extractors"""
basecategory = "wpmadara"
root = "https://www.mangaread.org"

@staticmethod
Expand All @@ -30,36 +31,69 @@ def parse_chapter_string(chapter_string, data):
data["language"] = "English"


class MangareadChapterExtractor(MangareadBase, ChapterExtractor):
"""Extractor for manga-chapters from mangaread.org"""
pattern = (r"(?:https?://)?(?:www\.)?mangaread\.org"
r"(/manga/[^/?#]+/[^/?#]+)")
BASE_PATTERN = WPMadaraBase.update({
"mangaread": {
"root": "https://www.mangaread.org",
"pattern": r"(?:https?://)?(?:www\.)?mangaread\.org",
},
"toonily": {
"root": "https://www.toonily.com",
"pattern": r"(?:https?://)?(?:www\.)?toonily\.com",
},
"webtoonxyz": {
"root": "https://www.webtoon.xyz",
"pattern": r"(?:https?://)?(?:www\.)?webtoon\.xyz",
},
})


class WPMadaraChapterExtractor(WPMadaraBase, ChapterExtractor):
"""Extractor for manga-chapters from WordPressMadara based websites."""
subcategory = "chapter"
pattern = BASE_PATTERN + r"(/(manga|webtoon|read)/[^/?#]+/[^/?#]+)"
example = "https://www.mangaread.org/manga/MANGA/chapter-01/"

def __init__(self, match, url=None):
WPMadaraBase.__init__(self, match)
self.chapter = match.group(match.lastindex)
self.log.debug("chapter: %s", self.chapter)
self.gallery_url = self.root + match.group(match.lastindex)

if self.config("chapter-reverse", False):
self.reverse = not self.reverse

def metadata(self, page):
tags = text.extr(page, 'class="wp-manga-tags-list">', '</div>')
data = {"tags": list(text.split_html(tags)[::2])}
info = text.extr(page, '<h1 id="chapter-heading">', "</h1>")
if not info:
raise exception.NotFoundError("chapter")
self.parse_chapter_string(info, data)
self.log.debug("data: %s", data)
return data

def images(self, page):
page = text.extr(
page, '<div class="reading-content">', '<div class="entry-header')
self.log.debug("page: %s", page)
return [
(text.extr(img, 'src="', '"').strip(), None)
for img in text.extract_iter(page, '<img id="image-', '>')
]


class MangareadMangaExtractor(MangareadBase, MangaExtractor):
"""Extractor for manga from mangaread.org"""
chapterclass = MangareadChapterExtractor
pattern = r"(?:https?://)?(?:www\.)?mangaread\.org(/manga/[^/?#]+)/?$"
class WPMadaraMangaExtractor(WPMadaraBase, MangaExtractor):
"""Extractor for manga from WordPressMadara based websites."""
chapterclass = WPMadaraChapterExtractor
subcategory = "manga"
pattern = BASE_PATTERN + r"(/(manga|webtoon|read)/[^/?#]+)/?$"
example = "https://www.mangaread.org/manga/MANGA"

def __init__(self, match, url=None):
WPMadaraBase.__init__(self, match)
self.manga = match.group(match.lastindex)
self.manga_url = url or self.root + match.group(match.lastindex)

def chapters(self, page):
if 'class="error404' in page:
raise exception.NotFoundError("manga")
Expand All @@ -76,12 +110,24 @@ def chapters(self, page):
def metadata(self, page):
extr = text.extract_from(text.extr(
page, 'class="summary_content">', 'class="manga-action"'))
# rating = 0.0
if len(text.extr(page, 'total_votes">', "</span>").strip()) > 0:
rating = text.parse_float(text.extr(
page, 'total_votes">', "</span>").strip())
elif len(text.extr(page, 'property="ratingValue" id="averagerate">',
"</span>").strip()) > 0:
rating = text.parse_float(
text.extr(page,
'property="ratingValue" id="averagerate">',
"</span>").strip())
else:
rating = 0.0

return {
"manga" : text.extr(page, "<h1>", "</h1>").strip(),
"description": text.unescape(text.remove_html(text.extract(
page, ">", "</div>", page.index("summary__content"))[0])),
"rating" : text.parse_float(
extr('total_votes">', "</span>").strip()),
"rating" : rating,
"manga_alt" : text.remove_html(
extr("Alternative\t\t</h5>\n\t</div>", "</div>")).split("; "),
"author" : list(text.extract_iter(
Expand Down
28 changes: 14 additions & 14 deletions test/results/mangaread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

from gallery_dl.extractor import mangaread
from gallery_dl.extractor import wpmadara
from gallery_dl import exception


__tests__ = (
{
"#url" : "https://www.mangaread.org/manga/one-piece/chapter-1053-3/",
"#category": ("", "mangaread", "chapter"),
"#class" : mangaread.MangareadChapterExtractor,
"#category": ("wpmadara", "mangaread", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#pattern" : r"https://www\.mangaread\.org/wp-content/uploads/WP-manga/data/manga_[^/]+/[^/]+/[^.]+\.\w+",
"#count" : 11,

Expand All @@ -27,15 +27,15 @@

{
"#url" : "https://www.mangaread.org/manga/one-piece/chapter-1000000/",
"#category": ("", "mangaread", "chapter"),
"#class" : mangaread.MangareadChapterExtractor,
"#category": ("wpmadara", "mangaread", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#exception": exception.NotFoundError,
},

{
"#url" : "https://www.mangaread.org/manga/kanan-sama-wa-akumade-choroi/chapter-10/",
"#category": ("", "mangaread", "chapter"),
"#class" : mangaread.MangareadChapterExtractor,
"#category": ("wpmadara", "mangaread", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#pattern" : r"https://www\.mangaread\.org/wp-content/uploads/WP-manga/data/manga_[^/]+/[^/]+/[^.]+\.\w+",
"#count" : 9,

Expand All @@ -51,8 +51,8 @@
{
"#url" : "https://www.mangaread.org/manga/above-all-gods/chapter146-5/",
"#comment" : "^^ no whitespace",
"#category": ("", "mangaread", "chapter"),
"#class" : mangaread.MangareadChapterExtractor,
"#category": ("wpmadara", "mangaread", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#pattern" : r"https://www\.mangaread\.org/wp-content/uploads/WP-manga/data/manga_[^/]+/[^/]+/[^.]+\.\w+",
"#count" : 6,

Expand All @@ -67,8 +67,8 @@

{
"#url" : "https://www.mangaread.org/manga/kanan-sama-wa-akumade-choroi",
"#category": ("", "mangaread", "manga"),
"#class" : mangaread.MangareadMangaExtractor,
"#category": ("wpmadara", "mangaread", "manga"),
"#class" : wpmadara.WPMadaraMangaExtractor,
"#pattern" : r"https://www\.mangaread\.org/manga/kanan-sama-wa-akumade-choroi/chapter-\d+([_-].+)?/",
"#count" : ">= 13",

Expand All @@ -93,8 +93,8 @@

{
"#url" : "https://www.mangaread.org/manga/one-piece",
"#category": ("", "mangaread", "manga"),
"#class" : mangaread.MangareadMangaExtractor,
"#category": ("wpmadara", "mangaread", "manga"),
"#class" : wpmadara.WPMadaraMangaExtractor,
"#pattern" : r"https://www\.mangaread\.org/manga/one-piece/chapter-\d+(-.+)?/",
"#count" : ">= 1066",

Expand All @@ -115,7 +115,7 @@
{
"#url" : "https://www.mangaread.org/manga/doesnotexist",
"#category": ("", "mangaread", "manga"),
"#class" : mangaread.MangareadMangaExtractor,
"#class" : wordpressmadara.MangareadMangaExtractor,
"#exception": exception.NotFoundError,
},

Expand Down
64 changes: 64 additions & 0 deletions test/results/toonily.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

from gallery_dl.extractor import wpmadara
from gallery_dl import exception


__tests__ = (
{
"#url" : "https://toonily.com/webtoon/such-a-cute-spy/chapter-36/",
"#category": ("wpmadara", "toonily", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#pattern" : r"https://toonily\.com/wp-content/uploads/WP-manga/data/manga_[^/]+/[^/]+/[^.]+\.\w+",
"#count" : 11,

"manga" : "Jinxed",
"title" : "",
"chapter" : 36,
"tags" : ["harem"],
"lang" : "en",
"language" : "English",
},

{
"#url" : "https://toonily.com/webtoon/such-a-cute-spy/chapter-1000000/",
"#category": ("wpmadara", "toonily", "chapter"),
"#class" : wpmadara.WPMadaraChapterExtractor,
"#exception": exception.NotFoundError,
},

{
"#url" : "https://toonily.com/webtoon/such-a-cute-spy",
"#category": ("wpmadara", "toonily", "manga"),
"#class" : wpmadara.WPMadaraMangaExtractor,
"#pattern" : r"https://toonily\.com/webtoon/such-a-cute-spy/chapter-\d+([_-].+)?/",
"#count" : ">= 13",

"manga" : "Such a Cute Spy",
"author" : ["Life of Ruin"],
"artist" : ["Ganghyeon Yeo"],
"genres" : [
"Action",
"Comedy",
"Romance",
"School Life",
],
"rating" : float,
"status" : "End",
"lang" : "en",
"language" : "English",
"manga_alt" : list,
},

{
"#url" : "https://toonily.com/webtoon/doesnotexist",
"#category": ("wpmadara", "toonily", "manga"),
"#class" : wpmadara.WPMadaraMangaExtractor,
"#exception": exception.HttpError,
},

)
Loading