Патч для выделения информации о релизе

This commit is contained in:
2025-10-02 10:32:51 +03:00
parent fbc8b3e017
commit 19e1ce2f45
4 changed files with 45 additions and 20 deletions
+43
View File
@@ -0,0 +1,43 @@
"""
Делает текст в описании аниме копируемым
"selectable_text": {
"enabled": true
}
"""
priority = 0
# imports
from tqdm import tqdm
from lxml import etree
from typing import Dict, Any
from pydantic import Field
from utils.config import PatchConfig
#Config
class Config(PatchConfig): ...
# Patch
def apply(config: Config, base: Dict[str, Any]) -> bool:
file_path = "./decompiled/res/layout/release_info.xml"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(file_path, parser)
root = tree.getroot()
# Список тегов, к которым нужно добавить атрибут
tags = ["TextView", "at.blogc.android.views.ExpandableTextView"]
for tag in tags:
for element in root.findall(f".//{tag}", namespaces=base["xml_ns"]):
# Проверяем, нет ли уже атрибута
if f"{{{base['xml_ns']['android']}}}textIsSelectable" not in element.attrib:
element.set(f"{{{base['xml_ns']['android']}}}textIsSelectable", "true")
# Сохраняем обратно
tree.write(file_path, encoding="utf-8", xml_declaration=True, pretty_print=True)
return True