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.
impl YTClient
The YTClient is required for calling and using the youtube api in this library.
Sourcepub fn new_from_secret(data: &str) -> Self
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.
Sourcepub fn from_secret(data: &str) -> Self
👎Deprecated
pub fn from_secret(data: &str) -> Self
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.
Sourcepub fn from_secret_path(path: &str) -> Result<Self>
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?
More examples
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}
Sourcepub fn create_upload_options(
&self,
video_data: VideoData<'_, '_, '_, '_>,
) -> Result<UploadOptions, String>
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?
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}
Sourcepub fn rate_video_request(
&self,
rating_data: LikingArgs<'_>,
) -> Result<(), impl Debug>
pub fn rate_video_request( &self, rating_data: LikingArgs<'_>, ) -> Result<(), impl Debug>
Sourcepub fn upload_request(&self, opt: UploadOptions) -> Result<(), impl Debug>
pub fn upload_request(&self, opt: UploadOptions) -> Result<(), impl Debug>
Sends a request to upload a new video.
Examples found in repository?
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}
Sourcepub fn set_thumbnail(
&self,
args: ThumbnailArgs<'_, '_>,
) -> Result<(), impl Debug>
pub fn set_thumbnail( &self, args: ThumbnailArgs<'_, '_>, ) -> Result<(), impl Debug>
Sends a request to change the thumbnail of one of your videos.