youtube_search

Crates.ioyoutube_search
lib.rsyoutube_search
version1.0.2
sourcesrc
created_at2023-10-02 18:37:00.739857
updated_at2023-10-05 20:42:34.355936
descriptionA crate to navigate the YouTube API
homepage
repositoryhttps://github.com/mcamara/youtube_search
max_upload_size
id990321
size29,067
Marc Cámara (mcamara)

documentation

README

YouTube Search

Crates.io Run tests

Overview

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.

Features

  • Fetch a YouTube channel by name
  • Get the latest videos from a channel
  • Search for a video by its video ID

Requirements

  • Rust (latest stable version recommended)
  • Tokio runtime
  • thiserror crate for error handling

Installation

Add the following line to your Cargo.toml file under the [dependencies] section:

youtube_search = "1.0.1"

Usage

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(())
}

Documentation

Modules

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.

Testing

This project uses the tokio test framework for asynchronous testing.

Run the test suite with:

cargo test

Contributions

Feel free to open issues or pull requests if you have any improvements or fixes.

License

MIT License. See LICENSE for details

Commit count: 3

cargo fmt