-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
154 lines (120 loc) · 4.34 KB
/
main.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import inquirer
from modules.GitHubAPI import DownloadFiles
from modules.PatchesParser import ParsePatches
from modules.ApkMirror.Scraper import *
from modules.ApkMirror.ApkFileDownloader import *
from modules.PatcherProcess import RunPatcher
from modules.ADB import CheckForRoot, GetPackageVersion
from modules.JavaChecker import CheckJDKInstalled
from modules.PatchRememberer import *
import os
import modules.Configuration
config = modules.Configuration.Configuration()
selectedApp = {}
def main():
if not os.path.exists('revanced'):
os.mkdir('./revanced')
if not CheckJDKInstalled():
ExitApp()
print('Welcome to ReVanced Builder PY! Please wait while Builder updates files.')
DownloadFiles(config)
ParsePatches(None, config)
apps = FetchPackages(config)
appList = []
for app in apps:
appList.append((app['appName'], app))
questions = [
inquirer.List(
"app",
message="Please select the app you want to patch",
choices=appList,
),
]
answers = inquirer.prompt(questions)
if answers == None:
ExitApp()
selectedApp = answers['app']
ParsePatches(answers['app']['appPackage'], config)
questions = [
inquirer.List(
"patches",
message="Would you like to choose the patches yourself or choose the recommended patches",
choices=[
("Select recommended patches", True),
("Select patches", False)
],
),
]
answers = inquirer.prompt(questions)
if answers == None:
ExitApp()
patchList = []
if answers['patches']:
patches = config.GetPatches()['patches']
for patch in config.GetPatches()['patches']:
if patch['recommended']:
patchList.append(patch['name'])
config.SetPatches('patches', patchList)
else:
selectedPatches = LoadPatches(selectedApp['appPackage'])
for patch in config.GetPatches()['patches']:
patchList.append(
(f"{patch['name']}\n {patch['desc']}\n\n", patch['name']))
questions = [
inquirer.Checkbox(
"patches",
message="Please select the patches you want",
choices=patchList,
default=selectedPatches
),
]
answers = inquirer.prompt(questions)
if answers == None:
ExitApp()
WritePatches(selectedApp['appPackage'], answers['patches'])
config.SetPatches('patches', answers['patches'])
if (selectedApp['appPackage'] == 'com.google.android.youtube'
and 'vanced-microg-support' not in answers['patches']) or (selectedApp['appPackage'] == 'com.google.android.apps.youtube.music'
and 'music-microg-support' not in answers['patches']):
deviceId = CheckForRoot()
if not deviceId:
ExitApp()
else:
DownloadAPK(
re.sub('\.', '-', GetPackageVersion(selectedApp), selectedApp))
RunPatcher(config, selectedApp)
if os.path.exists(f"revanced/{selectedApp['appPackage']}.apk"):
questions = [
inquirer.Confirm(
"downloadAPK",
message="APK File already exists, do you want to download an another version"
)
]
answers = inquirer.prompt(questions)
if answers == None:
ExitApp()
if not answers['downloadAPK']:
RunPatcher(config, selectedApp)
ExitApp()
versions = FetchVersions(selectedApp, config)
versionList = []
backslashChar = "\\"
for version in versions:
versionList.append(
(f"{re.sub(f'{backslashChar}-', '.', version['versionName'])} {'(Recommended)' if version['recommended'] else ''}", version))
questions = [
inquirer.List(
"version",
message="Please select the version you want to patch",
choices=versionList,
),
]
answers = inquirer.prompt(questions)
if answers == None:
ExitApp()
DownloadAPK(answers['version']['versionName'], selectedApp)
RunPatcher(config, selectedApp)
ExitApp()
def ExitApp():
input("Press any key to exit...")
quit(0)