adjust login methods to a specific style
This commit is contained in:
@@ -169,12 +169,14 @@ class ExhentaiGalleryExtractor(Extractor):
|
|||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
"""Login and set necessary cookies"""
|
"""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():
|
for key, value in cookies.items():
|
||||||
self.session.cookies.set(key, value, domain=".exhentai.org", path="/")
|
self.session.cookies.set(key, value, domain=".exhentai.org", path="/")
|
||||||
|
|
||||||
@cache(maxage=360*24*60*60)
|
@cache(maxage=360*24*60*60, keyarg=1)
|
||||||
def _login_impl(self):
|
def _login_impl(self, username, password):
|
||||||
"""Actual login implementation"""
|
"""Actual login implementation"""
|
||||||
cnames = ["ipb_member_id", "ipb_pass_hash"]
|
cnames = ["ipb_member_id", "ipb_pass_hash"]
|
||||||
|
|
||||||
@@ -190,8 +192,8 @@ class ExhentaiGalleryExtractor(Extractor):
|
|||||||
"CookieDate": "1",
|
"CookieDate": "1",
|
||||||
"b": "d",
|
"b": "d",
|
||||||
"bt": "1-1",
|
"bt": "1-1",
|
||||||
"UserName": config.interpolate(("extractor", "exhentai", "username")),
|
"UserName": username,
|
||||||
"PassWord": config.interpolate(("extractor", "exhentai", "password")),
|
"PassWord": password,
|
||||||
"ipb_login_submit": "Login!",
|
"ipb_login_submit": "Login!",
|
||||||
}
|
}
|
||||||
self.session.headers["Referer"] = "http://e-hentai.org/bounce_login.php?b=d&bt=1-1"
|
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 = ""
|
self.artist_id = ""
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
self.session.cookies = self.login(
|
self.login()
|
||||||
config.interpolate(("extractor", self.category, "username")),
|
|
||||||
config.interpolate(("extractor", self.category, "password"))
|
|
||||||
)
|
|
||||||
data = self.get_job_metadata()
|
data = self.get_job_metadata()
|
||||||
images = self.get_image_ids()
|
images = self.get_image_ids()
|
||||||
yield Message.Version, 1
|
yield Message.Version, 1
|
||||||
@@ -62,9 +59,15 @@ class NijieExtractor(AsynchronousExtractor):
|
|||||||
"image-id": image_id,
|
"image-id": image_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
@cache(maxage=30*24*60*60, keyarg=1)
|
def login(self):
|
||||||
def login(self, username, password):
|
|
||||||
"""Login and obtain session cookie"""
|
"""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}
|
params = {"email": username, "password": password}
|
||||||
page = self.session.post("https://nijie.info/login_int.php",
|
page = self.session.post("https://nijie.info/login_int.php",
|
||||||
data=params).text
|
data=params).text
|
||||||
|
|||||||
@@ -226,14 +226,7 @@ class PixivAPI():
|
|||||||
"Referer": "http://www.pixiv.net/",
|
"Referer": "http://www.pixiv.net/",
|
||||||
"User-Agent": "PixivIOSApp/5.8.0",
|
"User-Agent": "PixivIOSApp/5.8.0",
|
||||||
})
|
})
|
||||||
self.user_id = -1
|
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
|
|
||||||
|
|
||||||
@require_login
|
@require_login
|
||||||
def user(self, user_id):
|
def user(self, user_id):
|
||||||
@@ -285,6 +278,13 @@ class PixivAPI():
|
|||||||
)
|
)
|
||||||
return self._parse(response)
|
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)
|
@cache(maxage=50*60, keyarg=1)
|
||||||
def _login_impl(self, username, password):
|
def _login_impl(self, username, password):
|
||||||
"""Actual login implementation"""
|
"""Actual login implementation"""
|
||||||
|
|||||||
Reference in New Issue
Block a user