MCPcopy
hub / github.com/Huanshere/VideoLingo / cleanup

Function cleanup

core/utils/onekeycleanup.py:6–40  ·  view source on GitHub ↗
(history_dir="history")

Source from the content-addressed store, hash-verified

4import shutil
5
6def cleanup(history_dir="history"):
7 # Get video file name
8 video_file = find_video_files()
9 video_name = video_file.split("/")[1]
10 video_name = os.path.splitext(video_name)[0]
11 video_name = sanitize_filename(video_name)
12
13 # Create required folders
14 os.makedirs(history_dir, exist_ok=True)
15 video_history_dir = os.path.join(history_dir, video_name)
16 log_dir = os.path.join(video_history_dir, "log")
17 gpt_log_dir = os.path.join(video_history_dir, "gpt_log")
18 os.makedirs(log_dir, exist_ok=True)
19 os.makedirs(gpt_log_dir, exist_ok=True)
20
21 # Move non-log files
22 for file in glob.glob("output/*"):
23 if not file.endswith(('log', 'gpt_log')):
24 move_file(file, video_history_dir)
25
26 # Move log files
27 for file in glob.glob("output/log/*"):
28 move_file(file, log_dir)
29
30 # Move gpt_log files
31 for file in glob.glob("output/gpt_log/*"):
32 move_file(file, gpt_log_dir)
33
34 # Delete empty output directories
35 try:
36 os.rmdir("output/log")
37 os.rmdir("output/gpt_log")
38 os.rmdir("output")
39 except OSError:
40 pass # Ignore errors when deleting directories
41
42def move_file(src, dst):
43 try:

Callers 4

process_videoFunction · 0.90
text_processing_sectionFunction · 0.85
audio_processing_sectionFunction · 0.85
onekeycleanup.pyFile · 0.85

Calls 3

find_video_filesFunction · 0.90
move_fileFunction · 0.85
sanitize_filenameFunction · 0.70

Tested by

no test coverage detected