@@ -492,8 +492,7 @@ class InputManager():
|
|||||||
# url
|
# url
|
||||||
if " #" in line or "\t#" in line:
|
if " #" in line or "\t#" in line:
|
||||||
if strip_comment is None:
|
if strip_comment is None:
|
||||||
import re
|
strip_comment = util.re(r"\s+#.*").sub
|
||||||
strip_comment = re.compile(r"\s+#.*").sub
|
|
||||||
line = strip_comment("", line)
|
line = strip_comment("", line)
|
||||||
if gconf or lconf:
|
if gconf or lconf:
|
||||||
url = ExtendedUrl(line, gconf, lconf)
|
url = ExtendedUrl(line, gconf, lconf)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2023 Mike Fährmann
|
# Copyright 2023-2025 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
""" """
|
""" """
|
||||||
|
|
||||||
import re
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
@@ -32,7 +31,7 @@ def parse(actionspec):
|
|||||||
|
|
||||||
for event, spec in actionspec:
|
for event, spec in actionspec:
|
||||||
level, _, pattern = event.partition(":")
|
level, _, pattern = event.partition(":")
|
||||||
search = re.compile(pattern).search if pattern else util.true
|
search = util.re(pattern).search if pattern else util.true
|
||||||
|
|
||||||
if isinstance(spec, str):
|
if isinstance(spec, str):
|
||||||
type, _, args = spec.partition(" ")
|
type, _, args = spec.partition(" ")
|
||||||
@@ -138,7 +137,7 @@ def action_print(opts):
|
|||||||
|
|
||||||
|
|
||||||
def action_status(opts):
|
def action_status(opts):
|
||||||
op, value = re.match(r"\s*([&|^=])=?\s*(\d+)", opts).groups()
|
op, value = util.re(r"\s*([&|^=])=?\s*(\d+)").match(opts).groups()
|
||||||
|
|
||||||
op = {
|
op = {
|
||||||
"&": operator.and_,
|
"&": operator.and_,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"""Filesystem path handling"""
|
"""Filesystem path handling"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
import functools
|
import functools
|
||||||
from . import util, formatter, exception
|
from . import util, formatter, exception
|
||||||
@@ -148,8 +147,7 @@ class PathFormat():
|
|||||||
def func(x, c=chars, r=repl):
|
def func(x, c=chars, r=repl):
|
||||||
return x.replace(c, r)
|
return x.replace(c, r)
|
||||||
else:
|
else:
|
||||||
return functools.partial(
|
return functools.partial(util.re(f"[{chars}]").sub, repl)
|
||||||
re.compile("[" + chars + "]").sub, repl)
|
|
||||||
return func
|
return func
|
||||||
|
|
||||||
def _process_repl_dict(self, chars):
|
def _process_repl_dict(self, chars):
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .extractor.common import Extractor, Message
|
from .extractor.common import Extractor, Message
|
||||||
@@ -184,7 +183,7 @@ class UpdateExtractor(Extractor):
|
|||||||
tag = channel
|
tag = channel
|
||||||
exact = True
|
exact = True
|
||||||
|
|
||||||
if re.match(r"\d\.\d+\.\d+", tag):
|
if util.re_compile(r"\d\.\d+\.\d+").match(tag):
|
||||||
tag = "v" + tag
|
tag = "v" + tag
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"""Helpers for interacting with youtube-dl"""
|
"""Helpers for interacting with youtube-dl"""
|
||||||
|
|
||||||
import re
|
|
||||||
import shlex
|
import shlex
|
||||||
import itertools
|
import itertools
|
||||||
from . import text, util, exception
|
from . import text, util, exception
|
||||||
@@ -258,13 +257,12 @@ def parse_command_line(module, argv):
|
|||||||
|
|
||||||
cookiesfrombrowser = getattr(opts, "cookiesfrombrowser", None)
|
cookiesfrombrowser = getattr(opts, "cookiesfrombrowser", None)
|
||||||
if cookiesfrombrowser:
|
if cookiesfrombrowser:
|
||||||
match = re.fullmatch(r"""(?x)
|
pattern = util.re(r"""(?x)
|
||||||
(?P<name>[^+:]+)
|
(?P<name>[^+:]+)
|
||||||
(?:\s*\+\s*(?P<keyring>[^:]+))?
|
(?:\s*\+\s*(?P<keyring>[^:]+))?
|
||||||
(?:\s*:\s*(?!:)(?P<profile>.+?))?
|
(?:\s*:\s*(?!:)(?P<profile>.+?))?
|
||||||
(?:\s*::\s*(?P<container>.+))?
|
(?:\s*::\s*(?P<container>.+))?""")
|
||||||
""", cookiesfrombrowser)
|
if match := pattern.fullmatch(cookiesfrombrowser):
|
||||||
if match:
|
|
||||||
browser, keyring, profile, container = match.groups()
|
browser, keyring, profile, container = match.groups()
|
||||||
if keyring is not None:
|
if keyring is not None:
|
||||||
keyring = keyring.upper()
|
keyring = keyring.upper()
|
||||||
@@ -524,7 +522,7 @@ def legacy_postprocessors(opts, module, ytdlp, compat_opts):
|
|||||||
if len(dur) == 2 and all(t is not None for t in dur):
|
if len(dur) == 2 and all(t is not None for t in dur):
|
||||||
remove_ranges.append(tuple(dur))
|
remove_ranges.append(tuple(dur))
|
||||||
continue
|
continue
|
||||||
remove_chapters_patterns.append(re.compile(regex))
|
remove_chapters_patterns.append(util.re(regex))
|
||||||
if opts.remove_chapters or sponsorblock_query:
|
if opts.remove_chapters or sponsorblock_query:
|
||||||
postprocessors.append({
|
postprocessors.append({
|
||||||
"key": "ModifyChapters",
|
"key": "ModifyChapters",
|
||||||
|
|||||||
Reference in New Issue
Block a user