Rust client for the public YouTube / YouTube Music API (Innertube) Development now on https://codeberg.org/ThetaDev/rustypipe
Find a file
ThetaDev 9743b3f9dc
All checks were successful
CI / Test (push) Successful in 4m40s
feat: add http3 support
2024-03-16 19:59:58 +01:00
.gitea/workflows ci: use cimaster image 2024-03-03 01:58:41 +01:00
cli refactor: generic search API 2023-11-18 01:19:47 +01:00
codegen fix: add support for A/B-13 (2-column layout for music playlists/albums) 2024-02-29 02:54:40 +01:00
downloader chore: fix clippy lints 2023-08-30 22:05:18 +02:00
notes fix: add support for A/B-13 (2-column layout for music playlists/albums) 2024-02-29 02:54:40 +01:00
src feat: add http3 support 2024-03-16 19:59:58 +01:00
testfiles fix: add support for A/B-13 (2-column layout for music playlists/albums) 2024-02-29 02:54:40 +01:00
tests tests: remove tokio_test::block_on 2024-03-16 19:21:30 +01:00
.editorconfig fix: add new attributed_text description 2022-09-24 18:41:27 +02:00
.gitignore chore: migrate insta snapshots to RON 2022-09-24 18:50:52 +02:00
.pre-commit-config.yaml chore: fix clippy lints 2023-09-16 23:34:34 +02:00
.woodpecker.yml chore: update woodpecker pipeline schema 2023-11-23 02:11:44 +01:00
Cargo.toml feat: add http3 support 2024-03-16 19:59:58 +01:00
Justfile fix: a/b test 8: parsing view count for tracks 2023-08-23 11:28:38 +02:00
LICENSE chore: add readme and license 2022-09-19 01:15:42 +02:00
README.md fix(tests): replace short playlist, add new pop genre id 2023-08-04 01:14:36 +02:00

RustyPipe

CI status

Client for the public YouTube / YouTube Music API (Innertube), inspired by NewPipe.

Features

YouTube

  • Player (video/audio streams, subtitles)
  • VideoDetails (metadata, comments, recommended videos)
  • Playlist
  • Channel (videos, shorts, livestreams, playlists, info, search)
  • ChannelRSS
  • Search (with filters)
  • Search suggestions
  • Trending
  • URL resolver

YouTube Music

  • Playlist
  • Album
  • Artist
  • Search
  • Search suggestions
  • Radio
  • Track details (lyrics, recommendations)
  • Moods/Genres
  • Charts
  • New (albums, music videos)

Getting started

Cargo.toml

[dependencies]
rustypipe = "0.1.0"
tokio = { version = "1.20.0", features = ["macros", "rt-multi-thread"] }

Watch a video

use std::process::Command;

use rustypipe::{client::RustyPipe, param::StreamFilter};

#[tokio::main]
async fn main() {
    // Create a client
    let rp = RustyPipe::new();
    // Fetch the player
    let player = rp.query().player("pPvd8UxmSbQ").await.unwrap();
    // Select the best streams
    let (video, audio) = player.select_video_audio_stream(&StreamFilter::default());

    // Open mpv player
    let mut args = vec![video.expect("no video stream").url.to_owned()];
    if let Some(audio) = audio {
        args.push(format!("--audio-file={}", audio.url));
    }
    Command::new("mpv").args(args).output().unwrap();
}

Get a playlist

use rustypipe::client::RustyPipe

#[tokio::main]
async fn main() {
    // Create a client
    let rp = RustyPipe::new();
    // Get the playlist
    let playlist = rp
        .query()
        .playlist("PL2_OBreMn7FrsiSW0VDZjdq0xqUKkZYHT")
        .await
        .unwrap();
    // Get all items (maximum: 1000)
    playlist.videos.extend_limit(rp.query(), 1000).await.unwrap();

    println!("Name: {}", playlist.name);
    println!("Author: {}", playlist.channel.unwrap().name);
    println!("Last update: {}", playlist.last_update.unwrap());

    playlist
        .videos
        .items
        .iter()
        .for_each(|v| println!("[{}] {} ({}s)", v.id, v.name, v.length));
}

Output:

Name: Homelab
Author: Jeff Geerling
Last update: 2023-05-04
[cVWF3u-y-Zg] I put a computer in my computer (720s)
[ecdm3oA-QdQ] 6-in-1: Build a 6-node Ceph cluster on this Mini ITX Motherboard (783s)
[xvE4HNJZeIg] Scrapyard Server: Fastest all-SSD NAS! (733s)
[RvnG-ywF6_s] Nanosecond clock sync with a Raspberry Pi (836s)
[R2S2RMNv7OU] I made the Petabyte Raspberry Pi even faster! (572s)
[FG--PtrDmw4] Hiding Macs in my Rack! (515s)
...

Get a channel

use rustypipe::client::RustyPipe

#[tokio::main]
async fn main() {
    // Create a client
    let rp = RustyPipe::new();
    // Get the channel
    let channel = rp
        .query()
        .channel_videos("UCl2mFZoRqjw_ELax4Yisf6w")
        .await
        .unwrap();

    println!("Name: {}", channel.name);
    println!("Description: {}", channel.description);
    println!("Subscribers: {}", channel.subscriber_count.unwrap());

    channel
        .content
        .items
        .iter()
        .for_each(|v| println!("[{}] {} ({}s)", v.id, v.name, v.length.unwrap()));
}

Output:

Name: Louis Rossmann
Description: I discuss random things of interest to me. (...)
Subscribers: 1780000
[qBHgJx_rb8E] Introducing Rossmann senior, a genuine fossil 😃 (122s)
[TmV8eAtXc3s] Am I wrong about CompTIA? (592s)
[CjOJJc1qzdY] How FUTO projects loosen Google's grip on your life! (588s)
[0A10JtkkL9A] a private moment between a man and his kitten (522s)
[zbHq5_1Cd5U] Is Texas mandating auto repair shops use OEM parts? SB1083 analysis & breakdown; tldr, no. (645s)
[6Fv8bd9ICb4] Who owns this? (199s)
...

Development

Requirements:

  • Current version of stable Rust
  • just task runner
  • pre-commit
  • yq (YAML processor)

Tasks

Testing

  • just test Run unit+integration tests
  • just unittest Run unit tests
  • just testyt Run YouTube integration tests
  • just testintl Run YouTube integration tests for all supported languages (this takes a long time and is therefore not run in CI)
  • YT_LANG=de just testyt Run YouTube integration tests for a specific language

Tools

  • just testfiles Download missing testfiles for unit tests
  • just report2yaml Convert RustyPipe reports into a more readable yaml format (requires yq)