mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-23 03:02:50 +01:00
[doujinmode] add extractor
This commit is contained in:
parent
a2c5b1e07d
commit
25f56c9061
@ -12,8 +12,6 @@ from .. import config
|
|||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
"pixiv",
|
"pixiv",
|
||||||
"exhentai",
|
|
||||||
"gelbooru",
|
|
||||||
"3dbooru",
|
"3dbooru",
|
||||||
"4chan",
|
"4chan",
|
||||||
"8chan",
|
"8chan",
|
||||||
@ -21,7 +19,10 @@ modules = [
|
|||||||
"chronos",
|
"chronos",
|
||||||
"danbooru",
|
"danbooru",
|
||||||
"deviantart",
|
"deviantart",
|
||||||
|
"doujinmode",
|
||||||
"e621",
|
"e621",
|
||||||
|
"exhentai",
|
||||||
|
"gelbooru",
|
||||||
"hbrowse",
|
"hbrowse",
|
||||||
"hentai2read",
|
"hentai2read",
|
||||||
"hentaifoundry",
|
"hentaifoundry",
|
||||||
|
58
gallery_dl/extractor/doujinmode.py
Normal file
58
gallery_dl/extractor/doujinmode.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Copyright 2016 Mike Fährmann
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""Extract images from http://doujinmode.net/"""
|
||||||
|
|
||||||
|
from .common import Extractor, Message
|
||||||
|
from .. import text
|
||||||
|
import re
|
||||||
|
|
||||||
|
class DoujinmodeChapterExtractor(Extractor):
|
||||||
|
|
||||||
|
category = "doujinmode"
|
||||||
|
directory_fmt = ["{category}", "{title}"]
|
||||||
|
filename_fmt = "{num:>03}.{extension}"
|
||||||
|
pattern = [r"(?:https?://)?(?:www\.)?doujinmode\.net/(?:hentai/)?mangas/([0-9a-f]{36})"]
|
||||||
|
url_base = "http://doujinmode.net/mangas/"
|
||||||
|
|
||||||
|
def __init__(self, match):
|
||||||
|
Extractor.__init__(self)
|
||||||
|
self.gid = match.group(1)
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
data = self.get_job_metadata()
|
||||||
|
yield Message.Version, 1
|
||||||
|
yield Message.Directory, data
|
||||||
|
for url, image in self.get_images():
|
||||||
|
data.update(image)
|
||||||
|
yield Message.Url, url, data
|
||||||
|
|
||||||
|
def get_job_metadata(self):
|
||||||
|
"""Collect metadata for extractor-job"""
|
||||||
|
page = self.request(self.url_base + self.gid).text
|
||||||
|
count, pos = text.extract(page, ' class="manga-count">', '</span>')
|
||||||
|
title, pos = text.extract(page, '<h2>', ' Images List</h2>', pos)
|
||||||
|
return {
|
||||||
|
"category": self.category,
|
||||||
|
"gallery-id": self.gid,
|
||||||
|
"title": title,
|
||||||
|
"count": count,
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_images(self):
|
||||||
|
"""Collect a list of all images with url and metadata"""
|
||||||
|
url = self.url_base + "pages_large?manga_uuid=" + self.gid
|
||||||
|
for page in self.request(url).json():
|
||||||
|
pattern = r"(.*/p/([^/]+)/).+(\.(\w+)\?(\d+))"
|
||||||
|
parts = re.match(pattern, page["image_url"]).groups()
|
||||||
|
yield parts[0] + "original" + parts[2], {
|
||||||
|
"num": page["page"],
|
||||||
|
"image-id": parts[1],
|
||||||
|
"extension": parts[3],
|
||||||
|
"timestamp": parts[4],
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user