fix: truncate YT vid title to 100 chars

This commit is contained in:
VC
2023-12-28 10:35:08 +01:00
parent ab9ea1a8ee
commit 9e1c27be29
3 changed files with 229 additions and 169 deletions

View File

@@ -6,7 +6,7 @@ use crate::{
use async_stream::stream;
use futures_util::StreamExt;
use indicatif::{ProgressBar, ProgressStyle};
use log::debug;
use log::{debug, warn};
use reqwest::{multipart::Form, Body, Client};
use serde::{Deserialize, Serialize};
use std::{cmp::min, error::Error, io::stdin};
@@ -309,10 +309,17 @@ pub async fn create_resumable_upload(
) -> Result<String, Box<dyn Error>> {
let access_token = refresh_token(config).await?;
if vid.name.chars().count() > 100 {
warn!(
"PT Video Title ({}) is too long, it will be truncated",
&vid.name
);
}
let upload_params = YoutubeUploadParams {
snippet: {
YoutubeUploadParamsSnippet {
title: vid.name.clone(),
title: vid.name.chars().take(100).collect::<String>(),
description: vid.description.clone(),
tags: vid.tags.clone(),
..Default::default()