Skip to content

Commit 93bf4cc

Browse files
committed
merge #8928: [mangafreak] add support
2 parents 7026611 + 4e71e2f commit 93bf4cc

File tree

5 files changed

+188
-0
lines changed

5 files changed

+188
-0
lines changed

docs/supportedsites.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,12 @@ Consider all listed sites to potentially be NSFW.
667667
<td>Chapters, Manga</td>
668668
<td></td>
669669
</tr>
670+
<tr id="mangafreak" title="mangafreak">
671+
<td>MangaFreak</td>
672+
<td>https://ww2.mangafreak.me/</td>
673+
<td>Chapters, Manga</td>
674+
<td></td>
675+
</tr>
670676
<tr id="mangapark" title="mangapark">
671677
<td>MangaPark</td>
672678
<td>https://mangapark.net/</td>

gallery_dl/extractor/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"mangadex",
128128
"mangafire",
129129
"mangafox",
130+
"mangafreak",
130131
"mangahere",
131132
"manganelo",
132133
"mangapark",

gallery_dl/extractor/mangafreak.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License version 2 as
5+
# published by the Free Software Foundation.
6+
7+
"""Extractors for https://ww2.mangafreak.me/"""
8+
9+
from .common import ChapterExtractor, MangaExtractor
10+
from .. import text
11+
12+
BASE_PATTERN = r"(?:https?://)?(?:ww[\dw]\.)?mangafreak\.me"
13+
14+
15+
class MangafreakBase():
16+
"""Base class for mangafreak extractors"""
17+
category = "mangafreak"
18+
root = "https://ww2.mangafreak.me"
19+
20+
21+
class MangafreakChapterExtractor(MangafreakBase, ChapterExtractor):
22+
"""Extractor for mangafreak manga chapters"""
23+
pattern = BASE_PATTERN + r"(/Read1_([^/?#]+)_((\d+)([a-z])?))"
24+
example = "https://ww2.mangafreak.me/Read1_Onepunch_Man_1"
25+
26+
def metadata(self, page):
27+
manga = text.extr(page, "<title>Read ", " Chapter ")
28+
title = text.extr(page, 'selected="selected">', "<").partition(": ")[2]
29+
_, manga_slug, chapter_string, chapter, minor = self.groups
30+
31+
return {
32+
"manga" : text.unescape(manga),
33+
"manga_slug" : manga_slug,
34+
"title" : text.unescape(title) if title else "",
35+
"chapter" : text.parse_int(chapter),
36+
"chapter_minor": "" if minor is None else minor,
37+
"chapter_string": chapter_string,
38+
"lang" : "en",
39+
"language" : "English",
40+
}
41+
42+
def images(self, page):
43+
base = "https://images.mangafreak.me/mangas/"
44+
return [
45+
(base + path, None)
46+
for path in text.extract_iter(page, 'src="' + base, '"')
47+
]
48+
49+
50+
class MangafreakMangaExtractor(MangafreakBase, MangaExtractor):
51+
"""Extractor for mangafreak manga series"""
52+
chapterclass = MangafreakChapterExtractor
53+
pattern = BASE_PATTERN + r"(/Manga/([^/?#]+))"
54+
example = "https://ww2.mangafreak.me/Manga/Onepunch_Man"
55+
56+
def chapters(self, page):
57+
table = text.extr(page, "<table>", "</table>")
58+
if not table:
59+
return ()
60+
61+
data = {
62+
"manga" : text.unescape(text.extr(page, "<title>", " Manga")),
63+
"manga_slug": self.groups[1],
64+
"lang" : "en",
65+
"language" : "English",
66+
}
67+
68+
results = []
69+
chapter_match = text.re(r"(\d+)(\w*)").match
70+
for row in text.extract_iter(table, "<tr>", "</tr>"):
71+
href = text.extr(row, '<a href="', '"')
72+
if not href:
73+
continue
74+
url = self.root + href
75+
chapter_string = href.rpartition("_")[2]
76+
chapter, minor = chapter_match(chapter_string).groups()
77+
title = text.extr(row, '">', '<').partition(" - ")[2]
78+
results.append((url, {
79+
"chapter" : text.parse_int(chapter),
80+
"chapter_minor" : minor,
81+
"chapter_string": chapter_string,
82+
"title" : text.unescape(title) if title else "",
83+
**data,
84+
}))
85+
return results

scripts/supportedsites.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
"kabeuchi" : "かべうち",
116116
"kaliscan" : "KaliScan",
117117
"mangafire" : "MangaFire",
118+
"mangafreak" : "MangaFreak",
118119
"mangareader" : "MangaReader",
119120
"mangataro" : "MangaTaro",
120121
"s3ndpics" : "S3ND",

