Skip to content

Commit

Permalink
[danbooru] add 'ugoira' option (#406)
Browse files Browse the repository at this point in the history
to choose between ZIP archives or converted video files
for Ugoira posts
  • Loading branch information
mikf committed Aug 31, 2019
1 parent 9646ccb commit f02a768
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## Unreleased

## 1.10.3 - 2019-08-30
### Additions
- Provide `filename` metadata for all `deviantart` files ([#392](https://github.com/mikf/gallery-dl/issues/392), [#400](https://github.com/mikf/gallery-dl/issues/400))
Expand Down
12 changes: 12 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,18 @@ Description Try to follow external URLs of embedded players.
=========== =====


extractor.danbooru.ugoira
-------------------------
=========== =====
Type ``bool``
Default ``true``
Description Controls the download target for Ugoira posts.

* ``true``: Original ZIP archives
* ``false``: Converted video files
=========== =====


extractor.deviantart.extra
--------------------------
=========== =====
Expand Down
3 changes: 2 additions & 1 deletion docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"danbooru":
{
"username": null,
"password": null
"password": null,
"ugoira": true
},
"deviantart":
{
Expand Down
7 changes: 6 additions & 1 deletion gallery_dl/extractor/booru.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class BooruExtractor(SharedConfigMixin, Extractor):
page_start = 1
page_limit = None
sort = False
ugoira = True

def __init__(self, match):
super().__init__(match)
Expand All @@ -51,7 +52,11 @@ def items(self):

for image in images:
try:
url = image["file_url"]
if "pixiv_ugoira_frame_data" in image and \
"large_file_url" in image and not self.ugoira:
url = image["large_file_url"]
else:
url = image["file_url"]
except KeyError:
continue
if url.startswith("/"):
Expand Down
13 changes: 10 additions & 3 deletions gallery_dl/extractor/danbooru.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(self, match):
self.scheme = "https" if self.subdomain == "danbooru" else "http"
self.api_url = "{scheme}://{subdomain}.donmai.us/posts.json".format(
scheme=self.scheme, subdomain=self.subdomain)
self.ugoira = self.config("ugoira", True)

username, api_key = self._get_auth_info()
if username:
Expand Down Expand Up @@ -63,9 +64,15 @@ class DanbooruPoolExtractor(booru.PoolMixin, DanbooruExtractor):
class DanbooruPostExtractor(booru.PostMixin, DanbooruExtractor):
"""Extractor for single images from danbooru"""
pattern = BASE_PATTERN + r"/posts/(?P<post>\d+)"
test = ("https://danbooru.donmai.us/posts/294929", {
"content": "5e255713cbf0a8e0801dc423563c34d896bb9229",
})
test = (
("https://danbooru.donmai.us/posts/294929", {
"content": "5e255713cbf0a8e0801dc423563c34d896bb9229",
}),
("https://danbooru.donmai.us/posts/3613024", {
"pattern": r"https?://.+\.webm$",
"options": (("ugoira", False),)
})
)


class DanbooruPopularExtractor(booru.PopularMixin, DanbooruExtractor):
Expand Down
2 changes: 1 addition & 1 deletion gallery_dl/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

__version__ = "1.10.3"
__version__ = "1.10.4-dev"

0 comments on commit f02a768

Please sign in to comment.