-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
30 lines (26 loc) · 871 Bytes
/
client.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
import requests
USER="admin"
PASS="admin"
SERVER_IP="192.168.1.10"
class Client(object):
cookie = ""
stream_url = ""
def __init__(self, user, password, ip):
assert user and password and ip, "Missing params"
self.user = user
self.password = password
self.ip = ip
def login(self):
url="http://{IP}/Login.cgi?Username={USER}&Password={PASSWORD}".format(IP=self.ip,USER=self.user,PASSWORD=self.password)
resp = requests.get(url)
data = resp.text.split(';')
params = {}
for i in data:
try:
k,v = i.split("=")
params[k] = v
except:
pass
self.cookie = params.get('Session-ID')
self.stream_url ="http://{IP}/Getvideo.cgi?Cookie={COOKIE}".format(IP=self.ip,COOKIE=self.cookie)
return params