forked from baalajimaestro/auto-blob-updater
-
Notifications
You must be signed in to change notification settings - Fork 6
/
get_rom.py
33 lines (32 loc) · 1.08 KB
/
get_rom.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
from requests import get
from datetime import datetime as dt
import yaml
with open('violet.yml', 'wb') as load:
load.write(get("https://raw.githubusercontent.com/XiaomiFirmwareUpdater/xiaomifirmwareupdater.github.io/master/data/devices/latest/violet.yml").content)
fw = yaml.safe_load(open('violet.yml').read())
stable_date = dt.strptime(fw[1]["date"], "%Y-%m-%d")
weekly_date = dt.strptime(fw[2]["date"], "%Y-%m-%d")
if stable_date > weekly_date:
URL="https://bigota.d.miui.com/"
version=fw[1]["versions"]["miui"]
with open('/tmp/version','wb') as load:
load.write(str.encode(version))
URL+=version
URL+="/"
file=fw[1]["filename"]
file=file[10:]
URL+=file
print("Fetching Stable ROM......")
else:
URL="https://bigota.d.miui.com/"
version=fw[2]["versions"]["miui"]
with open('/tmp/version','wb') as load:
load.write(str.encode(version))
URL+=version
URL+="/"
file=fw[2]["filename"]
file=file[10:]
URL+=file
print("Fetching Weekly ROM......")
with open('rom.zip', 'wb') as load:
load.write(get(URL).content)