mirror of
https://framagit.org/veretcle/tootube.git
synced 2025-07-20 12:31:19 +02:00
feat: add relevant debug bits
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use bytes::Bytes;
|
||||
use futures_core::stream::Stream;
|
||||
use log::debug;
|
||||
use std::error::Error;
|
||||
|
||||
mod error;
|
||||
@@ -31,6 +32,7 @@ pub async fn run(config: Config, pl: Vec<String>) {
|
||||
});
|
||||
|
||||
let dl_url = get_max_resolution_dl(latest_vid.streaming_playlists.as_ref().unwrap());
|
||||
debug!("PT download URL: {}", &dl_url);
|
||||
|
||||
let pt_stream = get_dl_video_stream(&dl_url)
|
||||
.await
|
||||
@@ -39,10 +41,12 @@ pub async fn run(config: Config, pl: Vec<String>) {
|
||||
let resumable_upload_url = create_resumable_upload(&config.youtube, &latest_vid)
|
||||
.await
|
||||
.unwrap_or_else(|e| panic!("Cannot retrieve the upload’s resumable id: {e}"));
|
||||
debug!("YT upload URL: {}", &resumable_upload_url);
|
||||
|
||||
let yt_video_id = now_kiss(pt_stream, &resumable_upload_url, &config.youtube)
|
||||
.await
|
||||
.unwrap_or_else(|e| panic!("Cannot resume upload!: {e}"));
|
||||
debug!("YT video ID: {}", &yt_video_id);
|
||||
|
||||
if !pl.is_empty() {
|
||||
add_video_to_playlists(&config.youtube, &yt_video_id, &pl)
|
||||
|
@@ -1,6 +1,7 @@
|
||||
use crate::{config::YoutubeConfig, error::TootubeError, peertube::PeerTubeVideo};
|
||||
use bytes::Bytes;
|
||||
use futures_core::stream::Stream;
|
||||
use log::debug;
|
||||
use reqwest::{multipart::Form, Body, Client};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{error::Error, io::stdin};
|
||||
@@ -207,6 +208,7 @@ async fn refresh_token(config: &YoutubeConfig) -> Result<String, reqwest::Error>
|
||||
|
||||
let access_token: AccessTokenResponse = res.json().await?;
|
||||
|
||||
debug!("YT Access Token: {}", &access_token.access_token);
|
||||
Ok(access_token.access_token)
|
||||
})
|
||||
.await
|
||||
@@ -250,6 +252,7 @@ async fn get_playlist_ids(
|
||||
}
|
||||
}
|
||||
|
||||
debug!("Playlists IDs: {:?}", &playlists);
|
||||
Ok(playlists)
|
||||
}
|
||||
|
||||
@@ -273,8 +276,8 @@ pub async fn add_video_to_playlists(
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
let client = Client::new();
|
||||
|
||||
let client = Client::new();
|
||||
let res = client
|
||||
.post("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet")
|
||||
.header("Authorization", format!("Bearer {}", access_token))
|
||||
@@ -316,6 +319,7 @@ pub async fn create_resumable_upload(
|
||||
}
|
||||
},
|
||||
};
|
||||
debug!("YT upload params: {:?}", &upload_params);
|
||||
|
||||
let client = Client::new();
|
||||
let res = client.post("https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet%2Cstatus")
|
||||
@@ -349,7 +353,6 @@ pub async fn now_kiss<'a>(
|
||||
|
||||
// Create client
|
||||
let client = Client::new();
|
||||
|
||||
let res = client
|
||||
.put(r_url)
|
||||
.header("Authorization", format!("Bearer {}", access_token))
|
||||
|
Reference in New Issue
Block a user