Files
patcher/patches/change_server.py

22 lines
792 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Change api server"""
priority = 0
from tqdm import tqdm
import json
import requests
def apply(config: dict) -> bool:
response = requests.get(config['server'])
assert response.status_code == 200, f"Failed to fetch data {response.status_code} {response.text}"
for item in json.loads(response.text)['modifications']:
tqdm.write(f"Изменение {item['file']}")
filepath = './decompiled/smali_classes2/com/swiftsoft/anixartd/network/api/'+item['file']
with open(filepath, 'r') as f:
content = f.read()
with open(filepath, 'w') as f:
if content.count(item['src']) == 0:
tqdm.write(f"Не найдено {item['src']}")
f.write(content.replace(item['src'], item['dst']))
return True