summaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/8chan.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/8chan.py')
-rw-r--r--gallery_dl/extractor/8chan.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/gallery_dl/extractor/8chan.py b/gallery_dl/extractor/8chan.py
index 0385067..3230182 100644
--- a/gallery_dl/extractor/8chan.py
+++ b/gallery_dl/extractor/8chan.py
@@ -9,9 +9,8 @@
"""Extractors for https://8chan.moe/"""
from .common import Extractor, Message
-from .. import text, util
+from .. import text, dt
from ..cache import memcache
-from datetime import timedelta
import itertools
BASE_PATTERN = r"(?:https?://)?8chan\.(moe|se|cc)"
@@ -44,7 +43,7 @@ class _8chanExtractor(Extractor):
def cookies_prepare(self):
# fetch captcha cookies
# (necessary to download without getting interrupted)
- now = util.datetime_utcnow()
+ now = dt.now()
url = self.root + "/captcha.js"
params = {"d": now.strftime("%a %b %d %Y %H:%M:%S GMT+0000 (UTC)")}
self.request(url, params=params).content
@@ -57,7 +56,7 @@ class _8chanExtractor(Extractor):
if cookie.domain.endswith(domain):
cookie.expires = None
if cookie.name == "captchaexpiration":
- cookie.value = (now + timedelta(30, 300)).strftime(
+ cookie.value = (now + dt.timedelta(30, 300)).strftime(
"%a, %d %b %Y %H:%M:%S GMT")
return self.cookies
@@ -70,7 +69,7 @@ class _8chanThreadExtractor(_8chanExtractor):
"{threadId} {subject[:50]}")
filename_fmt = "{postId}{num:?-//} {filename[:200]}.{extension}"
archive_fmt = "{boardUri}_{postId}_{num}"
- pattern = BASE_PATTERN + r"/([^/?#]+)/(?:res|last)/(\d+)"
+ pattern = rf"{BASE_PATTERN}/([^/?#]+)/(?:res|last)/(\d+)"
example = "https://8chan.moe/a/res/12345.html"
def items(self):
@@ -92,7 +91,7 @@ class _8chanThreadExtractor(_8chanExtractor):
# download files
posts = thread.pop("posts", ())
- yield Message.Directory, thread
+ yield Message.Directory, "", thread
for post in itertools.chain((thread,), posts):
files = post.pop("files", ())
if not files:
@@ -108,7 +107,7 @@ class _8chanThreadExtractor(_8chanExtractor):
class _8chanBoardExtractor(_8chanExtractor):
"""Extractor for 8chan boards"""
subcategory = "board"
- pattern = BASE_PATTERN + r"/([^/?#]+)/(?:(\d+)\.html)?$"
+ pattern = rf"{BASE_PATTERN}/([^/?#]+)/(?:(\d+)\.html)?$"
example = "https://8chan.moe/a/"
def items(self):