Delet a video by json

Post Reply
ben
Posts: 5
Joined: Fri Nov 22, 2019 3:49 pm

Delet a video by json

Post by ben »

Hi i like to do delet recorded videos by a json command
Blue Iris send told me with {delclip:@record#} it should work.
The number i record# i get back from a get request when i stop recording a video.
What i need more is that i probably have to give a authentification with as well.
I'm stuck with the command lin
Do you know how the code for python should be?

Am I on the right way with this one?:
URL = 'http://IP-Adress/admin?user=username&pw=password'

data = {'delclip':'@429152'}
r = requests.get(URL, headers={'Content-Type': 'application/json' }, json=data)
a = r.json()
print('\nResponse: \n')
print(a)

with that one i get an error back.. see picture..

Tanks for help :D
Attachments
Screenshot (30).png
Screenshot (30).png (47.26 KiB) Viewed 8685 times
Last edited by ben on Sat May 16, 2020 2:38 pm, edited 1 time in total.
User avatar
Thixotropic
Posts: 747
Joined: Wed Sep 04, 2019 7:20 pm
Location: Low-Earth Orbit

Re: Delet a video by json

Post by Thixotropic »

ben wrote: Thu May 14, 2020 11:39 am with that one i get an error back.. see picture..
I don't see a picture (??)
Blue Iris 5.x x64 | Windows 10 Pro x64 | 16GB RAM | i7-7700 3.6 GHz | 1TB HDD | 2TB RAID NAS | 9 Cameras | Almost Dual NIC | 2KVA UPS
User avatar
TimG
Posts: 2678
Joined: Tue Jun 18, 2019 10:45 am
Location: Nottinghamshire, UK.

Re: Delet a video by json

Post by TimG »

Since there is no broken link or URL, I wonder if that was a language thing, i.e. did he mean "Do you get the picture ?".
Forum Moderator.
Problem ? Ask and we will try to assist, but please check the Help file.
ben
Posts: 5
Joined: Fri Nov 22, 2019 3:49 pm

Re: Delet a video by json

Post by ben »

So now there is the picture ;D
ben
Posts: 5
Joined: Fri Nov 22, 2019 3:49 pm

Re: Delet a video by json

Post by ben »

So i got this:

URL = "http://user:Password@192.168.1.9:81/json"

r = requests.post(URL, data=json.dumps({"delclip":"@344249"}))
print(r.text)
print(r)

and the answer is this:
{"result":"fail"}
<Response [200]>

Do know what i have to change or add, so i can delet the video?
ben
Posts: 5
Joined: Fri Nov 22, 2019 3:49 pm

Re: Delet a video by json

Post by ben »

i figure it out hope i can help some one else with that.

import json
import hashlib
from urllib.request import Request, urlopen

def Send(request):
jsonRequest = json.dumps(request).encode('ascii')
request = Request(url, jsonRequest)
response = urlopen(request).read().decode()
jsonResponse = json.loads(response)
return jsonResponse

request = { "cmd": "login" }
response = Send(request)
#print(time.monotonic())
#print(response)
session = response["session"]

s = "yourUsername:" + session + ":youPassword"
hash = hashlib.md5(s.encode("utf-8")).hexdigest()
response = Send({ "cmd": "login", "session": session, "response": hash })
print(response)
request = { "cmd": "cliplist", "session": session, "camera":"Cam1"}
#request = { "cmd": "delclip", "session": session, "path":"@441991"}
response = Send(request)
print(response)

request = { "cmd": "logout", "session": session}
response = Send(request)
response
User avatar
Thixotropic
Posts: 747
Joined: Wed Sep 04, 2019 7:20 pm
Location: Low-Earth Orbit

Re: Delet a video by json

Post by Thixotropic »

Awesome, thank you for posting the solution.
Blue Iris 5.x x64 | Windows 10 Pro x64 | 16GB RAM | i7-7700 3.6 GHz | 1TB HDD | 2TB RAID NAS | 9 Cameras | Almost Dual NIC | 2KVA UPS
Post Reply