-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxiaomi.py
More file actions
27 lines (24 loc) · 812 Bytes
/
Copy pathxiaomi.py
File metadata and controls
27 lines (24 loc) · 812 Bytes
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
# coding=utf8
import json
import datetime
import gzip
import StringIO
import time
def response(context, flow):
#print flow.request.content
if flow.request.path.find("hdinfo") != -1:
print '************'
txt = flow.response.content.replace('hdinfo(','').replace(')','')
print txt
obj = json.loads(txt)
obj['pmstart']=True
obj['stime']=obj['stime']+1000
print time.ctime(obj['stime'])
flow.response.content = 'hdinfo('+json.dumps(obj)+')'
elif flow.request.path.find("hdcontrol") != -1:
print '************'
txt = flow.response.content.replace('hdcontrol(','').replace(')','')
print txt
obj = json.loads(txt)
obj['pmstart']=True
flow.response.content = 'hdcontrol('+json.dumps(obj)+')'