Skip to content

Commit

Permalink
[deviantart] add 'external' option (#302)
Browse files Browse the repository at this point in the history
If a description is available, this will extract URLs from the
description text and try to find Extractors for them.
  • Loading branch information
mikf committed Jun 6, 2019
1 parent f85e42c commit 2fb8517
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,18 @@ Description Try to follow external URLs of embedded players.
=========== =====


extractor.deviantart.external
-----------------------------
=========== =====
Type ``bool``
Default ``false``
Description Try to follow external URLs in description fields.

Note: deviantart.metadata_ needs to be enabled to make descriptions
available.
=========== =====


extractor.deviantart.flat
-------------------------
=========== =====
Expand Down Expand Up @@ -1586,6 +1598,7 @@ Description An object with the ``name`` of a post-processor and its options.
.. _skipped: `extractor.*.skip`_
.. _`date-min and date-max`: `extractor.reddit.date-min & .date-max`_
.. _date-format: extractor.reddit.date-format_
.. _deviantart.metadata: extractor.deviantart.metadata_

.. _.netrc: https://stackoverflow.com/tags/.netrc/info
.. _tempfile.gettempdir(): https://docs.python.org/3/library/tempfile.html#tempfile.gettempdir
Expand Down
1 change: 1 addition & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"deviantart":
{
"refresh-token": null,
"external": false,
"flat": true,
"folders": false,
"journals": "html",
Expand Down
16 changes: 16 additions & 0 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(self, match=None):
self.offset = 0
self.flat = self.config("flat", True)
self.original = self.config("original", True)
self.external = self.config("external", False)
self.user = match.group(1) or match.group(2)
self.group = False

Expand Down Expand Up @@ -95,6 +96,13 @@ def items(self):
journal = self.api.deviation_content(deviation["deviationid"])
yield self.commit_journal(deviation, journal)

if self.external:
for url in text.extract_iter(
deviation.get("description", ""), 'href="', '"'):
if "deviantart.com/users/outgoing?" in url:
url = text.unquote(url.partition("?")[2])
yield Message.Queue, url, deviation

def deviations(self):
"""Return an iterable containing all relevant Deviation-objects"""
return []
Expand Down Expand Up @@ -361,6 +369,14 @@ class DeviantartDeviationExtractor(DeviantartExtractor):
"pattern": (r"https://images-wixmp-\w+\.wixmp\.com"
r"/f/[^/]+/[^.]+\.gif\?token="),
}),
# external URLs from description (#302)
(("https://www.deviantart.com/uotapo/art/"
"INANAKI-Memorial-Humane7-590297498"), {
"options": (("external", 1), ("metadata", 1), ("original", 0)),
"pattern": r"https?://(sta\.sh|youtu\.be)/\w+$",
"range": "2-",
"count": 6,
}),
# old-style URLs
("https://shimoda7.deviantart.com"
"/art/For-the-sake-of-a-memory-10073852"),
Expand Down

0 comments on commit 2fb8517

Please sign in to comment.