@@ -56,7 +56,7 @@ def parse_filename(file_name):
56
56
# https://github.com/sven337/ReolinkLinux/wiki/Figuring-out-the-file-names#file-name-structure
57
57
pattern = r'.*?Mp4Record_(\d{4}-\d{2}-\d{2})_Rec[MS](\d)(\d)_(DST)?(\d{8})_(\d{6})_(\d{6})'
58
58
v3_suffix = r'.*_(\w{4,8})_(\w{4,8})\.mp4'
59
- v9_suffix = r'.*_(\d)_(\w{7})(\w{7})_(\w{4 ,8})\.mp4'
59
+ v9_suffix = r'.*_(\d)_(\w{7})(\w{7})_(\w{1 ,8})\.mp4'
60
60
match = re .match (pattern , file_name )
61
61
62
62
out = {}
@@ -375,8 +375,28 @@ def add_video(self, video_path):
375
375
# Find a potentially pre-existing channel0 item for this datetime, if so, add as a child
376
376
# This lets channel1 appear as a child, but also main & sub videos appear in the same group
377
377
channel_0_item = self .find_channel_0_item (start_datetime )
378
+
378
379
if channel_0_item :
379
- channel_0_item .addChild (video_item )
380
+ # Check if the current item is a main stream and the existing channel_0_item is a sub stream
381
+ if "RecM" in base_file_name and "RecS" in channel_0_item .text (1 ):
382
+ # Make the current main stream item the new parent
383
+ new_parent = video_item
384
+ # Move all children of the sub stream item to the new main stream item
385
+ while channel_0_item .childCount () > 0 :
386
+ child = channel_0_item .takeChild (0 )
387
+ new_parent .addChild (child )
388
+ # Remove the old sub stream item
389
+ parent = channel_0_item .parent ()
390
+ if parent :
391
+ parent .removeChild (channel_0_item )
392
+ else :
393
+ index = self .video_tree .indexOfTopLevelItem (channel_0_item )
394
+ self .video_tree .takeTopLevelItem (index )
395
+ # Add the new main stream item as a top-level item
396
+ self .video_tree .addTopLevelItem (new_parent )
397
+ else :
398
+ # If it's not a main stream replacing a sub stream, add as a child as before
399
+ channel_0_item .addChild (video_item )
380
400
else :
381
401
self .video_tree .addTopLevelItem (video_item )
382
402
@@ -424,6 +444,7 @@ def on_download_complete(self, video_path, success):
424
444
item = self .find_item_by_path (os .path .basename (video_path ))
425
445
if not item :
426
446
print (f"on_download_complete { video_path } did not find item?!" )
447
+ return
427
448
item .setForeground (1 , QBrush (QColor (0 , 0 , 0 ))) # Black color for normal text
428
449
font = item .font (1 )
429
450
font .setItalic (False )
@@ -592,7 +613,7 @@ def signal_handler(sig, frame):
592
613
signal .signal (signal .SIGINT , signal_handler )
593
614
594
615
parser = argparse .ArgumentParser (description = "Reolink Video Review GUI" )
595
- parser .add_argument ('--sub ' , action = 'store_true' , help = "Search for sub channel instead of main channel" )
616
+ parser .add_argument ('--main ' , action = 'store_true' , help = "Search for main channel instead of sub channel" )
596
617
parser .add_argument ('files' , nargs = '*' , help = "Optional video file names to process" )
597
618
args = parser .parse_args ()
598
619
@@ -609,7 +630,7 @@ def signal_handler(sig, frame):
609
630
start = dt .combine (dt .now (), dt .min .time ())
610
631
end = dt .now ()
611
632
612
- streamtype = 'sub' if args .sub else 'main'
633
+ streamtype = 'sub' if not args .main else 'main'
613
634
processed_motions = cam .get_motion_files (start = start , end = end , streamtype = streamtype , channel = 0 )
614
635
processed_motions += cam .get_motion_files (start = start , end = end , streamtype = streamtype , channel = 1 )
615
636
0 commit comments