-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate.py
77 lines (65 loc) · 1.83 KB
/
update.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
#!/usr/bin/python
import sys
import datetime
import string
import xdaapi
import re
def main(argc, argv):
i = 1
user=""
password=""
opdata=""
version=""
device=""
postid=""
title=""
showdate=""
while i < argc:
if argv[i] == "-u":
i+=1
user = argv[i]
elif argv[i] == "-p":
i+=1
password = argv[i]
elif argv[i] == "-v":
i+=1
version = argv[i]
elif argv[i] == "-d":
i+=1
device = argv[i]
elif argv[i] == "-i":
i+=1
postid = argv[i]
elif argv[i] == "-t":
i+=1
showdate= argv[i]
else:
print "Invalid argument " + argv[i]
return 1
i += 1
if not user or not password:
print "User name and password are required, use -u and -p arguments!"
return 1
if not version:
print "Version is required, use -v!"
return 1
if not showdate:
showdate = datetime.datetime.now().strftime("%Y-%m-%d").upper()
title = "[RECOVERY][%s] TWRP %s touch recovery [%s]" % (device, version, showdate)
if not device:
title = "[RECOVERY] TWRP %s touch recovery [%s]" % (version, showdate)
api=xdaapi.XdaApi()
api.login(user, password)
with open ("op.txt", "r") as opfile:
opdata=opfile.read()
list = open("list.txt", "r")
for line in list:
currdevice, postid = line.split("=", 1)
if not device or device == currdevice:
print "Working on " + currdevice
title = "[RECOVERY][%s] TWRP %s touch recovery [%s]" % (currdevice, version, showdate)
api.save_raw_post(postid, title, opdata)
api.logout_user()
return 0
if __name__ == "__main__":
exit(main(len(sys.argv), sys.argv))