[vipergirls] implement login support (#4166)

This commit is contained in:
Mike Fährmann
2023-06-13 21:05:09 +02:00
parent db20a645c5
commit deff3b434d
5 changed files with 37 additions and 5 deletions

View File

@@ -395,6 +395,7 @@ Description
* ``tapas`` * ``tapas``
* ``tsumino`` * ``tsumino``
* ``twitter`` * ``twitter``
* ``vipergirls``
* ``zerochan`` * ``zerochan``
These values can also be specified via the These values can also be specified via the

View File

@@ -712,7 +712,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr> <tr>
<td>Postimg</td> <td>Postimg</td>
<td>https://postimages.org/</td> <td>https://postimages.org/</td>
<td>individual Images</td> <td>Galleries, individual Images</td>
<td></td> <td></td>
</tr> </tr>
<tr> <tr>
@@ -899,7 +899,7 @@ Consider all sites to be NSFW unless otherwise known.
<td>Vipergirls</td> <td>Vipergirls</td>
<td>https://vipergirls.to/</td> <td>https://vipergirls.to/</td>
<td>Posts, Threads</td> <td>Posts, Threads</td>
<td></td> <td>Supported</td>
</tr> </tr>
<tr> <tr>
<td>Vipr</td> <td>Vipr</td>
@@ -995,7 +995,7 @@ Consider all sites to be NSFW unless otherwise known.
<td>Zerochan</td> <td>Zerochan</td>
<td>https://www.zerochan.net/</td> <td>https://www.zerochan.net/</td>
<td>individual Images, Tag Searches</td> <td>individual Images, Tag Searches</td>
<td></td> <td>Supported</td>
</tr> </tr>
<tr> <tr>
<td>かべうち</td> <td>かべうち</td>

View File

@@ -9,7 +9,8 @@
"""Extractors for https://vipergirls.to/""" """Extractors for https://vipergirls.to/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, util from .. import text, util, exception
from ..cache import cache
from xml.etree import ElementTree from xml.etree import ElementTree
@@ -30,6 +31,8 @@ class VipergirlsExtractor(Extractor):
self.session.headers["Referer"] = self.root self.session.headers["Referer"] = self.root
def items(self): def items(self):
self.login()
for post in self.posts(): for post in self.posts():
data = post.attrib data = post.attrib
data["thread_id"] = self.thread_id data["thread_id"] = self.thread_id
@@ -38,6 +41,31 @@ class VipergirlsExtractor(Extractor):
for image in post: for image in post:
yield Message.Queue, image.attrib["main_url"], data yield Message.Queue, image.attrib["main_url"], data
def login(self):
if not self._check_cookies(self.cookienames):
username, password = self._get_auth_info()
if username:
self._update_cookies(self._login_impl(username, password))
@cache(maxage=90*24*3600, keyarg=1)
def _login_impl(self, username, password):
self.log.info("Logging in as %s", username)
url = "{}/login.php?do=login".format(self.root)
data = {
"vb_login_username": username,
"vb_login_password": password,
"do" : "login",
"cookieuser" : "1",
}
response = self.request(url, method="POST", data=data)
if not response.cookies.get("vg_password"):
raise exception.AuthenticationError()
return {cookie.name: cookie.value
for cookie in response.cookies}
class VipergirlsThreadExtractor(VipergirlsExtractor): class VipergirlsThreadExtractor(VipergirlsExtractor):
"""Extractor for vipergirls threads""" """Extractor for vipergirls threads"""

View File

@@ -340,8 +340,10 @@ AUTH_MAP = {
"tsumino" : "Supported", "tsumino" : "Supported",
"tumblr" : _OAUTH, "tumblr" : _OAUTH,
"twitter" : "Supported", "twitter" : "Supported",
"vipergirls" : "Supported",
"wallhaven" : _APIKEY_WH, "wallhaven" : _APIKEY_WH,
"weasyl" : _APIKEY_WY, "weasyl" : _APIKEY_WY,
"zerochan" : "Supported",
} }
IGNORE_LIST = ( IGNORE_LIST = (

View File

@@ -324,7 +324,8 @@ def setup_test_config():
for category in ("danbooru", "atfbooru", "aibooru", "e621", "e926", for category in ("danbooru", "atfbooru", "aibooru", "e621", "e926",
"instagram", "twitter", "subscribestar", "deviantart", "instagram", "twitter", "subscribestar", "deviantart",
"inkbunny", "tapas", "pillowfort", "mangadex"): "inkbunny", "tapas", "pillowfort", "mangadex",
"vipergirls"):
config.set(("extractor", category), "username", None) config.set(("extractor", category), "username", None)
config.set(("extractor", "mastodon.social"), "access-token", config.set(("extractor", "mastodon.social"), "access-token",