1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 19:22:32 +01:00
gallery-dl/gallery_dl/extractor/ngomik.py
Mike Fährmann 5530871b5a
change results of text.nameext_from_url()
Instead of getting a complete 'filename' from an URL and splitting that
into 'name' and 'extension', the new approach gets rid of the complete
version and renames 'name' to 'filename'. (Using anything other than
{extension} for a filename extension doesn't really work anyway)

Example: "https://example.org/path/filename.ext"

before:
- filename : filename.ext
- name     : filename
- extension: ext

now:
- filename : filename
- extension: ext
2019-02-14 16:07:17 +01:00

46 lines
1.5 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2018-2019 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 manga-chapters and entire manga from http://ngomik.in/"""
from .common import ChapterExtractor
from .. import text
class NgomikChapterExtractor(ChapterExtractor):
"""Extractor for manga-chapters from ngomik.in"""
category = "ngomik"
root = "http://ngomik.in"
pattern = (r"(?:https?://)?(?:www\.)?ngomik\.in"
r"(/[^/?&#]+-chapter-[^/?&#]+)")
test = ("https://www.ngomik.in/14-sai-no-koi-chapter-1-6/", {
"url": "8e67fdf751bbc79bc6f4dead7675008ddb8e32a4",
"keyword": "204d177f09d438fd50c9c28d98c73289194640d8",
})
def metadata(self, page):
info = text.extract(page, '<title>', "</title>")[0]
manga, _, chapter = info.partition(" Chapter ")
chapter, sep, minor = chapter.partition(" ")[0].partition(".")
return {
"manga": text.unescape(manga),
"chapter": text.parse_int(chapter),
"chapter_minor": sep + minor,
"lang": "id",
"language": "Indonesian",
}
@staticmethod
def images(page):
readerarea = text.extract(page, 'id="readerarea"', 'class="chnav"')[0]
return [
(text.unescape(url), None)
for url in text.extract_iter(readerarea, ' src="', '"')
]