Crates.io | youtube_search |
lib.rs | youtube_search |
version | 1.0.2 |
source | src |
created_at | 2023-10-02 18:37:00.739857 |
updated_at | 2023-10-05 20:42:34.355936 |
description | A crate to navigate the YouTube API |
homepage | |
repository | https://github.com/mcamara/youtube_search |
max_upload_size | |
id | 990321 |
size | 29,067 |
This Rust library provides an asynchronous interface for interacting with YouTube channels and videos. It uses the lemnoslife youtube API to fetch data from YouTube without the use of an API key. Please consider supporting them if you find this library useful.
thiserror
crate for error handlingAdd the following line to your Cargo.toml
file under the [dependencies]
section:
youtube_search = "1.0.1"
Here's a simple example demonstrating how to use the library:
use youtube_search::{
find_youtube_channel,
find_latest_videos,
find_video,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let channel = find_youtube_channel("ChannelName").await?;
println!("Channel Title: {}", channel.title);
let videos = find_latest_videos(&channel, 5).await?;
println!("Latest videos: {:?}", videos);
let video = find_video("video_id_here".to_string()).await?;
println!("Video Title: {}", video.title);
Ok(())
}
src/lib.rs
The main library file which provides functions for user interaction.
src/youtube/channel.rs
Defines the Channel struct and methods to initialize and fetch details.
src/youtube/video.rs
Defines the Video struct and methods to search for videos by ID.
src/youtube/playlist.rs
Defines the Playlist struct.
This project uses the tokio test framework for asynchronous testing.
Run the test suite with:
cargo test
Feel free to open issues or pull requests if you have any improvements or fixes.
MIT License. See LICENSE
for details