refactor: move print schedule to own function

This commit is contained in:
LinlyBoi
2025-07-10 13:02:58 +03:00
parent 549277c73d
commit 8bc17a3af3
2 changed files with 19 additions and 16 deletions

View File

@@ -158,3 +158,17 @@ pub fn expand_tilde(path: &str) -> String {
path.to_string() path.to_string()
} }
} }
pub fn print_schedule(video_files: &Vec<String>, schedule: &Vec<DateTime<Utc>>) {
// Display schedule
println!("Upload Schedule:");
println!("================");
for (i, (video_file, scheduled_time)) in video_files.iter().zip(schedule.iter()).enumerate() {
println!(
"{}. {} -> {}",
i + 1,
video_file,
scheduled_time.format("%Y-%m-%d %H:%M:%S UTC")
);
}
}

View File

@@ -22,18 +22,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let oauth_config_path = args.oauth_config(); let oauth_config_path = args.oauth_config();
let oauth_config = load_oauth_config(oauth_config_path)?; let oauth_config = load_oauth_config(oauth_config_path)?;
let start_time = if let Some(start_str) = matches.get_one::<String>("start-time") { let start_time = if let Some(start_str) = args.start_time() {
Some(DateTime::parse_from_rfc3339(start_str)?.with_timezone(&Utc)) Some(DateTime::parse_from_rfc3339(start_str)?.with_timezone(&Utc))
} else { } else {
None None
}; };
let timestamp_file = matches.get_one::<String>("timestamp-file"); let timestamp_file = args.timestamp_file();
let dry_run = matches.get_flag("dry-run"); let dry_run = args.dry_run();
// Load or create metadata // Load or create metadata
let mut metadata = if let Some(metadata_path) = matches.get_one::<String>("metadata") { let mut metadata = if let Some(metadata_path) = args.timestamp_file() {
load_video_metadata(metadata_path)? load_video_metadata(metadata_path)?
} else { } else {
create_default_metadata(&video_files) create_default_metadata(&video_files)
@@ -54,18 +54,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
metadata[i].privacy_status = "private".to_string(); // Set to private for scheduling metadata[i].privacy_status = "private".to_string(); // Set to private for scheduling
} }
} }
print_schedule(&video_files, &schedule);
// Display schedule
println!("Upload Schedule:");
println!("================");
for (i, (video_file, scheduled_time)) in video_files.iter().zip(schedule.iter()).enumerate() {
println!(
"{}. {} -> {}",
i + 1,
video_file,
scheduled_time.format("%Y-%m-%d %H:%M:%S UTC")
);
}
if dry_run { if dry_run {
println!("\nDry run complete. No videos were uploaded."); println!("\nDry run complete. No videos were uploaded.");