Skip to content

Commit

Permalink
[deviantart] rename 'external' to 'stash' (#302)
Browse files Browse the repository at this point in the history
restrict extracted URLs to ones from https://sta.sh/...
  • Loading branch information
mikf committed Jun 9, 2019
1 parent c73c2cd commit c23bf26
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
23 changes: 11 additions & 12 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,6 @@ 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 @@ -499,6 +487,17 @@ Description The ``refresh_token`` value you get from linking your
=========== =====


extractor.deviantart.stash
--------------------------
=========== =====
Type ``bool``
Default ``false``
Description Extract Sta.sh resources from description texts.

Note: Enabling this option also enables deviantart.metadata_.
=========== =====


extractor.deviantart.wait-min
-----------------------------
=========== =====
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"deviantart":
{
"refresh-token": null,
"external": false,
"flat": true,
"folders": false,
"journals": "html",
"mature": true,
"metadata": false,
"original": true,
"stash": false,
"wait-min": 0
},
"exhentai":
Expand Down
22 changes: 12 additions & 10 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,14 @@ def __init__(self, match=None):
self.api = DeviantartAPI(self)
self.offset = 0
self.flat = self.config("flat", True)
self.stash = self.config("stash", False)
self.original = self.config("original", True)
self.external = self.config("external", False)
self.user = match.group(1) or match.group(2)
self.group = False

if self.stash:
self.api.metadata = True

self.commit_journal = {
"html": self._commit_journal_html,
"text": self._commit_journal_text,
Expand Down Expand Up @@ -96,12 +99,11 @@ 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
if self.stash:
for match in DeviantartStashExtractor.pattern.finditer(
deviation.get("description", "")):
deviation["_extractor"] = DeviantartStashExtractor
yield Message.Queue, match.group(0), deviation

def deviations(self):
"""Return an iterable containing all relevant Deviation-objects"""
Expand Down Expand Up @@ -372,10 +374,10 @@ class DeviantartDeviationExtractor(DeviantartExtractor):
# 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+$",
"options": (("stash", 1), ("original", 0)),
"pattern": r"https?://sta\.sh/\w+$",
"range": "2-",
"count": 6,
"count": 4,
}),
# old-style URLs
("https://shimoda7.deviantart.com"
Expand Down

0 comments on commit c23bf26

Please sign in to comment.