Патч для замены текста ссылок в "поделиться"
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
{"enabled":true,"format":{"share_channel_text":"Канал: «%1$s»\n%2$schannel/%3$d","share_collection_text":"Коллекция: «%1$s»\n%2$scollection/%3$d","share_profile_text":"Профиль пользователя «%1$s»\n%2$sprofile/%3$d","share_release_text":"Релиз: «%1$s»\n%2$srelease/%3$d"}}
|
||||||
@@ -11,8 +11,8 @@ priority = -1
|
|||||||
|
|
||||||
# imports
|
# imports
|
||||||
import os
|
import os
|
||||||
from lxml import etree
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
from lxml import etree
|
||||||
from typing import Dict, Any
|
from typing import Dict, Any
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
"""
|
||||||
|
Изменяет формат "поделиться"
|
||||||
|
|
||||||
|
"selectable_text": {
|
||||||
|
"enabled": true,
|
||||||
|
"format": {
|
||||||
|
"share_channel_text": "Канал: «%1$s»\n%2$schannel/%3$d",
|
||||||
|
"share_collection_text": "Коллекция: «%1$s»\n%2$scollection/%3$d",
|
||||||
|
"share_profile_text": "Профиль пользователя «%1$s»\n%2$sprofile/%3$d",
|
||||||
|
"share_release_text": "Релиз: «%1$s»\n%2$srelease/%3$d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
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
|
||||||
|
DEFAULT_FORMATS = {
|
||||||
|
"share_channel_text": "Канал: «%1$s»\n%2$schannel/%3$d",
|
||||||
|
"share_collection_text": "Коллекция: «%1$s»\n%2$scollection/%3$d",
|
||||||
|
"share_profile_text": "Профиль пользователя «%1$s»\n%2$sprofile/%3$d",
|
||||||
|
"share_release_text": "Релиз: «%1$s»\n%2$srelease/%3$d"
|
||||||
|
}
|
||||||
|
|
||||||
|
class Config(PatchConfig):
|
||||||
|
format: Dict[str, str] = Field(DEFAULT_FORMATS)
|
||||||
|
|
||||||
|
# Patch
|
||||||
|
def apply(config: Config, base: Dict[str, Any]) -> bool:
|
||||||
|
|
||||||
|
file_path = "./decompiled/res/values/strings.xml"
|
||||||
|
|
||||||
|
parser = etree.XMLParser(remove_blank_text=True)
|
||||||
|
tree = etree.parse(file_path, parser)
|
||||||
|
root = tree.getroot()
|
||||||
|
|
||||||
|
for string in root.findall("string"):
|
||||||
|
name = string.get("name")
|
||||||
|
if name in config.format:
|
||||||
|
string.text = config.format[name]
|
||||||
|
|
||||||
|
# Сохраняем обратно
|
||||||
|
tree.write(file_path, encoding="utf-8", xml_declaration=True, pretty_print=True)
|
||||||
|
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user