#api-wrapper #music #youtube #streaming #bandcamp #applications #soundcloud

musicou-kit

为类似 YouTube 音乐、Soundcloud 和 Bandcamp 的音乐流媒体网站的官方 API 包装器

11 个版本

0.1.2 2023 年 8 月 30 日
0.1.1 2023 年 8 月 30 日
0.0.9 2023 年 8 月 29 日
0.0.3 2023 年 7 月 29 日

#1779 in Web 编程

Download history 54/week @ 2024-07-01 59/week @ 2024-07-22

每月 113 次下载

AGPL-3.0

59KB
1.5K SLoC

musicou-kit

Musicou-kit 是 YouTube 音乐、SoundCloud 和 Bandcamp 的 API 包装器。它使用简单,易于集成到其他应用程序中。

当前状态

此 crate 仍然处于实验性 & WIP 状态,未来将会有重大变化。代码结构混乱,存在一些错误,目前只支持一个(1)平台。

示例

使用查询进行搜索并获取第一位艺术家及其数据。

#[tokio::main]
async fn main() {
    env_logger::init(); // logs stuff
    // crating search with query and defining platform
    let mut search = Search::new("the weeknd" structs::Platform::Youtube)
        .fetch(structs::Page::Artist) // fetching a certain page
        .await;

    // fetching all data for first artist in search results
    print!(" {:?}, ", search.unwrap().artists.unwrap()[0].fetch().await)
    // Ok(Artist { id: "UClYV6hHlupm_S_ObS1W-DYw", name: "The Weeknd", platform: Youtube, thumbnails: [Thumbnail { url: ".....", width: 540, height: 225 }], background: [], incomplete: true, followers: 33000000 }
}

通过 ID 获取歌曲数据

#[tokio::main]
async fn main() {
    env_logger::init(); // logs stuff
    let song = Song::from_id("diW6jXhLE0E").fetch().await;
    println!("{:?}", song.unwrap());
    // Song { id: "", title: "The Weeknd - Party Monster (Official Video)", length: 258, author: Artist { id: "", name: "", platform: Youtube, thumbnails: [], background: [], incomplete: true, followers: 0, private_field: "" }, thumbnails: [Thumbnail { url: "https://i.ytimg.com/.....", width: 400, height: 225 } ... ], view_count: 154341745, streams: Some([Stream { url: "https://rr3---....", bitrate: "130477", mime_type: "audio/mp4; codecs="mp4a.40.2" } ]), album: None, type_of: Youtube, incomplete: false}
}

路线图

  • YouTube 抓取 / 提取

    • 流提取
    • 音乐
    • 搜索
      • 歌曲
      • 专辑
      • 播放列表
      • 艺术家
    • 专辑
    • 艺术家
    • 播放列表
  • Soundcloud 抓取

    • 流提取
    • 直接音乐查找
    • 搜索
    • 专辑
    • 艺术家
    • 播放列表
  • Bandcamp 抓取

    • 流提取
    • 直接音乐查找
    • 搜索
    • 专辑
    • 艺术家
    • 播放列表

感谢 <3!

YouTube 内部 API 研究

依赖项

~13–28MB
~454K SLoC