From 3b0fe8f544b59e635ca064447ede275150e96b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 6 Nov 2015 16:48:33 +0100 Subject: [PATCH] unify booru filename-patterns --- gallery_dl/extractor/3dbooru.py | 2 +- gallery_dl/extractor/booru.py | 8 +++++--- gallery_dl/extractor/danbooru.py | 2 +- gallery_dl/extractor/e621.py | 2 +- gallery_dl/extractor/gelbooru.py | 2 +- gallery_dl/extractor/konachan.py | 2 +- gallery_dl/extractor/safebooru.py | 2 +- gallery_dl/extractor/yandere.py | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gallery_dl/extractor/3dbooru.py b/gallery_dl/extractor/3dbooru.py index 665c1e01..c303a6d4 100644 --- a/gallery_dl/extractor/3dbooru.py +++ b/gallery_dl/extractor/3dbooru.py @@ -14,7 +14,7 @@ info = { "category": "3dbooru", "extractor": "ThreeDeeBooruExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{id}_{name}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?behoimi\.org/post(?:/(?:index)?)?\?tags=([^&]+).*", ], diff --git a/gallery_dl/extractor/booru.py b/gallery_dl/extractor/booru.py index 850285cd..d59416b4 100644 --- a/gallery_dl/extractor/booru.py +++ b/gallery_dl/extractor/booru.py @@ -53,16 +53,18 @@ class BooruExtractor(Extractor): """Collect metadata for extractor-job""" return { "category": self.info["category"], - "tags": self.tags.replace("/", "_"), + "tags": self.tags } def get_file_metadata(self, data): """Collect metadata for a downloadable file""" data["category"] = self.info["category"] - data["name"] = text.unquote( + data["filename"] = text.unquote( text.filename_from_url(self.get_file_url(data)) ) - data["extension"] = os.path.splitext(data["name"])[1][1:] + name, ext = os.path.splitext(data["filename"]) + data["name"] = name + data["extension"] = ext[1:] return data def get_file_url(self, data): diff --git a/gallery_dl/extractor/danbooru.py b/gallery_dl/extractor/danbooru.py index 5024020f..47765d21 100644 --- a/gallery_dl/extractor/danbooru.py +++ b/gallery_dl/extractor/danbooru.py @@ -14,7 +14,7 @@ info = { "category": "danbooru", "extractor": "DanbooruExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{name}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?danbooru.donmai.us/posts\?(?:utf8=%E2%9C%93&)?tags=([^&]+).*", ], diff --git a/gallery_dl/extractor/e621.py b/gallery_dl/extractor/e621.py index af4971e8..7b808f44 100644 --- a/gallery_dl/extractor/e621.py +++ b/gallery_dl/extractor/e621.py @@ -14,7 +14,7 @@ info = { "category": "e621", "extractor": "E621Extractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{name}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?e621\.net/post/index/\d+/([^?]+)", r"(?:https?://)?(?:www\.)?e621\.net/post\?tags=([^&]+).*" diff --git a/gallery_dl/extractor/gelbooru.py b/gallery_dl/extractor/gelbooru.py index e5c4f8e7..11a67f0c 100644 --- a/gallery_dl/extractor/gelbooru.py +++ b/gallery_dl/extractor/gelbooru.py @@ -15,7 +15,7 @@ info = { "category": "gelbooru", "extractor": "GelbooruExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{name}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?gelbooru\.com/(?:index\.php)?\?page=post&s=list&tags=([^&]+).*", ], diff --git a/gallery_dl/extractor/konachan.py b/gallery_dl/extractor/konachan.py index 523d28f7..63df2398 100644 --- a/gallery_dl/extractor/konachan.py +++ b/gallery_dl/extractor/konachan.py @@ -14,7 +14,7 @@ info = { "category": "konachan", "extractor": "KonachanExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{md5}.{extension}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?konachan\.com/post\?tags=([^&]+).*", ], diff --git a/gallery_dl/extractor/safebooru.py b/gallery_dl/extractor/safebooru.py index 29ab811d..695fc760 100644 --- a/gallery_dl/extractor/safebooru.py +++ b/gallery_dl/extractor/safebooru.py @@ -14,7 +14,7 @@ info = { "category": "safebooru", "extractor": "SafebooruExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{name}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?safebooru\.org/(?:index\.php)?\?page=post&s=list&tags=([^&]+).*", ], diff --git a/gallery_dl/extractor/yandere.py b/gallery_dl/extractor/yandere.py index 95843176..cd58dad1 100644 --- a/gallery_dl/extractor/yandere.py +++ b/gallery_dl/extractor/yandere.py @@ -14,7 +14,7 @@ info = { "category": "yandere", "extractor": "YandereExtractor", "directory": ["{category}", "{tags}"], - "filename": "{category}_{md5}.{extension}", + "filename": "{category}_{id}_{md5}.{extension}", "pattern": [ r"(?:https?://)?(?:www\.)?yande\.re/post\?tags=([^&]+).*", ],