diff --git a/.idea/.idea.Abyss/.idea/workspace.xml b/.idea/.idea.Abyss/.idea/workspace.xml index b91eebf..339cdcf 100644 --- a/.idea/.idea.Abyss/.idea/workspace.xml +++ b/.idea/.idea.Abyss/.idea/workspace.xml @@ -10,15 +10,8 @@ - - - - - - - - + - + @@ -254,7 +247,8 @@ - + + @@ -304,19 +298,6 @@ diff --git a/Abyss/Toolkits/update-video.py b/Abyss/Toolkits/update-video.py index 1e4864d..b112aa6 100644 --- a/Abyss/Toolkits/update-video.py +++ b/Abyss/Toolkits/update-video.py @@ -130,10 +130,12 @@ def find_video_in_dir(base_path): return None -def update_summary(base_path, name_input=None, author_input=None): +def update_summary(base_path, name_input=None, author_input=None, group_input=None): """ Updates the summary.json file for a given path. - name_input and author_input are optional, used for the '-a' mode. + name_input, author_input, group_input are optional, used for the '-a' mode. + If group_input is provided, the written summary.json will include the "group" key. + If summary.json already contains a "group" and group_input is None, existing group is preserved. """ summary_path = base_path / "summary.json" gallery_path = base_path / "gallery" @@ -154,18 +156,26 @@ def update_summary(base_path, name_input=None, author_input=None): "author": author_input if author_input is not None else "anonymous" } + existing_data = {} # Load existing summary if available if summary_path.exists(): try: with open(summary_path, 'r', encoding='utf-8') as f: existing_data = json.load(f) - # Update default with existing values + # Update default with existing values for known keys for key in default_summary: if key in existing_data: default_summary[key] = existing_data[key] except json.JSONDecodeError: print("Warning: Invalid JSON in summary.json, using defaults") + # Handle group: preserve existing if no new group provided; otherwise set new group + if group_input is not None: + default_summary["group"] = group_input + else: + if isinstance(existing_data, dict) and "group" in existing_data: + default_summary["group"] = existing_data["group"] + # Update duration from video file if found if video_path and video_path.exists(): default_summary["duration"] = get_video_duration(video_path) @@ -206,7 +216,8 @@ def main(): print("Usage: python script.py [arguments]") print("Commands:") print(" -u Update the summary.json in the specified path.") - print(" -a Add a new video project in a new directory under the specified path. Optional -y to accept defaults.") + print(" -a Add a new video project in a new directory under the specified path.") + print(" Optional flags for -a: -y (accept defaults anywhere), -g (set group in summary.json).") print(" -c