|
|
@ -5,6 +5,8 @@ import struct |
|
|
|
import base64 |
|
|
|
|
|
|
|
NVR_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" |
|
|
|
NVR_TIME_FORMAT = "%H:%M:%S" |
|
|
|
NVR_DATE_FORMAT = "%Y-%m-%d" |
|
|
|
|
|
|
|
PRIMARY_STREAM = 0 |
|
|
|
SECONDARY_STREAM = 1 |
|
|
@ -22,9 +24,10 @@ class File: |
|
|
|
self.SerialNo = data.get("SerialNo") |
|
|
|
self.size = int(data.get("FileLength"), 0) * 1024 if "FileLength" in data else data.get("size", 0) |
|
|
|
self.filename = data.get("FileName", data.get("filename")) |
|
|
|
self.filename_cleared = self.filename.split("/")[-1].replace("[", "_").replace("]", "_").replace("@","_") |
|
|
|
self.channel = channel |
|
|
|
self.stream = stream |
|
|
|
self.type = "h264" |
|
|
|
self.filename_cleared = f"{self.begin.strftime(NVR_DATE_FORMAT)} {self.begin.strftime(NVR_TIME_FORMAT)} - {self.end.strftime(NVR_TIME_FORMAT)} ({self.channel}) ({self.stream})" |
|
|
|
|
|
|
|
def __str__(self) -> str: |
|
|
|
return f"{self.filename_cleared}/{self.size}/{self.channel}/{self.stream}" |
|
|
@ -41,7 +44,7 @@ class File: |
|
|
|
|
|
|
|
@property |
|
|
|
def json(self): |
|
|
|
return {"filename": self.filename_cleared, "size": self.size, "b64": self.to_b64.replace("==", "")} |
|
|
|
return {"filename": self.filename_cleared, "type": self.type, "size": self.size, "b64": self.to_b64.replace("==", "")} |
|
|
|
|
|
|
|
@staticmethod |
|
|
|
def from_b64(b64): |
|
|
|