| Crates.io | podbean |
| lib.rs | podbean |
| version | 0.2.1 |
| created_at | 2025-03-11 13:51:23.7629+00 |
| updated_at | 2025-03-20 17:27:33.779352+00 |
| description | An async Podbean client for connecting to the Podbean API. |
| homepage | https://github.com/ernestas-poskus/podbean |
| repository | https://github.com/ernestas-poskus/podbean |
| max_upload_size | |
| id | 1587961 |
| size | 90,982 |
A fully async Rust client for the Podbean API, built with Tokio and Reqwest.
Add the following to your Cargo.toml:
[dependencies]
podbean = "0.2.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
use podbean::PodbeanClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client with your credentials
let mut client = PodbeanClient::new("your_client_id", "your_client_secret").unwrap();
// Generate authorization URL for the user to visit
let auth_url = client.get_authorization_url(
"https://your-app.com/callback",
Some("state_for_csrf_protection")
)?;
println!("Please visit: {}", auth_url);
// After user authorization, exchange the code for a token
client.authorize("authorization_code_from_callback", "https://your-app.com/callback").await?;
// Now you can use the API
let podcasts = client.list_podcasts(None, Some(10)).await?;
println!("You have {} podcasts", podcasts.count);
Ok(())
}
use podbean::{PodbeanClient, EpisodeStatus, EpisodeType, MediaFormat};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client with your credentials
let mut client = PodbeanClient::new("your_client_id", "your_client_secret").unwrap();
// Upload an audio file
let media_key = client.upload_media("episode.mp3".to_string(), vec![], MediaFormat::Mp3).await?;
// Publish a new episode
let episode_id = client.publish_episode(
"your_podcast_id",
"Episode Title",
"Episode description and show notes...",
&media_key,
EpisodeStatus::Draft,
EpisodeType::Public,
None, // Publish immediately
).await?;
println!("Published new episode with ID: {}", episode_id);
Ok(())
}
use podbean::PodbeanClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client with your credentials
let mut client = PodbeanClient::new("your_client_id", "your_client_secret").unwrap();
// List episodes
let episodes = client.list_episodes(Some("your_podcast_id"), None, Some(20)).await?;
println!("Found {} episodes", episodes.count);
// Get a specific episode
let episode = client.get_episode("episode_id").await?;
println!("Episode: {} (URL: {})", episode.title, episode.player_url);
// Update an episode
client.update_episode(
"episode_id",
Some("Updated Title"),
Some("Updated description"),
None, // Keep current status
None, // Keep current publish time
).await?;
// Delete an episode
client.delete_episode("episode_id").await?;
Ok(())
}
PodbeanClient::new(client_id, client_secret) - Create a new clientclient.get_authorization_url(redirect_uri, state) - Generate OAuth authorization URLclient.authorize(code, redirect_uri) - Exchange authorization code for tokenclient.refresh_token() - Refresh the access token when expiredclient.list_podcasts(offset, limit) - List podcasts for the authenticated userclient.list_episodes(podcast_id, offset, limit) - List episodesclient.get_episode(episode_id) - Get a specific episodeclient.publish_episode(podcast_id, title, content, media_key, EpisodeStatus::Draft, EpisodeType::Public, publish_timestamp) - Publish a new episodeclient.update_episode(episode_id, title, content, status, publish_timestamp) - Update an episodeclient.delete_episode(episode_id) - Delete an episodeclient.upload_media(file_name, file_bytes, content_type) - Upload a media fileclient.list_media(offset, limit) - List media filesThe library uses a custom PodbeanError type that provides detailed information about what went wrong:
MIT
Contributions are welcome! Please feel free to submit a Pull Request.