Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# vim:sw=4:ts=4:et
import datetime
from amcrest import AmcrestCamera
amcrest = AmcrestCamera("192.168.1.10", 80, "admin", "super_password")
camera = amcrest.camera
end_time = datetime.datetime.now()
start_time = end_time - datetime.timedelta(hours=1)
for text in camera.find_files(start_time, end_time):
for line in text.split("\r\n"):
key, value = list(line.split("=", 1) + [None])[:2]
if key.endswith(".FilePath"):
print("Found file {}".format(value))
if value.endswith(".jpg"):
file_name = value
if file_name:
print("Downloading {}...".format(file_name))
with open("snapshot.jpg", "w") as file:
help='port to Amcrest camera. Default: 80')
parser.add_argument('--get-current-time',
action='store_true',
help='Get camera current time')
parser.add_argument('--motion-detection-status',
action='store_true',
help='Return motion detection status.')
parser.add_argument('--enable-motion-detection',
action='store_true',
help='Enable motion detection.')
parser.add_argument('--disable-motion-detection',
action='store_true',
help='Disable motion detection.')
args = parser.parse_args()
camera = AmcrestCamera(
args.hostname,
args.port,
args.username,
args.password
)
if args.get_current_time:
print(camera.get_current_time())
elif args.motion_detection_status:
print(camera.is_motion_detection_enabled())
elif args.enable_motion_detection:
if camera.is_motion_detection_enabled():
print("Nothing to do, motion detected, already enabled!")
return
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# vim:sw=4:ts=4:et
import datetime
from amcrest import AmcrestCamera
amcrest = AmcrestCamera("192.168.1.10", 80, "admin", "super_password")
camera = amcrest.camera
end_time = datetime.datetime.now()
start_time = end_time - datetime.timedelta(hours=1)
for text in camera.log_find(start_time, end_time):
print(text)