[subscribestar] add login capabilities (#852)
This commit is contained in:
@@ -206,7 +206,7 @@ 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``, ``instagram``,
|
||||||
``luscious``, ``sankaku``, ``tsumino``, and ``twitter``.
|
``luscious``, ``sankaku``, ``subscribestar``, ``tsumino``, and ``twitter``.
|
||||||
|
|
||||||
You can set the necessary information in your configuration file
|
You can set the necessary information in your configuration file
|
||||||
(cf. gallery-dl.conf_)
|
(cf. gallery-dl.conf_)
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ Description The username and password to use when attempting to log in to
|
|||||||
* ``instagram``
|
* ``instagram``
|
||||||
* ``luscious``
|
* ``luscious``
|
||||||
* ``sankaku``
|
* ``sankaku``
|
||||||
|
* ``subscribestar``
|
||||||
* ``tsumino``
|
* ``tsumino``
|
||||||
* ``twitter``
|
* ``twitter``
|
||||||
|
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ SlickPic https://www.slickpic.com/ Albums, User Profiles
|
|||||||
SlideShare https://www.slideshare.net/ Presentations
|
SlideShare https://www.slideshare.net/ Presentations
|
||||||
SmugMug https://www.smugmug.com/ |smugmug-C| Optional (`OAuth <https://github.com/mikf/gallery-dl#oauth>`__)
|
SmugMug https://www.smugmug.com/ |smugmug-C| Optional (`OAuth <https://github.com/mikf/gallery-dl#oauth>`__)
|
||||||
Speaker Deck https://speakerdeck.com/ Presentations
|
Speaker Deck https://speakerdeck.com/ Presentations
|
||||||
SubscribeStar https://www.subscribestar.com/ Posts, User Profiles Optional (`Cookies <https://github.com/mikf/gallery-dl#cookies>`__)
|
SubscribeStar https://www.subscribestar.com/ Posts, User Profiles Optional
|
||||||
The /b/ Archive https://thebarchive.com/ Threads
|
The /b/ Archive https://thebarchive.com/ Threads
|
||||||
Tsumino https://www.tsumino.com/ Galleries, Search Results Optional
|
Tsumino https://www.tsumino.com/ Galleries, Search Results Optional
|
||||||
Tumblr https://www.tumblr.com/ Likes, Posts, Tag Searches, User Profiles Optional (`OAuth <https://github.com/mikf/gallery-dl#oauth>`__)
|
Tumblr https://www.tumblr.com/ Likes, Posts, Tag Searches, User Profiles Optional (`OAuth <https://github.com/mikf/gallery-dl#oauth>`__)
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
"""Extractors for https://www.subscribestar.com/"""
|
"""Extractors for https://www.subscribestar.com/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text, exception
|
||||||
|
from ..cache import cache
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@@ -24,17 +25,21 @@ class SubscribestarExtractor(Extractor):
|
|||||||
directory_fmt = ("{category}", "{author_name}")
|
directory_fmt = ("{category}", "{author_name}")
|
||||||
filename_fmt = "{post_id}_{id}.{extension}"
|
filename_fmt = "{post_id}_{id}.{extension}"
|
||||||
archive_fmt = "{id}"
|
archive_fmt = "{id}"
|
||||||
|
cookiedomain = "www.subscribestar.com"
|
||||||
|
cookienames = ("auth_token",)
|
||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
tld, self.item = match.groups()
|
tld, self.item = match.groups()
|
||||||
if tld == "adult":
|
if tld == "adult":
|
||||||
self.root = "https://subscribestar.adult"
|
self.root = "https://subscribestar.adult"
|
||||||
|
self.cookiedomain = "subscribestar.adult"
|
||||||
self.subcategory += "-adult"
|
self.subcategory += "-adult"
|
||||||
Extractor.__init__(self, match)
|
Extractor.__init__(self, match)
|
||||||
self.metadata = self.config("metadata", False)
|
self.metadata = self.config("metadata", False)
|
||||||
self._year = " " + str(datetime.date.today().year)
|
self._year = " " + str(datetime.date.today().year)
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
|
self.login()
|
||||||
for post_html in self.posts():
|
for post_html in self.posts():
|
||||||
media = self._media_from_post(post_html)
|
media = self._media_from_post(post_html)
|
||||||
if not media:
|
if not media:
|
||||||
@@ -49,6 +54,42 @@ class SubscribestarExtractor(Extractor):
|
|||||||
def posts(self):
|
def posts(self):
|
||||||
"""Yield HTML content of all relevant posts"""
|
"""Yield HTML content of all relevant posts"""
|
||||||
|
|
||||||
|
def login(self):
|
||||||
|
if self._check_cookies(self.cookienames):
|
||||||
|
return
|
||||||
|
username, password = self._get_auth_info()
|
||||||
|
if username:
|
||||||
|
cookies = self._login_impl(username, password)
|
||||||
|
self._update_cookies(cookies)
|
||||||
|
|
||||||
|
@cache(maxage=28*24*3600, keyarg=1)
|
||||||
|
def _login_impl(self, username, password):
|
||||||
|
self.log.info("Logging in as %s", username)
|
||||||
|
|
||||||
|
url = "https://www.subscribestar.com/session.json"
|
||||||
|
headers = {
|
||||||
|
"Origin" : "https://www.subscribestar.com",
|
||||||
|
"Referer" : "https://www.subscribestar.com/login",
|
||||||
|
"X-Requested-With": "XMLHttpRequest",
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"utf8" : "✓",
|
||||||
|
"email" : username,
|
||||||
|
"password": password,
|
||||||
|
}
|
||||||
|
|
||||||
|
response = self.request(
|
||||||
|
url, method="POST", headers=headers, data=data, fatal=False)
|
||||||
|
if response.json().get("errors"):
|
||||||
|
self.log.debug(response.json()["errors"])
|
||||||
|
raise exception.AuthenticationError()
|
||||||
|
|
||||||
|
return {
|
||||||
|
cookie.name: cookie.value
|
||||||
|
for cookie in response.cookies
|
||||||
|
if cookie.name.startswith("auth")
|
||||||
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _media_from_post(html):
|
def _media_from_post(html):
|
||||||
gallery = text.extract(html, 'data-gallery="', '"')[0]
|
gallery = text.extract(html, 'data-gallery="', '"')[0]
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ AUTH_MAP = {
|
|||||||
"sankaku" : "Optional",
|
"sankaku" : "Optional",
|
||||||
"seiga" : "Required",
|
"seiga" : "Required",
|
||||||
"smugmug" : "Optional" + _OAUTH,
|
"smugmug" : "Optional" + _OAUTH,
|
||||||
"subscribestar" : "Optional" + _COOKIES,
|
"subscribestar" : "Optional",
|
||||||
"tsumino" : "Optional",
|
"tsumino" : "Optional",
|
||||||
"tumblr" : "Optional" + _OAUTH,
|
"tumblr" : "Optional" + _OAUTH,
|
||||||
"twitter" : "Optional",
|
"twitter" : "Optional",
|
||||||
|
|||||||
Reference in New Issue
Block a user