Added support for uploads with name prefix

This commit is contained in:
Erik Thuning 2024-09-06 11:40:59 +02:00
parent 11917608bb
commit f8ab46bac8

@ -23,13 +23,15 @@ class ArecProcessor(Preprocessor):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# This regex matches the name format for the individual channel files
# in a capture, which is this format: 1970_12_31_23_45_00_CH?_Name.mp4
# in a capture, which is this format:
# some-prefix_1970_12_31_23_45_00_CH?_Name.mp4
# The above ? represents a number between 1 and 4.
# Capture group 1 is only there to shorten the regex.
# Capture group 2 capures the channel number,
# capture group 3 captures the channel name.
# Capture group 1 is there to make the upload name prefix optional
# Capture group 2 is only there to shorten the regex.
# Capture group 3 capures the channel number,
# capture group 4 captures the channel name.
self.name_regex = re.compile(
'^\d{4}(_\d{2}){5}_CH([1-4])_([^.]+).mp4$')
'^([^_]+_)?\d{4}(_\d{2}){5}_CH([1-4])_([^.]+).mp4$')
def validate(self, queueitem):
if 'upload_dir' not in queueitem.keys():
@ -78,7 +80,7 @@ class ArecProcessor(Preprocessor):
for item in upload_dir.iterdir():
match = self.name_regex.match(item.name)
if match:
item_channel_no, item_channel_name = match.group(2, 3)
item_channel_no, item_channel_name = match.group(3, 4)
source = {'video': item.name,
'poster': '',
'playAudio': False}