[instagram] disable login with username&password (#756)

This commit is contained in:
Mike Fährmann
2020-05-29 23:29:40 +02:00
parent a32aea41e1
commit 3e0848a482
5 changed files with 7 additions and 34 deletions

View File

@@ -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 a username & password pair. This is necessary for
``pixiv``, ``nijie``, and ``seiga`` ``pixiv``, ``nijie``, and ``seiga``
and optional for and optional for
``danbooru``, ``e621``, ``exhentai``, ``idolcomplex``, ``instagram``, ``danbooru``, ``e621``, ``exhentai``, ``idolcomplex``,
``luscious``, ``sankaku``, ``tsumino``, and ``twitter``. ``luscious``, ``sankaku``, ``tsumino``, and ``twitter``.
You can set the necessary information in your configuration file You can set the necessary information in your configuration file

View File

@@ -230,7 +230,6 @@ Description The username and password to use when attempting to log in to
* ``e621`` * ``e621``
* ``exhentai`` * ``exhentai``
* ``idolcomplex`` * ``idolcomplex``
* ``instagram``
* ``luscious`` * ``luscious``
* ``sankaku`` * ``sankaku``
* ``tsumino`` * ``tsumino``

View File

@@ -59,7 +59,7 @@ ImgBB https://imgbb.com/ Albums, individual Imag
imgbox https://imgbox.com/ Galleries, individual Images imgbox https://imgbox.com/ Galleries, individual Images
imgth https://imgth.com/ Galleries imgth https://imgth.com/ Galleries
imgur https://imgur.com/ |imgur-C| 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 Issuu https://issuu.com/ Publications, User Profiles
Jaimini's Box https://jaiminisbox.com/reader/ Chapters, Manga Jaimini's Box https://jaiminisbox.com/reader/ Chapters, Manga
Joyreactor http://joyreactor.com/ Posts, Search Results, Tag Searches, User Profiles Joyreactor http://joyreactor.com/ Posts, Search Results, Tag Searches, User Profiles

View File

@@ -10,7 +10,7 @@
"""Extractors for https://www.instagram.com/""" """Extractors for https://www.instagram.com/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, exception from .. import text
from ..cache import cache from ..cache import cache
import itertools import itertools
import json import json
@@ -66,35 +66,10 @@ class InstagramExtractor(Extractor):
@cache(maxage=360*24*3600, keyarg=1) @cache(maxage=360*24*3600, keyarg=1)
def _login_impl(self, username, password): def _login_impl(self, username, password):
self.log.info("Logging in as %s", username) self.log.warning(
'Logging in with username and password is currently not possible. '
page = self.request(self.root + "/accounts/login/").text 'Use cookies from your browser session instead.')
headers = { return {}
"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")
}
def _request_graphql(self, variables, query_hash, csrf=None): def _request_graphql(self, variables, query_hash, csrf=None):
headers = { headers = {

View File

@@ -151,7 +151,6 @@ AUTH_MAP = {
"flickr" : "Optional (OAuth)", "flickr" : "Optional (OAuth)",
"idolcomplex": "Optional", "idolcomplex": "Optional",
"imgbb" : "Optional", "imgbb" : "Optional",
"instagram" : "Optional",
"mangoxo" : "Optional", "mangoxo" : "Optional",
"newgrounds" : "Optional", "newgrounds" : "Optional",
"nijie" : "Required", "nijie" : "Required",