From 2b15b8167310dec051f433a6ca9fcd2de9b4763e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 20 Apr 2016 08:34:44 +0200 Subject: [PATCH] [khinsider] add extractor --- gallery_dl/extractor/__init__.py | 1 + gallery_dl/extractor/khinsider.py | 52 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 gallery_dl/extractor/khinsider.py diff --git a/gallery_dl/extractor/__init__.py b/gallery_dl/extractor/__init__.py index 0b9a311d..14bf28bf 100644 --- a/gallery_dl/extractor/__init__.py +++ b/gallery_dl/extractor/__init__.py @@ -32,6 +32,7 @@ modules = [ "imgchili", "imgth", "imgur", + "khinsider", "kissmanga", "konachan", "mangahere", diff --git a/gallery_dl/extractor/khinsider.py b/gallery_dl/extractor/khinsider.py new file mode 100644 index 00000000..acf6e8be --- /dev/null +++ b/gallery_dl/extractor/khinsider.py @@ -0,0 +1,52 @@ +# -*- 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 https://nijie.info/""" + +from .common import AsynchronousExtractor, Message +from .. import text + +class KhinsiderExtractor(AsynchronousExtractor): + + category = "khinsider" + directory_fmt = ["{category}", "{album}"] + filename_fmt = "{filename}" + pattern = [r"(?:https?://)?downloads\.khinsider\.com/game-soundtracks/album/(.+)"] + + def __init__(self, match): + AsynchronousExtractor.__init__(self) + self.album = match.group(1) + + def items(self): + url = "http://downloads.khinsider.com/game-soundtracks/album/" + self.album + page = self.request(url).text + data = self.get_job_metadata(page) + yield Message.Version, 1 + yield Message.Directory, data + for url, track in self.get_album_tracks(page): + track.update(data) + yield Message.Url, url, track + + def get_job_metadata(self, page): + return text.extract_all(page, ( + ("album", "Album name: ", ""), + ("count", "Number of Files: ", ""), + ("size" , "Total Filesize: ", ""), + ("date" , "Date added: ", ""), + ("type" , "Album type: ", ""), + ), values={"category": self.category})[0] + + def get_album_tracks(self, page): + pos = page.index("Download all songs at once:") + num = 0 + for url in text.extract_iter(page, '\r\n\t\t", "") + url , pos = text.extract(page, '