-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount_video_progress.py
More file actions
57 lines (47 loc) · 1.96 KB
/
Copy pathcount_video_progress.py
File metadata and controls
57 lines (47 loc) · 1.96 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
from auto_ingest_config import get_fileserver_path
import os, re
from datetime import datetime
from moviepy.editor import *
def is_valid_date_structure(dir_name):
try:
# If the directory name can be converted to a date, it's valid
datetime.strptime(dir_name, "%Y/%m/%d")
return True
except ValueError:
# If a ValueError is raised, the directory name is not a date
return False
def list_files(directory):
file_keys = set([])
for filename in os.listdir(directory):
if re.search("_R.MP4", filename):
file_keys.add(filename.rsplit('.', 1)[0])
if re.search("_F.MP4", filename):
file_keys.add(filename.rsplit('.', 1)[0])
# file_keys_copy = file_keys.copy()
# for filename in file_keys_copy:
# if os.path.exists(f"{directory}/{filename}_YOLOv8n.csv"):
# file_keys.remove(filename)
# if os.path.exists(f"{directory}/{filename}_FR.MP4"):
# file_keys.remove(filename)
return sorted(list(file_keys))
def list_directories(base_path):
total = 0
for root, dirs, files in os.walk(base_path):
# print(root,dirs,files)
# Split the path to analyze if it ends with a YYYY/MM/DD structure
path_parts = root[len(base_path):].split(os.sep)
print(path_parts)
# Rejoin with the correct separator to normalize across OSes
normalized_path = "/".join(path_parts)
temp_path = root[len(base_path):]
if is_valid_date_structure(temp_path):
print(normalized_path)
# print(f"Valid directory structure found: {root}")
file_path = root
key_list = list_files(file_path)
print(f"{len(key_list)/2} Minutes")
total += len(key_list)
print(total)
print(f"Total Footage Count: {total/120} Hours")
base_directory = get_fileserver_path("video") # Adjust this path to your base directory
list_directories(base_directory)