feat: add the newly added video to playlists if any

This commit is contained in:
VC
2023-10-14 22:45:08 +02:00
parent 8d4d683f55
commit ebc42f915d
5 changed files with 178 additions and 9 deletions

View File

@@ -13,7 +13,7 @@ use peertube::{get_latest_video, get_max_resolution_dl};
mod youtube;
pub use youtube::register;
use youtube::{create_resumable_upload, now_kiss};
use youtube::{add_video_to_playlists, create_resumable_upload, now_kiss};
async fn get_dl_video_stream(
u: &str,
@@ -22,7 +22,7 @@ async fn get_dl_video_stream(
}
#[tokio::main]
pub async fn run(config: Config) {
pub async fn run(config: Config, pl: Vec<String>) {
// Get the latest video object
let latest_vid = get_latest_video(&config.peertube.base_url)
.await
@@ -40,7 +40,13 @@ pub async fn run(config: Config) {
.await
.unwrap_or_else(|e| panic!("Cannot retrieve the uploads resumable id: {e}"));
now_kiss(pt_stream, &resumable_upload_url, &config.youtube)
let yt_video_id = now_kiss(pt_stream, &resumable_upload_url, &config.youtube)
.await
.unwrap_or_else(|e| panic!("Cannot resume upload!: {e}"));
if !pl.is_empty() {
add_video_to_playlists(&config.youtube, &yt_video_id, &pl)
.await
.unwrap_or_else(|e| panic!("Cannot add video to playlist(s): {e}"));
}
}