本帖最后由 序幕七章 于 2019-2-21 08:49 编辑
下载思路和破解思路都是来自这个帖子,不过代码是自己写的
==================================
经测试:
- 我的手机能用是因为第三方MIUI ROM自带主题破解
- 其他人用会出现服务器错误
如果谁有真正的破解思路可以告诉我,我来实现
===================================
使用方法:粘贴主题地址即可,破解完成后导入手机,主题商店->我的主题->从SD卡导入
源码:
import os
import zipfile
import requests
import shutil
THEME_FILE = 'theme.zip'
THEME_FILE_EXTRACT_DIR = './'
CRACK_FILE = 'readme.txt'
PACKAGE_FILE = 'miui.zip'
FINAL_FILE = 'miui.mtz'
NOT_PACKAGE_FILE = ['miui.exe', 'miui.zip']
NOT_DELETE_FILE = ['miui.exe', 'miui.mtz']
old_url = 'http://zhuti.xiaomi.com/detail/'
new_url = 'http://thm.market.xiaomi.com/thm/download/v2/'
# 返回目录中所有文件名
# 因为zipfile不能直接打包目录
def list_file (pre, path):
files = []
for file in os.listdir(path):
if os.path.isdir(file):
p = pre + file + '/'
files += list_file(p, p)
else:
files.append(pre + file)
return files
# 清除多余文件
def clear (path):
for file in os.listdir(path):
if file not in NOT_DELETE_FILE:
if os.path.isdir(file):
shutil.rmtree(file)
else:
os.remove(file)
print('注意:使用时需先创建一个空文件夹(名字不包含中文)并将程序放到文件夹中运行')
ans = input('已满足要求?(y or n): ')
if ans != 'y':
os._exit()
url = input('输入主题地址: ')
url = url.replace(old_url, new_url)
data = requests.get(url).json()
downloadUrl = data['apiData']['downloadUrl']
print('正在下载主题...')
themeFile = requests.get(downloadUrl)
with open(THEME_FILE, 'wb') as f:
f.write(themeFile.content)
print('下载完成正在破解...')
zf = zipfile.ZipFile(THEME_FILE)
zf.extractall(THEME_FILE_EXTRACT_DIR)
zf.close()
with open(CRACK_FILE, 'w') as f:
f.write('CRACK')
theme_files = list_file('./', THEME_FILE_EXTRACT_DIR)
zf = zipfile.ZipFile(PACKAGE_FILE, mode='w')
for file in theme_files:
if file not in NOT_PACKAGE_FILE:
zf.write(file)
zf.close()
shutil.move(PACKAGE_FILE, FINAL_FILE)
clear('./')
print('破解完成,保存为: miui.mtz')
_t = input('按任意键退出')
工具:
文件5m上传不了,百度自取
链接: https://pan.baidu.com/s/1fMoUT42djc3TKNZToBFq8g 提取码: zfzf
|