mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-25 04:02:32 +01:00
[tapas] implement login with username & password (#692)
This commit is contained in:
parent
e9ec91c811
commit
d5aad999dc
@ -212,6 +212,7 @@ and optional for
|
||||
``pinterest``,
|
||||
``sankaku``,
|
||||
``subscribestar``,
|
||||
``tapas``,
|
||||
``tsumino``,
|
||||
and ``twitter``.
|
||||
|
||||
|
@ -299,6 +299,7 @@ Description
|
||||
* ``pinterest``
|
||||
* ``sankaku``
|
||||
* ``subscribestar``
|
||||
* ``tapas``
|
||||
* ``tsumino``
|
||||
* ``twitter``
|
||||
|
||||
|
@ -647,7 +647,7 @@ Consider all sites to be NSFW unless otherwise known.
|
||||
<td>Tapas</td>
|
||||
<td>https://tapas.io/</td>
|
||||
<td>Episodes, Series</td>
|
||||
<td></td>
|
||||
<td>Supported</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tsumino</td>
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .. import text, exception
|
||||
from ..cache import cache
|
||||
|
||||
BASE_PATTERN = r"(?:https?://)?tapas\.io"
|
||||
|
||||
@ -21,15 +22,17 @@ class TapasExtractor(Extractor):
|
||||
directory_fmt = ("{category}", "{series[title]}", "{id} {title}")
|
||||
filename_fmt = "{num:>02}.{extension}"
|
||||
archive_fmt = "{id}_{num}"
|
||||
_cache = {}
|
||||
cookiedomain = ".tapas.io"
|
||||
cookienames = ("_cpc_",)
|
||||
_cache = None
|
||||
|
||||
def __init__(self, match):
|
||||
Extractor.__init__(self, match)
|
||||
setcookie = self.session.cookies.set
|
||||
setcookie("birthDate" , "1981-02-03", domain=".tapas.io")
|
||||
setcookie("adjustedBirthDate", "1981-02-03", domain=".tapas.io")
|
||||
if self._cache is None:
|
||||
TapasExtractor._cache = {}
|
||||
|
||||
def items(self):
|
||||
self.login()
|
||||
headers = {"Accept": "application/json, text/javascript, */*;"}
|
||||
|
||||
for episode_id in self.episode_ids():
|
||||
@ -66,6 +69,38 @@ class TapasExtractor(Extractor):
|
||||
html, 'data-src="', '"'), 1):
|
||||
yield Message.Url, url, text.nameext_from_url(url, episode)
|
||||
|
||||
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))
|
||||
else:
|
||||
sc = self.session.cookies.set
|
||||
sc("birthDate" , "1981-02-03", domain=self.cookiedomain)
|
||||
sc("adjustedBirthDate", "1981-02-03", domain=self.cookiedomain)
|
||||
|
||||
@cache(maxage=14*24*3600, keyarg=1)
|
||||
def _login_impl(self, username, password):
|
||||
self.log.info("Logging in as %s", username)
|
||||
|
||||
url = self.root + "/account/authenticate"
|
||||
headers = {
|
||||
"Referer" : url,
|
||||
}
|
||||
data = {
|
||||
"from" : "https://tapas.io/",
|
||||
"email" : username,
|
||||
"password": password,
|
||||
}
|
||||
response = self.request(
|
||||
url, method="POST", headers=headers, data=data)
|
||||
|
||||
if not response.history or \
|
||||
"/account/signin_fail" in response.history[-1].url:
|
||||
raise exception.AuthenticationError()
|
||||
|
||||
return {"_cpc_": response.history[0].cookies.get("_cpc_")}
|
||||
|
||||
|
||||
class TapasSeriesExtractor(TapasExtractor):
|
||||
subcategory = "series"
|
||||
|
@ -224,6 +224,7 @@ AUTH_MAP = {
|
||||
"seiga" : "Required",
|
||||
"smugmug" : _OAUTH,
|
||||
"subscribestar" : "Supported",
|
||||
"tapas" : "Supported",
|
||||
"tsumino" : "Supported",
|
||||
"tumblr" : _OAUTH,
|
||||
"twitter" : "Supported",
|
||||
|
Loading…
Reference in New Issue
Block a user