From 9bf76c135252674d204c81b3f8c9a6ce62d7cbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Mon, 20 Oct 2025 17:44:58 +0200 Subject: [PATCH] replace 'util.re()' with 'text.re()' remove unnecessary 'util' imports --- gallery_dl/extractor/agnph.py | 4 ++-- gallery_dl/extractor/arcalive.py | 2 +- gallery_dl/extractor/batoto.py | 2 +- gallery_dl/extractor/blogger.py | 6 +++--- gallery_dl/extractor/deviantart.py | 10 +++++----- gallery_dl/extractor/dynastyscans.py | 2 +- gallery_dl/extractor/everia.py | 6 +++--- gallery_dl/extractor/fanbox.py | 2 +- gallery_dl/extractor/gelbooru_v02.py | 4 ++-- gallery_dl/extractor/generic.py | 8 ++++---- gallery_dl/extractor/girlswithmuscle.py | 4 ++-- gallery_dl/extractor/hatenablog.py | 6 +++--- gallery_dl/extractor/hentai2read.py | 2 +- gallery_dl/extractor/hentaihere.py | 2 +- gallery_dl/extractor/hiperdex.py | 4 ++-- gallery_dl/extractor/imagebam.py | 4 ++-- gallery_dl/extractor/imgbox.py | 4 ++-- gallery_dl/extractor/instagram.py | 2 +- gallery_dl/extractor/kemono.py | 8 ++++---- gallery_dl/extractor/komikcast.py | 6 +++--- gallery_dl/extractor/mangahere.py | 4 ++-- gallery_dl/extractor/mangapark.py | 2 +- gallery_dl/extractor/mangaread.py | 4 ++-- gallery_dl/extractor/moebooru.py | 4 ++-- gallery_dl/extractor/newgrounds.py | 4 ++-- gallery_dl/extractor/pillowfort.py | 4 ++-- gallery_dl/extractor/pixiv.py | 2 +- gallery_dl/extractor/plurk.py | 2 +- gallery_dl/extractor/postmill.py | 6 +++--- gallery_dl/extractor/realbooru.py | 2 +- gallery_dl/extractor/recursive.py | 4 ++-- gallery_dl/extractor/rule34us.py | 4 ++-- gallery_dl/extractor/sankaku.py | 6 +++--- gallery_dl/extractor/sankakucomplex.py | 6 +++--- gallery_dl/extractor/speakerdeck.py | 4 ++-- gallery_dl/extractor/subscribestar.py | 4 ++-- gallery_dl/extractor/tumblr.py | 10 +++++----- gallery_dl/extractor/twitter.py | 2 +- gallery_dl/extractor/vk.py | 4 ++-- gallery_dl/extractor/xasiat.py | 10 +++++----- gallery_dl/extractor/zerochan.py | 2 +- gallery_dl/ytdl.py | 4 ++-- 42 files changed, 91 insertions(+), 91 deletions(-) diff --git a/gallery_dl/extractor/agnph.py b/gallery_dl/extractor/agnph.py index f8777ea3..be4517a7 100644 --- a/gallery_dl/extractor/agnph.py +++ b/gallery_dl/extractor/agnph.py @@ -9,7 +9,7 @@ """Extractors for https://agn.ph/""" from . import booru -from .. import text, util +from .. import text import collections BASE_PATTERN = r"(?:https?://)?agn\.ph" @@ -70,7 +70,7 @@ class AgnphExtractor(booru.BooruExtractor): return tags = collections.defaultdict(list) - pattern = util.re(r'class="(.)typetag">([^<]+)') + pattern = text.re(r'class="(.)typetag">([^<]+)') for tag_type, tag_name in pattern.findall(tag_container): tags[tag_type].append(text.unquote(tag_name).replace(" ", "_")) for key, value in tags.items(): diff --git a/gallery_dl/extractor/arcalive.py b/gallery_dl/extractor/arcalive.py index 51f54aa8..802e0fc2 100644 --- a/gallery_dl/extractor/arcalive.py +++ b/gallery_dl/extractor/arcalive.py @@ -63,7 +63,7 @@ class ArcalivePostExtractor(ArcaliveExtractor): def _extract_files(self, post): files = [] - for video, media in util.re(r"<(?:img|vide(o)) ([^>]+)").findall( + for video, media in text.re(r"<(?:img|vide(o)) ([^>]+)").findall( post["content"]): if not self.emoticons and 'class="arca-emoticon"' in media: continue diff --git a/gallery_dl/extractor/batoto.py b/gallery_dl/extractor/batoto.py index 0d35540c..1042d789 100644 --- a/gallery_dl/extractor/batoto.py +++ b/gallery_dl/extractor/batoto.py @@ -104,7 +104,7 @@ class BatotoChapterExtractor(BatotoBase, ChapterExtractor): info = text.remove_html(extr('link-hover">', "\ def _find_folder(self, folders, name, uuid): if uuid.isdecimal(): - match = util.re( + match = text.re( "(?i)" + name.replace("-", "[^a-z0-9]+") + "$").match for folder in folders: if match(folder["name"]): diff --git a/gallery_dl/extractor/dynastyscans.py b/gallery_dl/extractor/dynastyscans.py index 6d808d9b..1ce92a67 100644 --- a/gallery_dl/extractor/dynastyscans.py +++ b/gallery_dl/extractor/dynastyscans.py @@ -46,7 +46,7 @@ class DynastyscansChapterExtractor(DynastyscansBase, ChapterExtractor): def metadata(self, page): extr = text.extract_from(page) - match = util.re( + match = text.re( r"(?:]*>)?([^<]+)(?:)?" # manga name r"(?: ch(\d+)([^:<]*))?" # chapter info r"(?:: (.+))?" # title diff --git a/gallery_dl/extractor/everia.py b/gallery_dl/extractor/everia.py index 91672bb2..785fff5c 100644 --- a/gallery_dl/extractor/everia.py +++ b/gallery_dl/extractor/everia.py @@ -7,7 +7,7 @@ """Extractors for https://everia.club""" from .common import Extractor, Message -from .. import text, util +from .. import text BASE_PATTERN = r"(?:https?://)?everia\.club" @@ -25,7 +25,7 @@ class EveriaExtractor(Extractor): return self._pagination(self.groups[0]) def _pagination(self, path, params=None, pnum=1): - find_posts = util.re(r'thumbnail">\s*\s*', "\s]*)?" # optional query and fragment ) - imageurls_src = util.re(imageurl_pattern_src).findall(page) - imageurls_ext = util.re(imageurl_pattern_ext).findall(page) + imageurls_src = text.re(imageurl_pattern_src).findall(page) + imageurls_ext = text.re(imageurl_pattern_ext).findall(page) imageurls = imageurls_src + imageurls_ext # Resolve relative urls @@ -181,7 +181,7 @@ class GenericExtractor(Extractor): # by prepending a suitable base url. # # If the page contains a element, use it as base url - basematch = util.re( + basematch = text.re( r"(?i)(?:[^\"' >]+)").search(page) if basematch: self.baseurl = basematch['url'].rstrip('/') diff --git a/gallery_dl/extractor/girlswithmuscle.py b/gallery_dl/extractor/girlswithmuscle.py index 23773875..08970f75 100644 --- a/gallery_dl/extractor/girlswithmuscle.py +++ b/gallery_dl/extractor/girlswithmuscle.py @@ -5,7 +5,7 @@ # published by the Free Software Foundation. from .common import Extractor, Message -from .. import text, util, exception +from .. import text, exception from ..cache import cache BASE_PATTERN = r"(?:https?://)?(?:www\.)?girlswithmuscle\.com" @@ -155,7 +155,7 @@ class GirlswithmuscleSearchExtractor(GirlswithmuscleExtractor): raise exception.AuthorizationError(msg) page = response.text - match = util.re(r"Page (\d+) of (\d+)").search(page) + match = text.re(r"Page (\d+) of (\d+)").search(page) current, total = match.groups() current, total = text.parse_int(current), text.parse_int(total) diff --git a/gallery_dl/extractor/hatenablog.py b/gallery_dl/extractor/hatenablog.py index a6d2d329..39506ac7 100644 --- a/gallery_dl/extractor/hatenablog.py +++ b/gallery_dl/extractor/hatenablog.py @@ -7,7 +7,7 @@ """Extractors for https://hatenablog.com""" from .common import Extractor, Message -from .. import text, util +from .. import text BASE_PATTERN = ( @@ -30,7 +30,7 @@ class HatenablogExtractor(Extractor): self.domain = match[1] or match[2] def _init(self): - self._find_img = util.re(r']+)').finditer + self._find_img = text.re(r']+)').finditer def _handle_article(self, article: str): extr = text.extract_from(article) @@ -73,7 +73,7 @@ class HatenablogEntriesExtractor(HatenablogExtractor): def _init(self): HatenablogExtractor._init(self) - self._find_pager_url = util.re( + self._find_pager_url = text.re( r' class="pager-next">\s*", "") chapter_id = text.extr(page, 'report/C', '"') chapter, sep, minor = self.chapter.partition(".") - match = util.re( + match = text.re( r"Page 1 \| (.+) \(([^)]+)\) - Chapter \d+: (.+) by " r"(.+) at ").match(title) return { diff --git a/gallery_dl/extractor/hiperdex.py b/gallery_dl/extractor/hiperdex.py index a75eee0c..a07a6b51 100644 --- a/gallery_dl/extractor/hiperdex.py +++ b/gallery_dl/extractor/hiperdex.py @@ -9,7 +9,7 @@ """Extractors for https://hiperdex.com/""" from .common import ChapterExtractor, MangaExtractor -from .. import text, util +from .. import text from ..cache import memcache BASE_PATTERN = (r"((?:https?://)?(?:www\.)?" @@ -79,7 +79,7 @@ class HiperdexChapterExtractor(HiperdexBase, ChapterExtractor): return self.chapter_data(self.chapter) def images(self, page): - pattern = util.re(r'id="image-\d+"\s+(?:data-)?src="([^"]+)') + pattern = text.re(r'id="image-\d+"\s+(?:data-)?src="([^"]+)') return [ (url.strip(), None) for url in pattern.findall(page) diff --git a/gallery_dl/extractor/imagebam.py b/gallery_dl/extractor/imagebam.py index abba9dfb..aeceec6c 100644 --- a/gallery_dl/extractor/imagebam.py +++ b/gallery_dl/extractor/imagebam.py @@ -9,7 +9,7 @@ """Extractors for https://www.imagebam.com/""" from .common import Extractor, Message -from .. import text, util +from .. import text class ImagebamExtractor(Extractor): @@ -69,7 +69,7 @@ class ImagebamGalleryExtractor(ImagebamExtractor): page, 'id="gallery-name">', '<').strip())} def images(self, page): - findall = util.re(r'').findall(page)
 
         title = text.extr(page, ", "") diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index a93b05f2..c25d1eab 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -38,7 +38,7 @@ class InstagramExtractor(Extractor): def _init(self): self.www_claim = "0" self.csrf_token = util.generate_token() - self._find_tags = util.re(r"#\w+").findall + self._find_tags = text.re(r"#\w+").findall self._logged_in = True self._cursor = None self._user = None diff --git a/gallery_dl/extractor/kemono.py b/gallery_dl/extractor/kemono.py index 97cc3c05..7339b007 100644 --- a/gallery_dl/extractor/kemono.py +++ b/gallery_dl/extractor/kemono.py @@ -44,7 +44,7 @@ class KemonoExtractor(Extractor): order = self.config("order-revisions") self.revisions_reverse = order[0] in ("r", "a") if order else False - self._find_inline = util.re( + self._find_inline = text.re( r'src="(?:https?://(?:kemono\.cr|coomer\.st))?(/inline/[^"]+' r'|/[0-9a-f]{2}/[0-9a-f]{2}/[0-9a-f]{64}\.[^"]+)').findall self._json_dumps = json.JSONEncoder( @@ -52,7 +52,7 @@ class KemonoExtractor(Extractor): sort_keys=True, separators=(",", ":")).encode def items(self): - find_hash = util.re(HASH_PATTERN).match + find_hash = text.re(HASH_PATTERN).match generators = self._build_file_generators(self.config("files")) announcements = True if self.config("announcements") else None archives = True if self.config("archives") else False @@ -413,10 +413,10 @@ class KemonoDiscordExtractor(KemonoExtractor): "parent_id" : channel["parent_channel_id"], } - find_inline = util.re( + find_inline = text.re( r"https?://(?:cdn\.discordapp.com|media\.discordapp\.net)" r"(/[A-Za-z0-9-._~:/?#\[\]@!$&'()*+,;%=]+)").findall - find_hash = util.re(HASH_PATTERN).match + find_hash = text.re(HASH_PATTERN).match if (order := self.config("order-posts")) and order[0] in ("r", "d"): posts = self.api.discord_channel(channel_id, channel["post_count"]) diff --git a/gallery_dl/extractor/komikcast.py b/gallery_dl/extractor/komikcast.py index 816bc3dc..fad63c94 100644 --- a/gallery_dl/extractor/komikcast.py +++ b/gallery_dl/extractor/komikcast.py @@ -9,7 +9,7 @@ """Extractors for https://komikcast.li/""" from .common import ChapterExtractor, MangaExtractor -from .. import text, util +from .. import text BASE_PATTERN = (r"(?:https?://)?(?:www\.)?" r"komikcast\d*\.(?:l(?:i|a|ol)|com|cz|site|mo?e)") @@ -25,7 +25,7 @@ class KomikcastBase(): if data is None: data = {} - pattern = util.re(r"(?:(.*) Chapter )?0*(\d+)([^ ]*)(?: (?:- )?(.+))?") + pattern = text.re(r"(?:(.*) Chapter )?0*(\d+)([^ ]*)(?: (?:- )?(.+))?") match = pattern.match(text.unescape(chapter_string)) manga, chapter, data["chapter_minor"], title = match.groups() @@ -54,7 +54,7 @@ class KomikcastChapterExtractor(KomikcastBase, ChapterExtractor): def images(self, page): readerarea = text.extr( page, '
]* src=[\"']([^\"']+)") + pattern = text.re(r"]* src=[\"']([^\"']+)") return [ (text.unescape(url), None) for url in pattern.findall(readerarea) diff --git a/gallery_dl/extractor/mangahere.py b/gallery_dl/extractor/mangahere.py index 151e8093..9b3a3a14 100644 --- a/gallery_dl/extractor/mangahere.py +++ b/gallery_dl/extractor/mangahere.py @@ -9,7 +9,7 @@ """Extractors for https://www.mangahere.cc/""" from .common import ChapterExtractor, MangaExtractor -from .. import text, util +from .. import text class MangahereBase(): @@ -102,7 +102,7 @@ class MangahereMangaExtractor(MangahereBase, MangaExtractor): info, pos = text.extract(page, 'class="title3">', '<', pos) date, pos = text.extract(page, 'class="title2">', '<', pos) - match = util.re( + match = text.re( r"(?:Vol\.0*(\d+) )?Ch\.0*(\d+)(\S*)(?: - (.*))?").match(info) if match: volume, chapter, minor, title = match.groups() diff --git a/gallery_dl/extractor/mangapark.py b/gallery_dl/extractor/mangapark.py index b63426e9..35fbf190 100644 --- a/gallery_dl/extractor/mangapark.py +++ b/gallery_dl/extractor/mangapark.py @@ -23,7 +23,7 @@ class MangaparkBase(): category = "mangapark" def _parse_chapter_title(self, title): - match = util.re( + match = text.re( r"(?i)" r"(?:vol(?:\.|ume)?\s*(\d+)\s*)?" r"ch(?:\.|apter)?\s*(\d+)([^\s:]*)" diff --git a/gallery_dl/extractor/mangaread.py b/gallery_dl/extractor/mangaread.py index a3bdf392..82fddde3 100644 --- a/gallery_dl/extractor/mangaread.py +++ b/gallery_dl/extractor/mangaread.py @@ -7,7 +7,7 @@ """Extractors for https://mangaread.org/""" from .common import ChapterExtractor, MangaExtractor -from .. import text, util, exception +from .. import text, exception class MangareadBase(): @@ -16,7 +16,7 @@ class MangareadBase(): root = "https://www.mangaread.org" def parse_chapter_string(self, chapter_string, data): - match = util.re( + match = text.re( r"(?:(.+)\s*-\s*)?[Cc]hapter\s*(\d+)(\.\d+)?(?:\s*-\s*(.+))?" ).match(text.unescape(chapter_string).strip()) manga, chapter, minor, title = match.groups() diff --git a/gallery_dl/extractor/moebooru.py b/gallery_dl/extractor/moebooru.py index e4c8f1c7..27704bcf 100644 --- a/gallery_dl/extractor/moebooru.py +++ b/gallery_dl/extractor/moebooru.py @@ -9,7 +9,7 @@ """Extractors for Moebooru based sites""" from .booru import BooruExtractor -from .. import text, util, dt +from .. import text, dt import collections @@ -32,7 +32,7 @@ class MoebooruExtractor(BooruExtractor): return tags = collections.defaultdict(list) - pattern = util.re(r"tag-type-([^\"' ]+).*?[?;]tags=([^\"'+]+)") + pattern = text.re(r"tag-type-([^\"' ]+).*?[?;]tags=([^\"'+]+)") for tag_type, tag_name in pattern.findall(tag_container): tags[tag_type].append(text.unquote(tag_name)) for key, value in tags.items(): diff --git a/gallery_dl/extractor/newgrounds.py b/gallery_dl/extractor/newgrounds.py index 525b7bae..072868a9 100644 --- a/gallery_dl/extractor/newgrounds.py +++ b/gallery_dl/extractor/newgrounds.py @@ -34,7 +34,7 @@ class NewgroundsExtractor(Extractor): self.user_root = f"https://{self.user}.newgrounds.com" def _init(self): - self._extract_comment_urls = util.re( + self._extract_comment_urls = text.re( r'(?:') tags = collections.defaultdict(list) - pattern = util.re(r']*>]*src=[\"']([^\"']+)").findall(content) + return text.re(r"]*src=[\"']([^\"']+)").findall(content) def _extract_embeds(self, content): return [ "ytdl:" + url for url in - util.re(r"