Guest User

lockvideo.py

a guest
Apr 10th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. # USAGE
  2. # python lockvideo.py
  3.  
  4. # DESCRIPTION
  5. # This will connect to the specifiec NVR, and lock the listed videos
  6.  
  7. # import the necessary packages
  8. import requests
  9. import json
  10. import time
  11. from datetime import datetime
  12.  
  13. def lock(files):
  14.     #Basic vars
  15.     base = "https://<ip-of-nvr>:7443/api/2.0/recording/"
  16.     apiKey = "?apiKey=<nvr-api-key>"
  17.  
  18.     #Disable SSL warnings for now
  19.     requests.packages.urllib3.disable_warnings()
  20.  
  21.     for record in files:
  22.         record = record.split('-')
  23.         record = record[1].split('.')
  24.         recording = record[0]
  25.  
  26.         headers = {"Content-Type" : "application/json"}
  27.         r = requests.put(base+recording+apiKey, data = json.dumps({'locked':'true'}), headers=headers, verify=False)
Add Comment
Please, Sign In to add comment