feat: add upload options for pre-merge, merged, and standalone chat videos
- Updated global schema to include options for uploading original videos before merging, merged videos, and standalone chat videos. - Modified constants to set default values for new upload options. - Enhanced FileManager to handle new upload options, including conditional file uploads and deletions based on user configuration. - Introduced unit tests for command-line argument parsing, configuration loading, and merging logic, ensuring robust handling of new features. - Added tests for filtering logic, default configurations, and enabled streamer handling.
This commit is contained in:
parent
38d51636af
commit
0d3cdfd12c
6 changed files with 1128 additions and 23 deletions
|
|
@ -32,6 +32,9 @@ DEFAULT_CONFIG = {
|
|||
'mergeChatLayout': 'side-by-side', # Layout: 'side-by-side' or 'overlay'
|
||||
'vodTimeout': 300,
|
||||
'uploadCloud': True,
|
||||
'uploadPreMergeVideo': True, # Upload original videos before merging
|
||||
'uploadMergedVideo': True, # Upload merged videos (video + chat)
|
||||
'uploadChatVideo': False, # Upload standalone chat video
|
||||
'deleteFiles': False,
|
||||
'onlyRaw': False,
|
||||
'cleanRaw': True,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import subprocess
|
|||
from typing import List
|
||||
from colorama import Fore, Style
|
||||
|
||||
from .constants import PREFIX_LIVE, PREFIX_VOD, PREFIX_CHAT, PREFIX_METADATA
|
||||
from .constants import PREFIX_LIVE, PREFIX_VOD, PREFIX_CHAT, PREFIX_METADATA, PREFIX_MERGED
|
||||
from .utils import get_bin_path
|
||||
|
||||
|
||||
|
|
@ -28,6 +28,9 @@ class FileManager:
|
|||
self.root_path = pathlib.Path(root_path)
|
||||
self.username = username
|
||||
self.upload_cloud = config.get('uploadCloud', True)
|
||||
self.upload_pre_merge_video = config.get('uploadPreMergeVideo', True)
|
||||
self.upload_merged_video = config.get('uploadMergedVideo', True)
|
||||
self.upload_chat_video = config.get('uploadChatVideo', True)
|
||||
self.delete_files = config.get('deleteFiles', False)
|
||||
self.clean_raw = config.get('cleanRaw', True)
|
||||
self.download_vod = config.get('downloadVOD', True)
|
||||
|
|
@ -125,17 +128,35 @@ class FileManager:
|
|||
# Ensure temp directory exists
|
||||
os.makedirs(os.path.dirname(upload_list_path), exist_ok=True)
|
||||
|
||||
files_to_upload = [
|
||||
f"{PREFIX_LIVE}{filename_base}.ts",
|
||||
f"{PREFIX_LIVE}{filename_base}.mp4",
|
||||
f"{PREFIX_LIVE}{filename_base}.mp3",
|
||||
f"{PREFIX_VOD}{filename_base}.ts",
|
||||
f"{PREFIX_VOD}{filename_base}.mp4",
|
||||
f"{PREFIX_VOD}{filename_base}.mp3",
|
||||
f"{PREFIX_METADATA}{filename_base}.json",
|
||||
f"{PREFIX_CHAT}{filename_base}.json",
|
||||
f"{PREFIX_CHAT}{filename_base}.mp4"
|
||||
]
|
||||
files_to_upload = []
|
||||
|
||||
# Always include metadata and chat JSON
|
||||
files_to_upload.append(f"{PREFIX_METADATA}{filename_base}.json")
|
||||
files_to_upload.append(f"{PREFIX_CHAT}{filename_base}.json")
|
||||
|
||||
# Add pre-merge videos (original LIVE and VOD files)
|
||||
if self.upload_pre_merge_video:
|
||||
files_to_upload.extend([
|
||||
f"{PREFIX_LIVE}{filename_base}.ts",
|
||||
f"{PREFIX_LIVE}{filename_base}.mp4",
|
||||
f"{PREFIX_LIVE}{filename_base}.mp3",
|
||||
f"{PREFIX_VOD}{filename_base}.ts",
|
||||
f"{PREFIX_VOD}{filename_base}.mp4",
|
||||
f"{PREFIX_VOD}{filename_base}.mp3"
|
||||
])
|
||||
|
||||
# Add merged videos
|
||||
if self.upload_merged_video:
|
||||
files_to_upload.extend([
|
||||
f"{PREFIX_MERGED}{filename_base}.mp4",
|
||||
f"{PREFIX_MERGED}{filename_base}.mp3",
|
||||
f"{PREFIX_MERGED}{PREFIX_VOD}{filename_base}.mp4",
|
||||
f"{PREFIX_MERGED}{PREFIX_VOD}{filename_base}.mp3"
|
||||
])
|
||||
|
||||
# Add standalone chat video
|
||||
if self.upload_chat_video:
|
||||
files_to_upload.append(f"{PREFIX_CHAT}{filename_base}.mp4")
|
||||
|
||||
with open(upload_list_path, 'w') as f:
|
||||
f.write('\n'.join(files_to_upload))
|
||||
|
|
@ -175,6 +196,8 @@ class FileManager:
|
|||
"""
|
||||
Delete local archive files after successful upload.
|
||||
|
||||
Only deletes files that were configured to be uploaded.
|
||||
|
||||
Args:
|
||||
filename_base: Base filename (without prefixes/extensions)
|
||||
live_raw_path: Path to live raw file
|
||||
|
|
@ -191,14 +214,15 @@ class FileManager:
|
|||
|
||||
files_to_delete: List[str] = []
|
||||
|
||||
# Live files
|
||||
if not self.clean_raw and os.path.exists(live_raw_path):
|
||||
files_to_delete.append(live_raw_path)
|
||||
if os.path.exists(live_proc_path):
|
||||
files_to_delete.append(live_proc_path)
|
||||
# Live files (only if pre-merge videos are uploaded)
|
||||
if self.upload_pre_merge_video:
|
||||
if not self.clean_raw and os.path.exists(live_raw_path):
|
||||
files_to_delete.append(live_raw_path)
|
||||
if os.path.exists(live_proc_path):
|
||||
files_to_delete.append(live_proc_path)
|
||||
|
||||
# VOD files
|
||||
if self.download_vod:
|
||||
# VOD files (only if pre-merge videos are uploaded)
|
||||
if self.download_vod and self.upload_pre_merge_video:
|
||||
vod_raw = self.raw_path / f"{PREFIX_VOD}{filename_base}.ts"
|
||||
vod_mp4 = self.video_path / f"{PREFIX_VOD}{filename_base}.mp4"
|
||||
vod_mp3 = self.video_path / f"{PREFIX_VOD}{filename_base}.mp3"
|
||||
|
|
@ -210,17 +234,37 @@ class FileManager:
|
|||
if vod_mp3.exists():
|
||||
files_to_delete.append(str(vod_mp3))
|
||||
|
||||
# Merged video files (only if merged videos are uploaded)
|
||||
if self.upload_merged_video:
|
||||
merged_live_mp4 = self.video_path / f"{PREFIX_MERGED}{filename_base}.mp4"
|
||||
merged_live_mp3 = self.video_path / f"{PREFIX_MERGED}{filename_base}.mp3"
|
||||
merged_vod_mp4 = self.video_path / f"{PREFIX_MERGED}{PREFIX_VOD}{filename_base}.mp4"
|
||||
merged_vod_mp3 = self.video_path / f"{PREFIX_MERGED}{PREFIX_VOD}{filename_base}.mp3"
|
||||
|
||||
if merged_live_mp4.exists():
|
||||
files_to_delete.append(str(merged_live_mp4))
|
||||
if merged_live_mp3.exists():
|
||||
files_to_delete.append(str(merged_live_mp3))
|
||||
if merged_vod_mp4.exists():
|
||||
files_to_delete.append(str(merged_vod_mp4))
|
||||
if merged_vod_mp3.exists():
|
||||
files_to_delete.append(str(merged_vod_mp3))
|
||||
|
||||
# Chat files
|
||||
if self.download_chat:
|
||||
chat_json = self.chat_json_path / f"{PREFIX_CHAT}{filename_base}.json"
|
||||
chat_mp4 = self.chat_mp4_path / f"{PREFIX_CHAT}{filename_base}.mp4"
|
||||
|
||||
# Always delete JSON (it's always uploaded)
|
||||
if chat_json.exists():
|
||||
files_to_delete.append(str(chat_json))
|
||||
if chat_mp4.exists():
|
||||
files_to_delete.append(str(chat_mp4))
|
||||
|
||||
# Only delete chat MP4 if chat videos are uploaded
|
||||
if self.upload_chat_video:
|
||||
chat_mp4 = self.chat_mp4_path / f"{PREFIX_CHAT}{filename_base}.mp4"
|
||||
if chat_mp4.exists():
|
||||
files_to_delete.append(str(chat_mp4))
|
||||
|
||||
# Metadata files
|
||||
# Metadata files (always uploaded)
|
||||
if self.download_metadata:
|
||||
metadata = self.metadata_path / f"{PREFIX_METADATA}{filename_base}.json"
|
||||
if metadata.exists():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue