From 50e3179c561e73cc7765949592a6af12cc5a7486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 21 Sep 2022 20:23:37 +0200 Subject: [PATCH] [instagram] update _user_by_screen_name() use REST API --- gallery_dl/extractor/instagram.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 4913e8c3..8c75ccb4 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -147,20 +147,9 @@ class InstagramExtractor(Extractor): @memcache(keyarg=1) def _user_by_screen_name(self, screen_name): - url = "https://www.instagram.com/{}/?__a=1&__d=dis".format( - screen_name) - headers = { - "Referer": "https://www.instagram.com/{}/".format(screen_name), - "X-CSRFToken" : self.csrf_token, - "X-IG-App-ID" : "936619743392459", - "X-IG-WWW-Claim" : self.www_claim, - "X-Requested-With": "XMLHttpRequest", - } - cookies = { - "csrftoken": self.csrf_token, - } - return self.request( - url, headers=headers, cookies=cookies).json()["graphql"]["user"] + endpoint = "/v1/users/web_profile_info/" + params = {"username": screen_name} + return self._request_api(endpoint, params=params)["data"]["user"] def _uid_by_screen_name(self, screen_name): if screen_name.startswith("id:"):