update readne

This commit is contained in:
CodeDevMLH
2025-09-25 23:02:51 +02:00
parent 4ed0e2948d
commit 8d57c3d97e

View File

@@ -41,6 +41,7 @@ Below is an overview of its main functionality and usage:
- Operations include:
- Inserting text before or after specific content.
- Replacing old text with new text.
- NEW: Regex support (prefix markers with `re:`) for `before_text`, `after_text`, and `old_text` to handle dynamical hashes (e.g. Jellyfin assets)
- Recursively applies changes to files matching specified patterns in the destination directory.
5. **Error and Warning Tracking**:
@@ -84,13 +85,17 @@ copy_rules:
modification_rules:
- file_pattern: "*.js" # Files to modify (supports regex)
insert_rules:
- after_text: "search text" # Insert after this text
- after_text: "search text" # Insert after this exact (plain) text
insert_text: "new content"
- before_text: "target" # Insert before this text
- before_text: "target" # Insert before this exact (plain) text
insert_text: "new content"
- before_text: 're:<link href="main\\.jellyfin\\.[^"]+\\.css[^"]*" rel="stylesheet">' # Regex variant
insert_text: "<script>// injected</script>"
replace_rules:
- old_text: "original" # Text to replace
- old_text: "original" # Plain substring replacement
new_text: "replacement"
- old_text: 're:<link href="main\\.jellyfin\\.[^"]+\\.css[^"]*" rel="stylesheet">'
new_text: 're:<link href="newMain\\.newJellyfin\\.[^"]+\\.css[^"]*" rel="stylesheet">'
```
### Running the Script
@@ -102,3 +107,18 @@ So for example:
```bash
python customize-WebUI.py config.yaml
```
### Regex Markers Cheat Sheet
Prefix any marker with `re:` to interpret it as a Python Regex (DOTALL activ):
Examples:
```
before_text: 're:<link href="main\\.jellyfin\\.[^"]+\\.css[^"]*" rel="stylesheet">'
after_text: 're:data-backdroptype="movie,series,book">'
old_text: 're:this\\.get\("libraryPageSize",!1\),10\);return 0===t\?0:t\|\|100}'
```
Notes:
1. Properly escape backslashes (YAML + Regex!)
2. The first match will be used (count=1 for replacement/insertion)
3. Idempotency: The script checks whether the insertion or replacement text already exists to avoid duplicates