[deviantart] allow searching when not logged in
This commit is contained in:
@@ -1148,21 +1148,48 @@ class DeviantartSearchExtractor(DeviantartExtractor):
|
|||||||
("https://www.deviantart.com/search/deviations?order=popular-1-week"),
|
("https://www.deviantart.com/search/deviations?order=popular-1-week"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def deviations(self):
|
skip = Extractor.skip
|
||||||
self.login()
|
|
||||||
|
|
||||||
query = text.parse_query(self.user)
|
def __init__(self, match):
|
||||||
self.search = query.get("q", "")
|
DeviantartExtractor.__init__(self, match)
|
||||||
|
self.query = text.parse_query(self.user)
|
||||||
|
self.search = self.query.get("q", "")
|
||||||
self.user = ""
|
self.user = ""
|
||||||
|
|
||||||
|
def deviations(self):
|
||||||
|
logged_in = self.login()
|
||||||
|
|
||||||
eclipse_api = DeviantartEclipseAPI(self)
|
eclipse_api = DeviantartEclipseAPI(self)
|
||||||
return self._eclipse_to_oauth(
|
search = (eclipse_api.search_deviations
|
||||||
eclipse_api, eclipse_api.search_deviations(query))
|
if logged_in else self._search_html)
|
||||||
|
return self._eclipse_to_oauth(eclipse_api, search(self.query))
|
||||||
|
|
||||||
def prepare(self, deviation):
|
def prepare(self, deviation):
|
||||||
DeviantartExtractor.prepare(self, deviation)
|
DeviantartExtractor.prepare(self, deviation)
|
||||||
deviation["search_tags"] = self.search
|
deviation["search_tags"] = self.search
|
||||||
|
|
||||||
|
def _search_html(self, params):
|
||||||
|
url = self.root + "/search"
|
||||||
|
deviation = {
|
||||||
|
"deviationId": None,
|
||||||
|
"author": {"username": "u"},
|
||||||
|
"isJournal": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
while True:
|
||||||
|
page = self.request(url, params=params).text
|
||||||
|
|
||||||
|
items , pos = text.rextract(page, r'\"items\":[', ']')
|
||||||
|
cursor, pos = text.extract(page, r'\"cursor\":\"', '\\', pos)
|
||||||
|
|
||||||
|
for deviation_id in items.split(","):
|
||||||
|
deviation["deviationId"] = deviation_id
|
||||||
|
yield deviation
|
||||||
|
|
||||||
|
if not cursor:
|
||||||
|
return
|
||||||
|
params["cursor"] = cursor
|
||||||
|
|
||||||
|
|
||||||
class DeviantartGallerySearchExtractor(DeviantartExtractor):
|
class DeviantartGallerySearchExtractor(DeviantartExtractor):
|
||||||
"""Extractor for deviantart gallery searches"""
|
"""Extractor for deviantart gallery searches"""
|
||||||
|
|||||||
Reference in New Issue
Block a user