add separate video loader class
This commit is contained in:
27
recording_grouper.py
Normal file
27
recording_grouper.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from data.library import ArkiteData
|
||||
from string import digits as DIGITS
|
||||
|
||||
class RecordingGrouper:
|
||||
def __init__(self, data: ArkiteData):
|
||||
self.data = data
|
||||
|
||||
def getRecordings(self):
|
||||
for detection in self.data.detections(self.data.use_cases()):
|
||||
for recording in detection.recordings():
|
||||
yield recording
|
||||
|
||||
def getRecordingGroups(self):
|
||||
groups = []
|
||||
for recording in self.getRecordings():
|
||||
# Check if last char is digit
|
||||
name = recording.name
|
||||
if name[-1] in DIGITS:
|
||||
# Remove last two chars:
|
||||
splitname = name[:-2]
|
||||
group = next((x for x in groups if x[0] == splitname), None)
|
||||
if group is not None:
|
||||
group[1].append(recording)
|
||||
else:
|
||||
groups.append((splitname, [recording]))
|
||||
|
||||
return groups
|
||||
Reference in New Issue
Block a user