aboutsummaryrefslogtreecommitdiffstats
path: root/gallery_dl/extractor/realbooru.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/extractor/realbooru.py')
-rw-r--r--gallery_dl/extractor/realbooru.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/gallery_dl/extractor/realbooru.py b/gallery_dl/extractor/realbooru.py
index ab8a9b1..cf45578 100644
--- a/gallery_dl/extractor/realbooru.py
+++ b/gallery_dl/extractor/realbooru.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright 2024 Mike Fährmann
+# Copyright 2024-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 . import booru
from .. import text, util
import collections
-import re
BASE_PATTERN = r"(?:https?://)?realbooru\.com"
@@ -22,8 +21,7 @@ class RealbooruExtractor(booru.BooruExtractor):
root = "https://realbooru.com"
def _parse_post(self, post_id):
- url = "{}/index.php?page=post&s=view&id={}".format(
- self.root, post_id)
+ url = f"{self.root}/index.php?page=post&s=view&id={post_id}"
page = self.request(url).text
extr = text.extract_from(page)
rating = extr('name="rating" content="', '"')
@@ -72,8 +70,7 @@ class RealbooruExtractor(booru.BooruExtractor):
page = post["_html"]
tag_container = text.extr(page, 'id="tagLink"', '</div>')
tags = collections.defaultdict(list)
- pattern = re.compile(
- r'<a class="(?:tag-type-)?([^"]+).*?;tags=([^"&]+)')
+ pattern = util.re(r'<a class="(?:tag-type-)?([^"]+).*?;tags=([^"&]+)')
for tag_type, tag_name in pattern.findall(tag_container):
tags[tag_type].append(text.unescape(text.unquote(tag_name)))
for key, value in tags.items():
@@ -128,7 +125,7 @@ class RealbooruPoolExtractor(RealbooruExtractor):
def metadata(self):
pool_id = self.groups[0]
- url = "{}/index.php?page=pool&s=show&id={}".format(self.root, pool_id)
+ url = f"{self.root}/index.php?page=pool&s=show&id={pool_id}"
page = self.request(url).text
name, pos = text.extract(page, "<h4>Pool: ", "</h4>")