feat: add token refresh every 10 uploads
This commit is contained in:
@@ -83,6 +83,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Upload videos
|
// Upload videos
|
||||||
println!("\nUploading videos...");
|
println!("\nUploading videos...");
|
||||||
for (i, (video_file, video_metadata)) in video_files.iter().zip(metadata.iter()).enumerate() {
|
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());
|
println!("Uploading {} ({}/{})", video_file, i + 1, video_files.len());
|
||||||
|
|
||||||
match uploader.upload_video(video_file, video_metadata).await {
|
match uploader.upload_video(video_file, video_metadata).await {
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ impl YouTubeUploader {
|
|||||||
.ok_or("No access token in response")?
|
.ok_or("No access token in response")?
|
||||||
.to_string();
|
.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));
|
let expires_at = Some(Utc::now() + Duration::seconds(expires_in as i64));
|
||||||
|
|
||||||
Ok(StoredTokens {
|
Ok(StoredTokens {
|
||||||
|
|||||||
Reference in New Issue
Block a user