예제 #1
0
    def device_status(self, camera_id):
        data = {"channelId": camera_id}
        try:
            rec_data = requests.get(url=self.device_status_url,
                                    params=data,
                                    headers=self.auth_token)

            data = rec_data.json()
            return data
        except requests.exceptions.ConnectTimeout:
            return result.server_error(message='链接超时,请重试.')
        except:
            return result.server_error(message='请求失败,请重试.')
예제 #2
0
    def device_close(self, camera_id):
        data = {"channelId": camera_id, "type": 1}
        data = str(data).replace("'", "\"")
        try:
            rec_data = requests.put(url=self.close_url + "/" + camera_id,
                                    data=data,
                                    headers=self.auth_token)

            rec_data = rec_data.json()
            return rec_data
        except requests.exceptions.ConnectTimeout:
            return result.server_error(message='链接超时,请重试.')
        except:
            return result.server_error(message='请求失败,请重试.')
예제 #3
0
 def video_view(self, camera_id, begin_time, end_time):
     params = {
         "channelId": camera_id,
         "startTime": begin_time,
         "endTime": end_time
     }
     try:
         rec_data = requests.get(url=self.playback_url,
                                 params=params,
                                 headers=self.auth_token)
         rec_data = rec_data.json()
         return rec_data
     except requests.exceptions.ConnectTimeout:
         return result.server_error(message='链接超时,请重试.')
     except:
         return result.server_error(message='请求失败,请重试.')
예제 #4
0
    def rec_tree(self):
        try:

            rec_data = requests.get(url=self.dev_tree_url,
                                    headers=self.auth_token)
            data = rec_data.json()
            return data
        except requests.exceptions.ConnectTimeout:
            return result.server_error(message='链接超时,请重试.')
예제 #5
0
 def get_file(self, camera_id):
     params = {'channelId': camera_id}
     try:
         rec_data = requests.get(url=self.get_file_url,
                                 params=params,
                                 headers=self.auth_token)
         rec_data = rec_data.json()
         return rec_data
     except requests.exceptions.ConnectTimeout:
         return result.server_error(message='链接超时,请重试.')
예제 #6
0
 def token_auth(self, username, password):
     data = {'username': username, 'password': password}
     try:
         rec_data = requests.get(url=self.token_url,
                                 params=data,
                                 headers=self.auth_token)
         token = rec_data.headers['Token']
         return token
     except requests.exceptions.ConnectTimeout:
         return result.server_error(message='链接超时,请重试.')
     except:
         return data
예제 #7
0
 def live_view(self, camera_id):
     """
     获取直播地址
     :return:
     """
     params = {
         'channelId': camera_id,
         'protocol': "rtmp",
         "streamType": "0"
     }
     try:
         # print(params)
         rec_data = requests.get(url=self.live_url,
                                 params=params,
                                 headers=self.auth_token)
         return_data = rec_data.json()
         return return_data
     except requests.exceptions.ConnectTimeout:
         return result.server_error(message='链接超时,请重试.')
     except:
         return result.server_error(message='请求失败,请重试.')