mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
adjust login methods to a specific style
This commit is contained in:
parent
98d6d131a3
commit
4a8d74973c
@ -169,12 +169,14 @@ class ExhentaiGalleryExtractor(Extractor):
|
||||
|
||||
def login(self):
|
||||
"""Login and set necessary cookies"""
|
||||
cookies = self._login_impl()
|
||||
username = config.interpolate(("extractor", "exhentai", "username"))
|
||||
password = config.interpolate(("extractor", "exhentai", "password"))
|
||||
cookies = self._login_impl(username, password)
|
||||
for key, value in cookies.items():
|
||||
self.session.cookies.set(key, value, domain=".exhentai.org", path="/")
|
||||
|
||||
@cache(maxage=360*24*60*60)
|
||||
def _login_impl(self):
|
||||
@cache(maxage=360*24*60*60, keyarg=1)
|
||||
def _login_impl(self, username, password):
|
||||
"""Actual login implementation"""
|
||||
cnames = ["ipb_member_id", "ipb_pass_hash"]
|
||||
|
||||
@ -190,8 +192,8 @@ class ExhentaiGalleryExtractor(Extractor):
|
||||
"CookieDate": "1",
|
||||
"b": "d",
|
||||
"bt": "1-1",
|
||||
"UserName": config.interpolate(("extractor", "exhentai", "username")),
|
||||
"PassWord": config.interpolate(("extractor", "exhentai", "password")),
|
||||
"UserName": username,
|
||||
"PassWord": password,
|
||||
"ipb_login_submit": "Login!",
|
||||
}
|
||||
self.session.headers["Referer"] = "http://e-hentai.org/bounce_login.php?b=d&bt=1-1"
|
||||
|
@ -25,10 +25,7 @@ class NijieExtractor(AsynchronousExtractor):
|
||||
self.artist_id = ""
|
||||
|
||||
def items(self):
|
||||
self.session.cookies = self.login(
|
||||
config.interpolate(("extractor", self.category, "username")),
|
||||
config.interpolate(("extractor", self.category, "password"))
|
||||
)
|
||||
self.login()
|
||||
data = self.get_job_metadata()
|
||||
images = self.get_image_ids()
|
||||
yield Message.Version, 1
|
||||
@ -62,9 +59,15 @@ class NijieExtractor(AsynchronousExtractor):
|
||||
"image-id": image_id,
|
||||
})
|
||||
|
||||
@cache(maxage=30*24*60*60, keyarg=1)
|
||||
def login(self, username, password):
|
||||
def login(self):
|
||||
"""Login and obtain session cookie"""
|
||||
username = config.interpolate(("extractor", "nijie", "username"))
|
||||
password = config.interpolate(("extractor", "nijie", "password"))
|
||||
self.session.cookies = self._login_impl(username, password)
|
||||
|
||||
@cache(maxage=30*24*60*60, keyarg=1)
|
||||
def _login_impl(self, username, password):
|
||||
"""Actual login implementation"""
|
||||
params = {"email": username, "password": password}
|
||||
page = self.session.post("https://nijie.info/login_int.php",
|
||||
data=params).text
|
||||
|
@ -226,14 +226,7 @@ class PixivAPI():
|
||||
"Referer": "http://www.pixiv.net/",
|
||||
"User-Agent": "PixivIOSApp/5.8.0",
|
||||
})
|
||||
self.user_id = -1
|
||||
self.username = config.interpolate(("extractor", "pixiv", "username"))
|
||||
self.password = config.interpolate(("extractor", "pixiv", "password"))
|
||||
|
||||
def login(self):
|
||||
"""Login and gain a Pixiv Public-API access token"""
|
||||
self.user_id, auth_header = self._login_impl(self.username, self.password)
|
||||
self.session.headers["Authorization"] = auth_header
|
||||
self.user_id = -1
|
||||
|
||||
@require_login
|
||||
def user(self, user_id):
|
||||
@ -285,6 +278,13 @@ class PixivAPI():
|
||||
)
|
||||
return self._parse(response)
|
||||
|
||||
def login(self):
|
||||
"""Login and gain a Pixiv Public-API access token"""
|
||||
username = config.interpolate(("extractor", "pixiv", "username"))
|
||||
password = config.interpolate(("extractor", "pixiv", "password"))
|
||||
self.user_id, auth_header = self._login_impl(username, password)
|
||||
self.session.headers["Authorization"] = auth_header
|
||||
|
||||
@cache(maxage=50*60, keyarg=1)
|
||||
def _login_impl(self, username, password):
|
||||
"""Actual login implementation"""
|
||||
|
Loading…
Reference in New Issue
Block a user