YTClient

Struct YTClient 

Source
pub struct YTClient { /* private fields */ }
Expand description

The client that is used to interface with the google youtube api.

/* When inputing the secret make sure it is the oauth2 token and make sure it is a desktop
application type */
YTClient::new_from_path("./secret.json")

Implementations§

Source§

impl YTClient

The YTClient is required for calling and using the youtube api in this library.

Source

pub fn new_from_secret(data: &str) -> Self

Creates the client using thhe google youtube api secret json file. You can get the secret json file from the google developers page. If you want to create the client using the path the secret json file use the from_path(…) method instead.

Source

pub fn from_secret(data: &str) -> Self

👎Deprecated

DEPRICATED. This method is deprecated because it required the lib files to be present in user rust program. Call new_from_secret(…) to create a new youtube client from a str.

Source

pub fn from_secret_path(path: &str) -> Result<Self>

Creates the client using the path to the secret json file as input.

Examples found in repository?
examples/like_video.rs (line 5)
4fn main() {
5    let client = YTClient::from_secret_path("src/secret.json").unwrap();
6    let rating = LikingArgs {
7        id:"sg4TxfwSeYs",
8        rating:VideoInteration::Like
9    };
10    client.rate_video_request(rating).unwrap();
11}
More examples
Hide additional examples
examples/upload_video.rs (line 4)
2fn main() {
3    // Put your own youtube secret file here
4    let client = YTClient::from_secret_path("./secret.json").unwrap();
5    let options = VideoData {
6        title: "test video",
7        desc: "cool description",
8        keywords: Some("test,cool"),
9        category:video::CategoryID::SciTech as u32,
10        privacy_status: video::PrivacyStatus::Private,
11        file: "./test.mp4",
12        for_kids:false
13    };
14    // Creates the settings for the video
15    let opt = client.create_upload_options(options).unwrap();
16    client.upload_request(opt).expect("Could not upload");
17}
Source

pub fn create_upload_options( &self, video_data: VideoData<'_, '_, '_, '_>, ) -> Result<UploadOptions, String>

Returns a struct that can be used to upload a video. Will return an error is the file given doesn’t exist.

Examples found in repository?
examples/upload_video.rs (line 15)
2fn main() {
3    // Put your own youtube secret file here
4    let client = YTClient::from_secret_path("./secret.json").unwrap();
5    let options = VideoData {
6        title: "test video",
7        desc: "cool description",
8        keywords: Some("test,cool"),
9        category:video::CategoryID::SciTech as u32,
10        privacy_status: video::PrivacyStatus::Private,
11        file: "./test.mp4",
12        for_kids:false
13    };
14    // Creates the settings for the video
15    let opt = client.create_upload_options(options).unwrap();
16    client.upload_request(opt).expect("Could not upload");
17}
Source

pub fn rate_video_request( &self, rating_data: LikingArgs<'_>, ) -> Result<(), impl Debug>

Examples found in repository?
examples/like_video.rs (line 10)
4fn main() {
5    let client = YTClient::from_secret_path("src/secret.json").unwrap();
6    let rating = LikingArgs {
7        id:"sg4TxfwSeYs",
8        rating:VideoInteration::Like
9    };
10    client.rate_video_request(rating).unwrap();
11}
Source

pub fn upload_request(&self, opt: UploadOptions) -> Result<(), impl Debug>

Sends a request to upload a new video.

Examples found in repository?
examples/upload_video.rs (line 16)
2fn main() {
3    // Put your own youtube secret file here
4    let client = YTClient::from_secret_path("./secret.json").unwrap();
5    let options = VideoData {
6        title: "test video",
7        desc: "cool description",
8        keywords: Some("test,cool"),
9        category:video::CategoryID::SciTech as u32,
10        privacy_status: video::PrivacyStatus::Private,
11        file: "./test.mp4",
12        for_kids:false
13    };
14    // Creates the settings for the video
15    let opt = client.create_upload_options(options).unwrap();
16    client.upload_request(opt).expect("Could not upload");
17}
Source

pub fn set_thumbnail( &self, args: ThumbnailArgs<'_, '_>, ) -> Result<(), impl Debug>

Sends a request to change the thumbnail of one of your videos.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.