aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/tapas.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/tapas.py')
-rw-r--r--gallery_dl/extractor/tapas.py86
1 files changed, 17 insertions, 69 deletions
diff --git a/gallery_dl/extractor/tapas.py b/gallery_dl/extractor/tapas.py
index 545a95b..bfca7a6 100644
--- a/gallery_dl/extractor/tapas.py
+++ b/gallery_dl/extractor/tapas.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2021-2022 Mike Fährmann
+# Copyright 2021-2023 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -22,12 +22,11 @@ class TapasExtractor(Extractor):
directory_fmt = ("{category}", "{series[title]}", "{id} {title}")
filename_fmt = "{num:>02}.{extension}"
archive_fmt = "{id}_{num}"
- cookiedomain = ".tapas.io"
- cookienames = ("_cpc_",)
+ cookies_domain = ".tapas.io"
+ cookies_names = ("_cpc_",)
_cache = None
- def __init__(self, match):
- Extractor.__init__(self, match)
+ def _init(self):
if self._cache is None:
TapasExtractor._cache = {}
@@ -70,14 +69,17 @@ class TapasExtractor(Extractor):
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)
+ if self.cookies_check(self.cookies_names):
+ return
+
+ username, password = self._get_auth_info()
+ if username:
+ return self.cookies_update(self._login_impl(username, password))
+
+ self.cookies.set(
+ "birthDate" , "1981-02-03", domain=self.cookies_domain)
+ self.cookies.set(
+ "adjustedBirthDate", "1981-02-03", domain=self.cookies_domain)
@cache(maxage=14*24*3600, keyarg=1)
def _login_impl(self, username, password):
@@ -105,15 +107,7 @@ class TapasExtractor(Extractor):
class TapasSeriesExtractor(TapasExtractor):
subcategory = "series"
pattern = BASE_PATTERN + r"/series/([^/?#]+)"
- test = (
- ("https://tapas.io/series/just-leave-me-be", {
- "pattern": r"https://\w+\.cloudfront\.net/pc/\w\w/[0-9a-f-]+\.jpg",
- "count": 132,
- }),
- ("https://tapas.io/series/yona", { # mature
- "count": 26,
- }),
- )
+ example = "https://tapas.io/series/TITLE"
def __init__(self, match):
TapasExtractor.__init__(self, match)
@@ -149,53 +143,7 @@ class TapasSeriesExtractor(TapasExtractor):
class TapasEpisodeExtractor(TapasExtractor):
subcategory = "episode"
pattern = BASE_PATTERN + r"/episode/(\d+)"
- test = ("https://tapas.io/episode/2068651", {
- "url": "0b53644c864a0a097f65accea6bb620be9671078",
- "pattern": "^text:",
- "keyword": {
- "book": True,
- "comment_cnt": int,
- "date": "dt:2021-02-23 16:02:07",
- "early_access": False,
- "escape_title": "You are a Tomb Raider (2)",
- "free": True,
- "id": 2068651,
- "like_cnt": int,
- "liked": bool,
- "mature": False,
- "next_ep_id": 2068652,
- "nsfw": False,
- "nu": False,
- "num": 1,
- "open_comments": True,
- "pending_scene": 2,
- "prev_ep_id": 2068650,
- "publish_date": "2021-02-23T16:02:07Z",
- "read": bool,
- "related_ep_id": None,
- "relative_publish_date": "Feb 23, 2021",
- "scene": 2,
- "scheduled": False,
- "title": "You are a Tomb Raider (2)",
- "unlock_cnt": 0,
- "unlocked": False,
- "view_cnt": int,
-
- "series": {
- "genre": dict,
- "has_book_cover": True,
- "has_top_banner": True,
- "id": 199931,
- "premium": True,
- "sale_type": "PAID",
- "subscribed": bool,
- "thumbsup_cnt": int,
- "title": "Tomb Raider King",
- "type": "BOOKS",
- "url": "tomb-raider-king-novel",
- },
- },
- })
+ example = "https://tapas.io/episode/12345"
def __init__(self, match):
TapasExtractor.__init__(self, match)