From 762ad7426a068d9a73fe1f81c00a3579101770af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 15 Apr 2015 17:35:30 +0200 Subject: [PATCH] add extractor 'yandere' --- gallery_dl/extractor/booru.py | 6 +++++- gallery_dl/extractor/yandere.py | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gallery_dl/extractor/yandere.py diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py index 1684531a..ce6b0326 100644 --- a/gallery_dl/extractor/booru.py +++ b/gallery_dl/extractor/booru.py @@ -13,6 +13,7 @@ from .common import Message from .common import filename_from_url import xml.etree.ElementTree as ET import json +import os.path import urllib.parse @@ -55,7 +56,10 @@ class BooruExtractor(SequentialExtractor): def get_file_metadata(self, data): """Collect metadata for a downloadable file""" data["category"] = self.info["category"] - data["name"] = filename_from_url(self.get_file_url(data)) + data["name"] = urllib.parse.unquote( + filename_from_url(self.get_file_url(data)) + ) + data["extension"] = os.path.splitext(data["name"])[1][1:] return data def get_file_url(self, data): diff --git a/gallery_dl/extractor/yandere.py b/gallery_dl/extractor/yandere.py new file mode 100644 index 00000000..2e574b11 --- /dev/null +++ b/gallery_dl/extractor/yandere.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +# Copyright 2015 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 image-urls from https://yande.re/""" + +from .booru import JSONBooruExtractor + +info = { + "category": "yandere", + "extractor": "YandereExtractor", + "directory": ["{category}", "{tags}"], + "filename": "{category}_{md5}.{extension}", + "pattern": [ + r"(?:https?://)?(?:www\.)?yande\.re/post\?tags=([^&]+).*", + ], +} + +class YandereExtractor(JSONBooruExtractor): + + def __init__(self, match, config): + JSONBooruExtractor.__init__(self, match, config, info) + self.api_url = "https://yande.re/post.json"