From ab9fb6ac54bc52b1a01673090517841322cb0789 Mon Sep 17 00:00:00 2001 From: Alessandro Colomba Date: Sat, 15 May 2021 14:05:57 -0400 Subject: [PATCH] supports finer event types in new firmare (11 may 2021) see: https://blackvue.com/major-update-improved-blackvue-app-ui-dark-mode-live-event-upload-and-more/ #3 --- blackvuesync.py | 26 ++++++++++++++++++++++---- test/blackvue_emu/blackvue_emu.py | 13 +++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/blackvuesync.py b/blackvuesync.py index 1c6bf86..1245250 100755 --- a/blackvuesync.py +++ b/blackvuesync.py @@ -107,10 +107,28 @@ def calc_cutoff_date(keep): Recording = namedtuple("Recording", "filename base_filename group_name datetime type direction extension") # dashcam recording filename regular expression +# references: +# https://www.blackvue.com.sg/uploads/8/4/4/2/8442586/manual_dr750s-2ch_en_web_ver.1.00_12.pdf +# https://blackvue.com/major-update-improved-blackvue-app-ui-dark-mode-live-event-upload-and-more/ +# N: Normal +# E: Event +# P: Parking motion detection +# M: Manual +# I: Parking impact +# O: Overspeed +# A: Hard acceleration +# T: Hard cornering +# B: Hard braking +# R: Geofence-enter +# X: Geofence-exit +# G: Geofence-pass +# +# L or S: upload flag, Substream or Live filename_re = re.compile(r"""(?P(?P\d\d\d\d)(?P\d\d)(?P\d\d) _(?P\d\d)(?P\d\d)(?P\d\d)) - _(?P[NEPM]) + _(?P[NEPMIOATBRXG]) (?P[FR]) + (?P[LS]?) \.(?Pmp4)""", re.VERBOSE) @@ -323,12 +341,12 @@ def sort_recordings(recordings, recording_priority): """sorts recordings in place according to the given priority""" def datetime_sort_key(recording): - """sorts by datetime, then recording type, then front/rear direction""" + """sorts by datetime, then front/rear direction, then recording type""" return recording.datetime, "FR".find(recording.direction) def manual_event_sort_key(recording): - """sorts by recording type, then datetime, then front/rear direction""" - return "MENP".find(recording.type), recording.datetime, "FR".find(recording.direction) + """sorts by recording type (manual and events first), then datetime, then front/rear direction""" + return "MEIBOATRXGNP".find(recording.type), recording.datetime, "FR".find(recording.direction) if recording_priority == "date": # least recent first diff --git a/test/blackvue_emu/blackvue_emu.py b/test/blackvue_emu/blackvue_emu.py index a377870..4956047 100644 --- a/test/blackvue_emu/blackvue_emu.py +++ b/test/blackvue_emu/blackvue_emu.py @@ -13,8 +13,9 @@ # dashcam filename pattern filename_re = re.compile(r"""(?P(?P\d\d\d\d)(?P\d\d)(?P\d\d) _(?P\d\d)(?P\d\d)(?P\d\d)) - _(?P[NEPM]) + _(?P[NEPMIOATBRXG]) (?P[FR]?) + (?P[LS]?) \.(?P(3gf|gps|mp4|thm))""", re.VERBOSE) @@ -48,10 +49,18 @@ def generate_recording_filenames(day_range=3): for date in [today - datetime.timedelta(day) for day in range(0, day_range)]: for hour in [9, 18]: - for minutes in range(10, 25): + for minutes in range(10, 25, 3): for direction in ["F", "R"]: yield "%04d%02d%02d_%02d%02d%02d_N%s.mp4" % (date.year, date.month, date.day, hour, minutes, 0, direction) + for minutes in range(11, 25, 3): + for direction in ["F", "R"]: + yield "%04d%02d%02d_%02d%02d%02d_E%s.mp4" % (date.year, date.month, date.day, hour, minutes, 0, + direction) + for minutes in range(13, 25, 3): + for direction in ["F", "R"]: + yield "%04d%02d%02d_%02d%02d%02d_A%sL.mp4" % (date.year, date.month, date.day, hour, minutes, 0, + direction) @app.route("/blackvue_vod.cgi", methods=['GET'])