From 3e0848a482463415e40b3f12534da33f8a81d5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 29 May 2020 23:29:40 +0200 Subject: [PATCH] [instagram] disable login with username&password (#756) --- README.rst | 2 +- docs/configuration.rst | 1 - docs/supportedsites.rst | 2 +- gallery_dl/extractor/instagram.py | 35 +++++-------------------------- scripts/supportedsites.py | 1 - 5 files changed, 7 insertions(+), 34 deletions(-) diff --git a/README.rst b/README.rst index af918044..e10cf14a 100644 --- a/README.rst +++ b/README.rst @@ -196,7 +196,7 @@ Some extractors require you to provide valid login-credentials in the form of a username & password pair. This is necessary for ``pixiv``, ``nijie``, and ``seiga`` and optional for -``danbooru``, ``e621``, ``exhentai``, ``idolcomplex``, ``instagram``, +``danbooru``, ``e621``, ``exhentai``, ``idolcomplex``, ``luscious``, ``sankaku``, ``tsumino``, and ``twitter``. You can set the necessary information in your configuration file diff --git a/docs/configuration.rst b/docs/configuration.rst index 71067992..88dfe116 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -230,7 +230,6 @@ Description The username and password to use when attempting to log in to * ``e621`` * ``exhentai`` * ``idolcomplex`` - * ``instagram`` * ``luscious`` * ``sankaku`` * ``tsumino`` diff --git a/docs/supportedsites.rst b/docs/supportedsites.rst index b564f52a..83e9bd74 100644 --- a/docs/supportedsites.rst +++ b/docs/supportedsites.rst @@ -59,7 +59,7 @@ ImgBB https://imgbb.com/ Albums, individual Imag imgbox https://imgbox.com/ Galleries, individual Images imgth https://imgth.com/ Galleries imgur https://imgur.com/ |imgur-C| -Instagram https://www.instagram.com/ |instagram-C| Optional +Instagram https://www.instagram.com/ |instagram-C| Issuu https://issuu.com/ Publications, User Profiles Jaimini's Box https://jaiminisbox.com/reader/ Chapters, Manga Joyreactor http://joyreactor.com/ Posts, Search Results, Tag Searches, User Profiles diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 130c7f96..7fa5d32e 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -10,7 +10,7 @@ """Extractors for https://www.instagram.com/""" from .common import Extractor, Message -from .. import text, exception +from .. import text from ..cache import cache import itertools import json @@ -66,35 +66,10 @@ class InstagramExtractor(Extractor): @cache(maxage=360*24*3600, keyarg=1) def _login_impl(self, username, password): - self.log.info("Logging in as %s", username) - - page = self.request(self.root + "/accounts/login/").text - headers = { - "Referer" : self.root + "/accounts/login/", - "X-IG-App-ID" : "936619743392459", - "X-Requested-With": "XMLHttpRequest", - } - - response = self.request(self.root + "/web/__mid/", headers=headers) - headers["X-CSRFToken"] = response.cookies["csrftoken"] - headers["X-Instagram-AJAX"] = text.extract( - page, '"rollout_hash":"', '"')[0] - - url = self.root + "/accounts/login/ajax/" - data = { - "username" : username, - "password" : password, - "queryParams" : "{}", - "optIntoOneTap": "true", - } - response = self.request(url, method="POST", headers=headers, data=data) - - if not response.json().get("authenticated"): - raise exception.AuthenticationError() - return { - key: self.session.cookies.get(key) - for key in ("sessionid", "mid", "csrftoken") - } + self.log.warning( + 'Logging in with username and password is currently not possible. ' + 'Use cookies from your browser session instead.') + return {} def _request_graphql(self, variables, query_hash, csrf=None): headers = { diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 1adfb8de..8dabbc70 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -151,7 +151,6 @@ AUTH_MAP = { "flickr" : "Optional (OAuth)", "idolcomplex": "Optional", "imgbb" : "Optional", - "instagram" : "Optional", "mangoxo" : "Optional", "newgrounds" : "Optional", "nijie" : "Required",