aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/subscribestar.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/subscribestar.py')
-rw-r--r--gallery_dl/extractor/subscribestar.py84
1 files changed, 18 insertions, 66 deletions
diff --git a/gallery_dl/extractor/subscribestar.py b/gallery_dl/extractor/subscribestar.py
index 4de7e9b..6b4cba2 100644
--- a/gallery_dl/extractor/subscribestar.py
+++ b/gallery_dl/extractor/subscribestar.py
@@ -22,14 +22,14 @@ class SubscribestarExtractor(Extractor):
directory_fmt = ("{category}", "{author_name}")
filename_fmt = "{post_id}_{id}.{extension}"
archive_fmt = "{id}"
- cookiedomain = "www.subscribestar.com"
- cookienames = ("auth_token",)
+ cookies_domain = "www.subscribestar.com"
+ cookies_names = ("auth_token",)
def __init__(self, match):
tld, self.item = match.groups()
if tld == "adult":
self.root = "https://subscribestar.adult"
- self.cookiedomain = "subscribestar.adult"
+ self.cookies_domain = "subscribestar.adult"
self.subcategory += "-adult"
Extractor.__init__(self, match)
@@ -49,12 +49,12 @@ class SubscribestarExtractor(Extractor):
"""Yield HTML content of all relevant posts"""
def login(self):
- if self._check_cookies(self.cookienames):
+ if self.cookies_check(self.cookies_names):
return
+
username, password = self._get_auth_info()
if username:
- cookies = self._login_impl(username, password)
- self._update_cookies(cookies)
+ self.cookies_update(self._login_impl(username, password))
@cache(maxage=28*24*3600, keyarg=1)
def _login_impl(self, username, password):
@@ -84,16 +84,16 @@ class SubscribestarExtractor(Extractor):
if cookie.name.startswith("auth")
}
- @staticmethod
- def _media_from_post(html):
+ def _media_from_post(self, html):
media = []
gallery = text.extr(html, 'data-gallery="', '"')
if gallery:
- media.extend(
- item for item in util.json_loads(text.unescape(gallery))
- if "/previews/" not in item["url"]
- )
+ for item in util.json_loads(text.unescape(gallery)):
+ if "/previews" in item["url"]:
+ self._warn_preview()
+ else:
+ media.append(item)
attachments = text.extr(
html, 'class="uploads-docs"', 'data-role="post-edit_form"')
@@ -130,39 +130,16 @@ class SubscribestarExtractor(Extractor):
date = text.parse_datetime(dt, "%B %d, %Y %I:%M %p")
return date
+ def _warn_preview(self):
+ self.log.warning("Preview image detected")
+ self._warn_preview = util.noop
+
class SubscribestarUserExtractor(SubscribestarExtractor):
"""Extractor for media from a subscribestar user"""
subcategory = "user"
pattern = BASE_PATTERN + r"/(?!posts/)([^/?#]+)"
- test = (
- ("https://www.subscribestar.com/subscribestar", {
- "count": ">= 20",
- "pattern": r"https://\w+\.cloudfront\.net/uploads(_v2)?/users/11/",
- "keyword": {
- "author_id": 11,
- "author_name": "subscribestar",
- "author_nick": "SubscribeStar",
- "content": str,
- "date" : "type:datetime",
- "id" : int,
- "num" : int,
- "post_id": int,
- "type" : "re:image|video|attachment",
- "url" : str,
- "?pinned": bool,
- },
- }),
- ("https://www.subscribestar.com/subscribestar", {
- "options": (("metadata", True),),
- "keyword": {"date": "type:datetime"},
- "range": "1",
- }),
- ("https://subscribestar.adult/kanashiipanda", {
- "range": "1-10",
- "count": 10,
- }),
- )
+ example = "https://www.subscribestar.com/USER"
def posts(self):
needle_next_page = 'data-role="infinite_scroll-next_page" href="'
@@ -184,32 +161,7 @@ class SubscribestarPostExtractor(SubscribestarExtractor):
"""Extractor for media from a single subscribestar post"""
subcategory = "post"
pattern = BASE_PATTERN + r"/posts/(\d+)"
- test = (
- ("https://www.subscribestar.com/posts/102468", {
- "count": 1,
- "keyword": {
- "author_id": 11,
- "author_name": "subscribestar",
- "author_nick": "SubscribeStar",
- "content": "re:<h1>Brand Guidelines and Assets</h1>",
- "date": "dt:2020-05-07 12:33:00",
- "extension": "jpg",
- "filename": "8ff61299-b249-47dc-880a-cdacc9081c62",
- "group": "imgs_and_videos",
- "height": 291,
- "id": 203885,
- "num": 1,
- "pinned": False,
- "post_id": 102468,
- "type": "image",
- "width": 700,
- },
- }),
- ("https://subscribestar.adult/posts/22950", {
- "count": 1,
- "keyword": {"date": "dt:2019-04-28 07:32:00"},
- }),
- )
+ example = "https://www.subscribestar.com/posts/12345"
def posts(self):
url = "{}/posts/{}".format(self.root, self.item)