feat: add token refresh every 10 uploads

This commit is contained in:
2025-10-01 08:27:30 +03:00
parent d40e9b18ee
commit 393f4d44af
2 changed files with 4 additions and 1 deletions

View File

@@ -83,6 +83,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Upload videos
println!("\nUploading videos...");
for (i, (video_file, video_metadata)) in video_files.iter().zip(metadata.iter()).enumerate() {
if (i+1) % 10 == 0 {
uploader.authenticate().await?;
}
println!("Uploading {} ({}/{})", video_file, i + 1, video_files.len());
match uploader.upload_video(video_file, video_metadata).await {

View File

@@ -177,7 +177,7 @@ impl YouTubeUploader {
.ok_or("No access token in response")?
.to_string();
let expires_in = token_data["expires_in"].as_u64().unwrap_or(10800);
let expires_in = token_data["expires_in"].as_u64().unwrap_or(3600);
let expires_at = Some(Utc::now() + Duration::seconds(expires_in as i64));
Ok(StoredTokens {