1
0
mirror of https://github.com/mbirth/tcl_ota_check.git synced 2024-11-12 23:36:46 +00:00
This commit is contained in:
thurask 2017-08-05 10:59:11 -04:00 committed by GitHub
parent d603c4c267
commit 8ba67fb07e

View File

@ -26,6 +26,8 @@ def check(sess, serid, curef, fv="AAM481", mode=4, ftype="Firmware", cltp=2010,
req = sess.get(geturl, params=params) req = sess.get(geturl, params=params)
if req.status_code == 200: if req.status_code == 200:
return(req.text) return(req.text)
else:
raise SystemExit
def update_request(sess, serid, curef, tv, fwid, salt, vkh, fv="AAM481", mode=4, ftype="Firmware", cltp=2010): def update_request(sess, serid, curef, tv, fwid, salt, vkh, fv="AAM481", mode=4, ftype="Firmware", cltp=2010):
@ -34,6 +36,13 @@ def update_request(sess, serid, curef, tv, fwid, salt, vkh, fv="AAM481", mode=4,
req = sess.post(posturl, data=params) req = sess.post(posturl, data=params)
if req.status_code == 200: if req.status_code == 200:
return req.text return req.text
else:
raise SystemExit
def getcode(url):
req = requests.head(url)
return req.status_code
def vkhash(serid, curef, tv, fwid, salt, fv="AAM481", ftype="Firmware", mode=4, cltp=2010): def vkhash(serid, curef, tv, fwid, salt, fv="AAM481", ftype="Firmware", mode=4, cltp=2010):
@ -65,12 +74,12 @@ def parse_request(body):
if __name__ == "__main__": if __name__ == "__main__":
sess = prep_sess() sess = prep_sess()
serid = "543212345000000" serid = "543212345000000"
curef = "PRD-63116-001" curef = "PRD-63117-011"
checktext = check(sess, serid, curef) checktext = check(sess, serid, curef)
tv, fwid, filename, filesize, filehash = parse_check(checktext) tv, fwid, filename, filesize, filehash = parse_check(checktext)
salt = salt() salt = salt()
vkh = vkhash(serid, curef, tv, fwid, salt) vkh = vkhash(serid, curef, tv, fwid, salt)
updatetext = update_request(sess, serid, curef, tv, fwid, salt, vkh) updatetext = update_request(sess, serid, curef, tv, fwid, salt, vkh)
downloadurl = parse_request(updatetext) downloadurl = parse_request(updatetext)
print(filename) print("{0}: HTTP {1}".format(filename, getcode(downloadurl)))
print(downloadurl) print(downloadurl)