-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatvify.py
127 lines (109 loc) · 3.89 KB
/
atvify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
from prompt_toolkit.shortcuts import radiolist_dialog
from prompt_toolkit.shortcuts import input_dialog
from prompt_toolkit.shortcuts import yes_no_dialog
from prompt_toolkit.shortcuts import message_dialog
from prompt_toolkit import print_formatted_text, HTML
from prompt_toolkit.styles import Style
import py7zr, os, shutil, time
width = shutil.get_terminal_size().columns
height = shutil.get_terminal_size().lines
lines = []
def center(text):
os.system('cls')
lines.append(text)
x = (width - max(map(len, lines))) // 2
y = (height - len(lines)) // 2
print('\n'*y)
for i, line in enumerate(lines):
print_formatted_text(HTML(' '*x+'<p color="white">'+line+'</p>'))
example_style = Style.from_dict({
'dialog': 'bg:#000000',
'dialog frame.label': 'bg:#000000',
'dialog.body': 'bg:#000000 #fff',
'dialog shadow': 'bg:#000000',
})
if os.listdir(os.getcwd()+'\\in'):
pass
else:
android = message_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Для продолжения закиньте Вашу прошивку в папку in и перезапустите скрипт",
style=example_style
).run()
exit()
android = radiolist_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Какую версию Android использует Ваша прошивка?",
values=[
("android_11", "Android 11"),
("android_9", "Android 9")
],
style=example_style
).run()
if android:
center('Распаковка файлов для замены...')
archive = py7zr.SevenZipFile(os.getcwd()+'\\bin\\'+android+'.7z', mode='r')
archive.extractall(path=os.getcwd()+'\\tmp\\')
archive.close()
pass
else:
exit()
bootanimation = radiolist_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Какую анимацию загрузки использовать?",
values=[
("bootanimation_atv", "Из Android TV"),
("bootanimation_2021", "Из Android TV 2021"),
("bootanimation_m", "Из Android 6.0 (Marshmallow)"),
("bootanimation_l", "Из Android 5.1 (Lollipop)"),
("stock", "Оставить стоковую")
],
style=example_style
).run()
if bootanimation:
center('Заменяю BootAnimation...')
dst = os.getcwd()+'\\tmp\\level2\\system\\system\\media'
os.remove(dst+'\\bootanimation.zip')
shutil.copy(os.getcwd()+'\\_bootanimations\\'+bootanimation+'.zip', dst+'\\bootanimation.zip')
time.sleep(5)
elif 'stock' == bootanimation:
pass
else:
exit()
screensaver = radiolist_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Какой ScreenSaver использовать?",
values=[
("aerial", "Aerial Dream (как из Apple TV)"),
("stock", "Оставить стандартный (Backdrop от Google)")
],
style=example_style
).run()
if screensaver:
if android == 'android_11':
dst = os.getcwd()+'\\tmp\\level2\\product\\app\\Backdrop'
else:
dst = os.getcwd()+'\\tmp\\level2\\system\\system\\app\\Backdrop'
center('Заменяю ScreenSaver...')
os.remove(dst+'\\Backdrop.apk')
shutil.copy(os.getcwd()+'\\_screensavers\\'+screensaver+'.apk', dst+'\\Backdrop.apk')
time.sleep(5)
elif 'stock' == screensaver:
pass
else:
exit()
start = yes_no_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Начать сборку прошивки?",
style=example_style
).run()
if start:
os.system('_aosp2atv-'+android+'.bat')
bye = message_dialog(
title=HTML('<style fg="green">ATV</style><style fg="white">ify</style>'),
text="Прошивка успешно собрана!",
style=example_style
).run()
exit()
else:
exit()