add playlist privacy parameter

This commit is contained in:
OMGeeky
2023-06-21 17:55:28 +02:00
parent 3a599ab9fd
commit a7de029317
2 changed files with 13 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "google_youtube"
version = "0.1.6"
version = "0.2.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -12,12 +12,12 @@ use google_youtube3::{
api::PlaylistItemSnippet,
api::PlaylistListResponse,
api::PlaylistSnippet,
api::PlaylistStatus,
api::ResourceId,
api::Video,
api::VideoSnippet,
api::VideoStatus,
hyper::client::HttpConnector,
hyper::{Body, Response},
hyper::{client::HttpConnector, Body, Response},
hyper_rustls::HttpsConnector,
};
#[cfg(feature = "tracing")]
@@ -136,12 +136,16 @@ impl YoutubeClient {
}
#[cfg_attr(feature = "tracing", instrument)]
pub async fn find_playlist_or_create_by_name(&self, name: &str) -> Result<Playlist> {
pub async fn find_playlist_or_create_by_name(
&self,
name: &str,
privacy: PrivacyStatus,
) -> Result<Playlist> {
let playlist = self.find_playlist_by_name(name).await?;
if let Some(playlist) = playlist {
return Ok(playlist);
}
let playlist = self.create_playlist(name).await?;
let playlist = self.create_playlist(name, privacy).await?;
Ok(playlist)
}
@@ -290,12 +294,15 @@ impl YoutubeClient {
// }
}
#[cfg_attr(feature = "tracing", instrument)]
async fn create_playlist(&self, name: &str) -> Result<Playlist> {
async fn create_playlist(&self, name: &str, privacy: PrivacyStatus) -> Result<Playlist> {
let playlist = Playlist {
snippet: Some(PlaylistSnippet {
title: Some(name.to_string()),
..Default::default()
}),
status: Some(PlaylistStatus {
privacy_status: Some(privacy.to_string()),
}),
..Default::default()
};