diff --git a/docs/configuration.rst b/docs/configuration.rst index 6c464d41..f3fef6a0 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -820,35 +820,6 @@ How To =========== ===== -extractor.pinterest.access-token --------------------------------- -=========== ===== -Type ``string`` -How To - register a Pinterest application and use its client-id and - client-secret (see `extractor.pinterest.client-id & .secret`_) - - run `gallery-dl oauth:pinterest` and authenticate access with - (preferably) the same account that registered the application -Notes Access tokens currently only allow for 10 requests per hour. -=========== ===== - - -extractor.pinterest.client-id & .secret ---------------------------------------- -=========== ===== -Type ``string`` -How To - login and visit Pinterest's - `Apps `__ section - - agree to "Pinterest Developer Terms and the API Policy" - and click "Create app" - - choose a random name and description and click "Create" - - scroll down and set a Site URL (e.g. https://example.org/) - and allow https://mikf.github.io/gallery-dl/oauth-redirect.html - as Redirect URI - - scroll back up again, copy the "App ID" and "App secret" values - and put them in your configuration file -=========== ===== - - extractor.reddit.client-id & .user-agent ---------------------------------------- =========== ===== diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index 8dc6e26f..f161126e 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.py @@ -198,29 +198,6 @@ class OAuthFlickr(OAuthBase): ) -class OAuthPinterest(OAuthBase): - subcategory = "pinterest" - pattern = ["oauth:pinterest$"] - redirect_uri = "https://mikf.github.io/gallery-dl/oauth-redirect.html" - - def items(self): - yield Message.Version, 1 - - client_id = self.oauth_config("client-id") - client_secret = self.oauth_config("client-secret") - - if not client_id or not client_secret: - self.log.error("'client-id' and 'client-secret' required") - return - - self._oauth2_authorization_code_grant( - client_id, client_secret, - "https://api.pinterest.com/oauth/", - "https://api.pinterest.com/v1/oauth/token", - scope="read_public", key="access_token", auth=False, - ) - - class OAuthReddit(OAuthBase): subcategory = "reddit" pattern = ["oauth:reddit$"] diff --git a/gallery_dl/extractor/pinterest.py b/gallery_dl/extractor/pinterest.py index 5db506a8..711d95de 100644 --- a/gallery_dl/extractor/pinterest.py +++ b/gallery_dl/extractor/pinterest.py @@ -81,15 +81,12 @@ class PinterestBoardExtractor(PinterestExtractor): def items(self): board = self.api.board(self.user, self.board) data = {"board": board, "count": board["pin_count"]} - num = data["count"] yield Message.Version, 1 yield Message.Directory, data for pin in self.api.board_pins(board["id"]): - url, pdata = self.data_from_pin(pin) - data.update(pdata) - data["num"] = num - num -= 1 - yield Message.Url, url, data + url, pin_data = self.data_from_pin(pin) + pin_data.update(data) + yield Message.Url, url, pin_data class PinterestPinitExtractor(PinterestExtractor): @@ -157,11 +154,8 @@ class PinterestAPI(): return self._pagination("BoardFeed", options) def _call(self, resource, options): - url = "{}/resource/{}Resource/get".format(self.BASE_URL, resource) - params = { - "source_url": "", - "data": json.dumps({"options": options}), - } + url = "{}/resource/{}Resource/get/".format(self.BASE_URL, resource) + params = {"data": json.dumps({"options": options}), "source_url": ""} response = self.session.get(url, params=params, headers=self.HEADERS) data = response.json() @@ -179,10 +173,8 @@ class PinterestAPI(): self.log.error("API request failed: %s", msg) raise exception.StopExtraction() - def _pagination(self, resource, options, bookmarks=None): + def _pagination(self, resource, options): while True: - if bookmarks: - options["bookmarks"] = bookmarks data = self._call(resource, options) yield from data["resource_response"]["data"] @@ -190,5 +182,6 @@ class PinterestAPI(): bookmarks = data["resource"]["options"]["bookmarks"] if not bookmarks or bookmarks[0] == "-end-": return + options["bookmarks"] = bookmarks except KeyError: return