-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathformat_parser.py
More file actions
66 lines (59 loc) · 2.71 KB
/
format_parser.py
File metadata and controls
66 lines (59 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from data_types import *
import re
def old_extron_format_parser(filepath: str) -> LectureRecording or None:
filename = os.path.basename(filepath)
extron_pattern = r'(\d+)_Rec\d+_.*?_(\d{8})-(\d{6})_[sS]1[rR]1.mp4'
match_extron = re.match(extron_pattern, filename)
if match_extron:
room_number, rec_date, rec_time = match_extron.groups()
dt = datetime.strptime(f'{rec_date}{rec_time}', '%Y%m%d%H%M%S')
rec = LectureRecording(filepath, dt.date(), dt.time(), room_number, 'extron')
return rec
else:
return None
def extron_format_parser(filepath: str) -> LectureRecording or None:
filename = os.path.basename(filepath)
extron_pattern = r'(\d+)_.*?_(\d{8})-(\d{6})_[sS]1[rR]1.mp4'
match_extron = re.match(extron_pattern, filename)
if match_extron:
room_number, rec_date, rec_time = match_extron.groups()
dt = datetime.strptime(f'{rec_date}{rec_time}', '%Y%m%d%H%M%S')
rec = LectureRecording(filepath, dt.date(), dt.time(), room_number, 'extron')
return rec
else:
return None
def capturecast_format_parser(filepath: str) -> LectureRecording or None:
filename = os.path.basename(filepath)
capturecast_pattern = r'(\w+)-(\d+)-(\d+)---(\d{1,2})-(\d{1,2})-(\d{4}).mp4'
match_capturecast = re.match(capturecast_pattern, filename)
if match_capturecast:
course_code, course_number, section_number, month, day, year = match_capturecast.groups()
rec_date = date(int(year), int(month), int(day))
rec = LectureRecording(filepath, rec_date, None, None, 'capturecast', course_number, section_number, course_code)
return rec
else:
return None
def extron_2100_format_parser(filepath: str) -> LectureRecording or None:
filename = os.path.basename(filepath)
extron_2100_pattern = r'SMP-2100_(\d{8})-(\d{6})_[sS]1[rR]1.mp4'
match_extron_2100 = re.match(extron_2100_pattern, filename)
if match_extron_2100:
rec_date, rec_time = match_extron_2100.groups()
room_number = '2100'
dt = datetime.strptime(f'{rec_date}{rec_time}', '%Y%m%d%H%M%S')
rec = LectureRecording(filepath, dt.date(), dt.time(), room_number, 'extron_2100')
return rec
else:
return None
# CURRENTLY UNUSED
def manual_format_parser(filepath: str) -> Recording or None:
filename = os.path.basename(filepath)
pattern = r'((?:u\d{7} )+)(.+)'
match_pattern = re.match(pattern, filename)
if match_pattern:
unids, metadata = match_pattern.groups()
dt = datetime.fromtimestamp(os.stat().st_mtime)
rec = ManualRecording(filepath, 'manual', dt.date(), dt.time(), metadata, unids.split(' '))
return rec
else:
return None