#youtube #api #async #api-key #api-bindings #playlist

弃用 yt-api

一个用于异步与 YouTube API 交互的正在进行中的库

9 个版本

0.3.2 2022 年 5 月 7 日
0.3.1 2021 年 3 月 24 日
0.3.0-alpha.12019 年 10 月 20 日
0.2.0 2019 年 9 月 23 日
0.1.1 2019 年 8 月 14 日

#40 in #playlist

每月 36 次下载

MIT 许可证

280KB
835 代码行

此项目主要是为了娱乐而开发的,已经有一段时间没有维护了。请考虑使用google_youtube3,它现在得到了维护,也是异步的,并且支持比 yt-api 更多的端点。

yt-api

Crates.io Documentation

关于

使用 yt-api,您可以异步与 YouTube API 交互。目前它实现了以下端点

  • 搜索
  • 播放列表

示例

使用 yt-api 的基本搜索请求

/// prints the first answer of a search query
fn main() -> Result<(), Error> {
    futures::executor::block_on(async {
        // take api key from enviroment variable
        let key = ApiKey::new(&env::var("YT_API_KEY").expect("YT_API_KEY env-var not found"));

        // create the SearchList struct for the query "rust lang"
        let result = SearchList::new(key)
            .q("rust lang")
            .item_type(ItemType::Video)
            .await?;

        // outputs the title of the first search result
        println!(
            "Title: \"{}\"",
            result.items[0].snippet.title.as_ref().unwrap()
        );
        // outputs the video id of the first search result
        println!(
            "https://youtube.com/watch?v={}",
            result.items[0].id.video_id.as_ref().unwrap()
        );

        Ok(())
    })
}

更多示例请见此处

支持的 Rust 版本

yt-api 的最低 Rust 版本是 1.39

许可证

本项目采用MIT 许可证

贡献

除非您明确声明,否则您提交给 yt-api 的任何有意贡献的代码,均应按照 MIT 许可证进行许可,不附加任何额外条款或条件。

依赖项

~8–23MB
~367K SLoC