test/results/mangafreak.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License version 2 as
5+
# published by the Free Software Foundation.
6+
7+
from gallery_dl.extractor import mangafreak
8+
9+
10+
__tests__ = (
11+
{
12+
"#url" : "https://ww2.mangafreak.me/Read1_Onepunch_Man_1",
13+
"#class" : mangafreak.MangafreakChapterExtractor,
14+
"#pattern" : r"https://images\.mangafreak\.me/mangas/onepunch_man/onepunch_man_1/onepunch_man_1_\d+\.jpg",
15+
"#count" : 24,
16+
17+
"chapter" : 1,
18+
"chapter_minor": "",
19+
"chapter_string": "1",
20+
"lang" : "en",
21+
"language" : "English",
22+
"manga" : "Onepunch Man",
23+
"manga_slug" : "Onepunch_Man",
24+
},
25+
26+
{
27+
"#url" : "https://ww2.mangafreak.me/Read1_Onepunch_Man_167e",
28+
"#class" : mangafreak.MangafreakChapterExtractor,
29+
30+
"chapter" : 167,
31+
"chapter_minor": "e",
32+
"chapter_string": "167e",
33+
},
34+
35+
{
36+
"#url" : "https://ww2.mangafreak.me/Read1_Sss_Rank_Dungeon_De_Knife_Ippon_Tewatasare_Tsuihou_Sareta_Shiro_Madoushi_Yggdrasil_No_Noroi_Ni_Yori_Jakuten_De_Aru_Maryoku_Fusoku_Wo_Kokufuku_Shi_Sekai_Saikyou_E_To_Itaru_23c",
37+
"#class" : mangafreak.MangafreakChapterExtractor,
38+
"#pattern" : r"https://images\.mangafreak\.me/mangas/sss_rank_dungeon_de_knife_ippon_tewatasare_tsuihou_sareta_shiro_madoushi_yggdrasil_no_noroi_ni_yori_jakuten_de_aru_maryoku_fusoku_wo_kokufuku_shi_sekai_saikyou_e_to_itaru/sss_rank_dungeon_de_knife_ippon_tewatasare_tsuihou_sareta_shiro_madoushi_yggdrasil_no_noroi_ni_yori_jakuten_de_aru_maryoku_fusoku_wo_kokufuku_shi_sekai_saikyou_e_to_itaru_23c/sss_rank_dungeon_de_knife_ippon_tewatasare_tsuihou_sareta_shiro_madoushi_yggdrasil_no_noroi_ni_yori_jakuten_de_aru_maryoku_fusoku_wo_kokufuku_shi_sekai_saikyou_e_to_itaru_23c_\d+\.jpg",
39+
"#count" : 11,
40+
41+
"chapter" : 23,
42+
"chapter_minor" : "c",
43+
"chapter_string": "23c",
44+
"count" : 11,
45+
"page" : range(1, 11),
46+
"filename" : str,
47+
"extension" : "jpg",
48+
"lang" : "en",
49+
"language" : "English",
50+
"manga" : "Sss Rank Dungeon De Knife Ippon Tewatasare Tsuihou Sareta Shiro Madoushi Yggdrasil No Noroi Ni Yori Jakuten De Aru Maryoku Fusoku Wo Kokufuku Shi Sekai Saikyou E To Itaru",
51+
"manga_slug" : "Sss_Rank_Dungeon_De_Knife_Ippon_Tewatasare_Tsuihou_Sareta_Shiro_Madoushi_Yggdrasil_No_Noroi_Ni_Yori_Jakuten_De_Aru_Maryoku_Fusoku_Wo_Kokufuku_Shi_Sekai_Saikyou_E_To_Itaru",
52+
"title" : "",
53+
},
54+
55+
{
56+
"#url" : "https://ww2.mangafreak.me/Read1_Tensei_Shitara_Slime_Datta_Ken_62",
57+
"#class" : mangafreak.MangafreakChapterExtractor,
58+
"#count" : 19,
59+
60+
"chapter" : 62,
61+
"count" : 19,
62+
"manga" : "Tensei Shitara Slime Datta Ken",
63+
"title" : "To be a Monster or Human",
64+
},
65+
66+
{
67+
"#url" : "https://ww2.mangafreak.me/Manga/Onepunch_Man",
68+
"#class" : mangafreak.MangafreakMangaExtractor,
69+
"#pattern" : mangafreak.MangafreakChapterExtractor.pattern,
70+
"#count" : range(150, 250),
71+
72+
"lang" : "en",
73+
"language" : "English",
74+
"manga" : "Onepunch-Man",
75+
"manga_slug" : "Onepunch_Man",
76+
"chapter" : int,
77+
},
78+
79+
{
80+
"#url" : "https://ww2.mangafreak.me/Manga/Sss_Rank_Dungeon_De_Knife_Ippon_Tewatasare_Tsuihou_Sareta_Shiro_Madoushi_Yggdrasil_No_Noroi_Ni_Yori_Jakuten_De_Aru_Maryoku_Fusoku_Wo_Kokufuku_Shi_Sekai_Saikyou_E_To_Itaru",
81+
"#class" : mangafreak.MangafreakMangaExtractor,
82+
"#pattern" : mangafreak.MangafreakChapterExtractor.pattern,
83+
"#count" : range(40, 80),
84+
85+
"chapter" : int,
86+
"chapter_minor" : {"", "a", "b", "c"},
87+
"chapter_string": str,
88+
"lang" : "en",
89+
"language" : "English",
90+
"manga" : "SSS Rank Dungeon de Knife Ippon Tewatasare Tsuihou Sareta Shiro Madoushi: Yggdrasil no Noroi ni yori Jakuten de aru Maryoku Fusoku wo Kokufuku-shi Sekai Saikyou e to Itaru",
91+
"manga_slug" : "Sss_Rank_Dungeon_De_Knife_Ippon_Tewatasare_Tsuihou_Sareta_Shiro_Madoushi_Yggdrasil_No_Noroi_Ni_Yori_Jakuten_De_Aru_Maryoku_Fusoku_Wo_Kokufuku_Shi_Sekai_Saikyou_E_To_Itaru",
92+
"title" : str,
93+
},
94+
95+
)

0 commit comments

Comments
 (0)