From f36d685ce1be771e6b9451dd99d0dcf4212a4fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 5 Mar 2017 02:22:36 +0100 Subject: [PATCH] [deviantart] always request access token before api calls (#7) --- gallery_dl/extractor/deviantart.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gallery_dl/extractor/deviantart.py b/gallery_dl/extractor/deviantart.py index 8b3d3752..83c68378 100644 --- a/gallery_dl/extractor/deviantart.py +++ b/gallery_dl/extractor/deviantart.py @@ -11,6 +11,7 @@ from .common import Extractor, Message from .. import text, exception from ..cache import cache +import sys class DeviantartUserExtractor(Extractor): @@ -137,11 +138,14 @@ class DeviantartAPI(): def gallery_all(self, username, offset=0): """Yield all Deviation-objects of a specific user """ - self.authenticate() url = "https://www.deviantart.com/api/v1/oauth2/gallery/all" params = {"username": username, "offset": offset} while True: + self.authenticate() data = self.session.get(url, params=params).json() + if "results" not in data: + print("Something went wrong:", data, sep="\n", file=sys.stderr) + return yield from data["results"] if not data["has_more"]: return