Skip to content

Commit

Permalink
[deviantart] use '/browse/newest' for most-recent searches
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 20, 2021
1 parent 0bd7607 commit 8f0cf0b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions gallery_dl/extractor/deviantart.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ def __init__(self, match):
if trange.startswith("popular-"):
trange = trange[8:]
self.time_range = {
"newest" : "now",
"most-recent" : "now",
"this-week" : "1week",
"this-month" : "1month",
Expand All @@ -786,6 +787,8 @@ def __init__(self, match):
}

def deviations(self):
if self.time_range == "now":
return self.api.browse_newest(self.search_term, self.offset)
return self.api.browse_popular(
self.search_term, self.time_range, self.offset)

Expand Down Expand Up @@ -1046,6 +1049,17 @@ def browse_posts_deviantsyouwatch(self, offset=0):
"mature_content": self.mature}
return self._pagination(endpoint, params, public=False, unpack=True)

def browse_newest(self, query=None, offset=0):
"""Browse newest deviations"""
endpoint = "browse/newest"
params = {
"q" : query,
"limit" : 50 if self.metadata else 120,
"offset" : offset,
"mature_content": self.mature,
}
return self._pagination(endpoint, params)

def browse_popular(self, query=None, timerange=None, offset=0):
"""Yield popular deviations"""
endpoint = "browse/popular"
Expand Down

0 comments on commit 8f0cf0b

Please sign in to comment.