diff options
| author | 2025-07-31 01:22:01 -0400 | |
|---|---|---|
| committer | 2025-07-31 01:22:01 -0400 | |
| commit | a6e995c093de8aae2e91a0787281bb34c0b871eb (patch) | |
| tree | 2d79821b05300d34d8871eb6c9662b359a2de85d /gallery_dl/extractor/plurk.py | |
| parent | 7672a750cb74bf31e21d76aad2776367fd476155 (diff) | |
New upstream version 1.30.2.upstream/1.30.2
Diffstat (limited to 'gallery_dl/extractor/plurk.py')
| -rw-r--r-- | gallery_dl/extractor/plurk.py | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/gallery_dl/extractor/plurk.py b/gallery_dl/extractor/plurk.py index 0bacd54..37b9b10 100644 --- a/gallery_dl/extractor/plurk.py +++ b/gallery_dl/extractor/plurk.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2019-2023 Mike Fährmann +# Copyright 2019-2025 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 @@ -11,7 +11,6 @@ from .common import Extractor, Message from .. import text, util, exception import datetime -import re class PlurkExtractor(Extractor): @@ -29,8 +28,7 @@ class PlurkExtractor(Extractor): def plurks(self): """Return an iterable with all relevant 'plurk' objects""" - @staticmethod - def _urls(obj): + def _urls(self, obj): """Extract URLs from a 'plurk' object""" return text.extract_iter(obj["content"], ' href="', '"') @@ -51,8 +49,8 @@ class PlurkExtractor(Extractor): } while True: - info = self.request( - url, method="POST", headers=headers, data=data).json() + info = self.request_json( + url, method="POST", headers=headers, data=data) yield from info["responses"] if not info["has_newer"]: return @@ -60,11 +58,11 @@ class PlurkExtractor(Extractor): del data["count"] data["from_response_id"] = info["responses"][-1]["id"] + 1 - @staticmethod - def _load(data): + def _load(self, data): if not data: raise exception.NotFoundError("user") - return util.json_loads(re.sub(r"new Date\(([^)]+)\)", r"\1", data)) + return util.json_loads( + util.re(r"new Date\(([^)]+)\)").sub(r"\1", data)) class PlurkTimelineExtractor(PlurkExtractor): @@ -75,10 +73,10 @@ class PlurkTimelineExtractor(PlurkExtractor): def __init__(self, match): PlurkExtractor.__init__(self, match) - self.user = match.group(1) + self.user = match[1] def plurks(self): - url = "{}/{}".format(self.root, self.user) + url = f"{self.root}/{self.user}" page = self.request(url).text user_id, pos = text.extract(page, '"page_user": {"id":', ',') plurks = self._load(text.extract(page, "_PLURKS = ", ";\n", pos)[0]) @@ -105,7 +103,7 @@ class PlurkPostExtractor(PlurkExtractor): example = "https://www.plurk.com/p/12345" def plurks(self): - url = "{}/p/{}".format(self.root, self.groups[0]) + url = f"{self.root}/p/{self.groups[0]}" page = self.request(url).text user, pos = text.extract(page, " GLOBAL=", "\n") data, pos = text.extract(page, "plurk =", ";\n", pos) |
