A asynchronous implementation of the invidious innertube aka youtubei API wrapper

Overview

youtubei-rs

A asynchronous implementation of the invidious innertube aka youtubei API wrapper.
Using tokio,reqwest, serde and serde_json.

Configuration

The client_config can be configured to dump the json response to a file if its not parsable,
this is on by default when using the default_client_config() function.
When creating the client_config manually you can parse true/false as the last parameter to disable this behavior.

Roadmap

  • implementing proxy support
  • removing panics
  • adding more endpoints

Implemented endpoints

  • next
  • browse
  • search
  • resolve_url
  • player

Supported queries

  • next_video_id // Get next(aka related and comments) results for a given videoId
  • next_continuation // Fetch more next(aka related and comments) results for a given ctoken
  • browse_id // Get browse(aka a channel or playlist) results for a given browseId
  • browse_continuation // Fetch more browse(aka a channel or playlist) results for a given ctoken
  • resolve, // Resolve a given url
  • player // Get player data for a given videoId

Example

use youtubei_rs::{query::player, utils::default_client_config, types::query_results::PlayerResult};
#[tokio::main]
async fn main() {
    // create default client_config with WEB client
    let client_config = &default_client_config();
    // get player for video with id gC6dQrScmHE
    let player: PlayerResult = player(String::from("gC6dQrScmHE"),String::from(""),&client_config).await.unwrap();
    println!("{}",player.video_details.title); // video title
}

With logging

For logging tracing is used so tracing_subscribe can be installed for easier use of tracing. The library has as target youtubei_rs with debug,trace and error levels.

use youtubei_rs::{query::player, utils::default_client_config};
#[tokio::main]
async fn main() {
    std::env::set_var("RUST_LOG", "youtubei_rs=debug");
    tracing_subscriber::fmt::init();
    // create default client_config with WEB client
    let client_config = &default_client_config();
    // get player for video with id gC6dQrScmHE
    let player: PlayerResult = player(String::from("gC6dQrScmHE"),String::from(""),&client_config).await.unwrap();
    println!("{}",player.video_details.title); // video title
}

Supported queries (legacy)

  • get_video: Fetches all information about the video except captions and storyboards
  • get_channel_info: Fetches all channel information and about tab
  • get_channel_tab: Fetches a specific tab like videos to get channel videos
  • search: Search youtube
  • load_search: Continue search with ctoken
  • get_comments: Loads initial comments or more comments for video
  • load_related_videos: Loads more related videos
  • get_playlist: Loads a playlist

For more in depth info take a look at query.rs and tests.rs

Comments
  • [Trivial] Some code style changes

    [Trivial] Some code style changes

    This PR mostly just changes some trivial code formatting. I hope it would be useful. A lot of it is subjective, but at times I just felt it looked better. I'm not trying to impose my own preference on you, so you are free to make any necessary changes.

    It also does the following:

    • Adds clippy and rustfmt to the pipeline. I'm not sure if the pipeline has the a write permission or if I've done it correctly, so it might need to be replaced with the proper action.
    • Formats the code with rustfmt and applies some clippy suggestions. I've also added some line breaks to make it look less dense. I hope they make sense and separate different things correctly.
    • Fixes some Markdown formatting.
    opened by walking-octopus 5
  • [Trivial] Logic optimisation + Typo/style corrections

    [Trivial] Logic optimisation + Typo/style corrections

    • Shortens the extract_author logic, also removing a mutable in favour of an inline conditional.
    • Fixes a few styling issues (lack of whitespace).
    • Typo corrections.

    Compiled and tested! - cargo check && cargo test :heavy_check_mark:

    opened by JSKitty 2
  • Add support for includingResultsForRenderer

    Add support for includingResultsForRenderer

    includingResultsForRenderer found in search results when e.g searched via a hashtag, it shows what result are also included meaning result containing a different wording/writing

    bug 
    opened by 11Tuvork28 0
  • Added json dump on error

    Added json dump on error

    This dumps the json response in the pwd directory the naming convention is json_dump_endpoint+ requested endpoint name e.g browse. This feature needs to be impoved in regards the names because it gets overwritten which is bad. The content of the file include request params, the error itself and the json data.

    opened by 11Tuvork28 0
  • Fixed unknown type recognitionShelfRenderer fixes #4

    Fixed unknown type recognitionShelfRenderer fixes #4

    Adds RecognitionShelfRenderer to the ItemSectionRendererContents enum but its not getting parsed since its not needed but should probably be parsed in a future release

    opened by 11Tuvork28 0
  • [Trivial] A bunch of minor typo/style corrections

    [Trivial] A bunch of minor typo/style corrections

    Just a small PR for a Rust-y fren!

    • Fixes many small typos.
    • Fixes a few styling inconsistencies.
    • Shortens some conditional logic.

    Not tested / compiled, need to setup my Rust environment!

    opened by JSKitty 0
  • Support feed fetching

    Support feed fetching

    YouTube.js supports fetching recommendations, subscriptions, and trending videos. Does such a feature fit within this project's scope? Would this project also support OAuth in the future?

    I just wanted to create an issue for tracking progress for this feature.

    question 
    opened by walking-octopus 1
  • Implement a parser simular youtubei.js

    Implement a parser simular youtubei.js

    Currently, this project uses error-prone and difficult to maintain manual parsing for each response type. Implementing a YouTube.js-inspired parser would help to get rid of unnecessary unwraps, add a layer of abstraction for creating new API endpoints, and make the project more maintainable. Maybe a macro could be made for parsing the InnerTube responses.

    enhancement 
    opened by walking-octopus 7
  • Implement parsing for all other known clients

    Implement parsing for all other known clients

    Currently only the WEB is useable, since nothing else can be parse but that must change and the parsing api needs to be updated as well regarding the result columns since those should be in an enum for a more generic matching ability

    enhancement 
    opened by 11Tuvork28 0
Releases(1.3.5)
  • 1.3.5(Jul 5, 2022)

    What's Changed

    • Fixed unknown type recognitionShelfRenderer fixes #4 in https://github.com/11Tuvork28/youtubei-rs/pull/6
    • Added utility functions for checking various things

    Full Changelog: https://github.com/11Tuvork28/youtubei-rs/compare/1.3.4...1.3.5

    Source code(tar.gz)
    Source code(zip)
  • 1.3.4(Jun 13, 2022)

  • 1.2.4(Jun 9, 2022)

    What's Changed

    • Fixed parsing error when captions are not available
    • Removed one origin of possible panics
    • Fixed error when search endpoint returns searchPyvRenderer in json
    Source code(tar.gz)
    Source code(zip)
  • 1.2.3(Jun 9, 2022)

    What's Changed

    • Fixed examples
    • various bug fixes
    • Added filters to filter result
    • [Trivial] A bunch of minor typo/style corrections by @JSKitty in https://github.com/11Tuvork28/youtubei-rs/pull/1
    • [Trivial] Tiny condition shortening by @JSKitty in https://github.com/11Tuvork28/youtubei-rs/pull/2
    • [Trivial] Logic optimisation + Typo/style corrections by @JSKitty in https://github.com/11Tuvork28/youtubei-rs/pull/3

    New Contributors

    • @JSKitty made their first contribution in https://github.com/11Tuvork28/youtubei-rs/pull/1
    Source code(tar.gz)
    Source code(zip)
Owner
11Tuvork28
Hey there, I like to program.
11Tuvork28
Rust wrapper for the LeapC Ultraleap (Leap Motion) hand tracking device API.

LeapRS LeapRS is a safe wrapper for LeapC, the Leap Motion C API. It uses the generated binding provided by leap-sys. This is an API for accessing Lea

Pierre Lulé 4 Oct 10, 2022
An efficient runtime for asynchronous applications in Rust.

PhotonIO PhotonIO is an efficient runtime for asynchronous applications in Rust. Features Asynchronous filesystem and networking I/O for Linux based o

PhotonDB 40 Jan 4, 2023
An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets.

Promise x Tokio = Prokio An asynchronous runtime compatible with WebAssembly and non-WebAssembly targets. Rationale When designing components and libr

Yew Stack 29 Feb 6, 2023
List public items (public API) of Rust library crates. Enables diffing public API between releases.

cargo wrapper for this library You probably want the cargo wrapper to this library. See https://github.com/Enselic/cargo-public-items. public_items Li

Martin Nordholts 20 Dec 26, 2022
Uma lib para a API do Brasil API (para o Rust)

Uma lib para a API do BrasilAPI (para o Rust) Features CEP (Zip code) DDD Bank CNPJ IBGE Feriados Nacionais Tabela FIPE ISBN Registros de domínios br

Pedro Augusto 6 Dec 13, 2022
The second Rust implementation on GitHub of third-party REST API client for Bilibili.

Bilibili REST API The second Rust implementation on GitHub of third-party REST API client for Bilibili. Designed to be lightweight and efficient. It's

null 4 Aug 25, 2022
Rust wrapper for `os-release`

os-release-rs Rust wrapper for /etc/os-release file. Installation Add this to your Cargo.toml: [dependencies] os-release-rs = "0.1.0" Usage use os_rel

0xMRTT 2 Nov 11, 2022
Safe MMDeploy Rust wrapper.

Introduction Safe MMDeploy Rust wrapper. News (2022.9.29) This repo has been added into the OpenMMLab ecosystem. (2022.9.27) This repo has been added

Mengyang Liu 14 Dec 15, 2022
A wrapper around Rust futures that stores the future in space provided by the caller.

StackFuture This crate defines a StackFuture wrapper around futures that stores the wrapped future in space provided by the caller. This can be used t

Microsoft 278 Dec 29, 2022
This is for aquestalk1 rust wrapper.

aquestalk-rs This is for aquestalk1 rust wrapper. 読み上げに使用する際 aquestalkを使ってDiscord読み上げbotなどを作成する場合aquestalkに問い合わせして、サーバー用ライセンスの購入が必須です。 Installation [d

KuronekoServer 2 Nov 16, 2022
c-library wrapper around the rust pdb crate

pdbcrust: pdbcrust is a c-library wrapper around the rust pdb crate. The API only exports a minimum subset of the pdb crate functionality. The project

Ulf Frisk 7 Feb 23, 2023
A rocksdb.rs wrapper bringing stack and queue functionalities

RocksDB_sq (Stack & Queue) A Rust crate that adds stack and queue functionality to RocksDB. This crate provide a wrapper around a RocksDB database and

Nathan GD 5 May 16, 2023
A shit dAPI wrapper.

Shit dAPI wrapper A Blazingly Fast (??????) discord API wrapper so shit it makes your bot say shit uncontrollably. usage: clone this repo and change t

Enoki 5 Jun 12, 2022
Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Speedy2D Hardware-accelerated drawing of shapes, images, and text, with an easy to use API. Speedy2D aims to be: The simplest Rust API for creating a

null 223 Dec 26, 2022
Code to follow along the "Zero To Production" book on API development in Rust.

Zero To Production / Code (Chapter 10 - Part 1) Zero To Production In Rust is an opinionated introduction to backend development using Rust. This repo

Luca Palmieri 2.8k Dec 31, 2022
Interact with the crate's API

cargo-crate-api Interact with the crate's API Documentation Installation Getting Started Reference FAQ Contribute CHANGELOG Install Download a pre-bui

null 7 Aug 9, 2022
Conversion Tools API Rust client

ConversionTools Rust This Conversion Tools API Rust client allows you to use the site API and convert files faster and more conveniently. Site Convers

WinsomeQuill 2 Jan 23, 2022
Public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis

api.adsbdb.com public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis See typescript branch for original typescript vers

Jack Wills 66 Dec 22, 2022
Simple RESTful API in rust created with actix-web. (Routing, models, JWT auth).

rust-simple-api Simple RESTful API created with rust, actix-web, Diesel, JWT. Running application Manual Firstly generate a secret.key which will be u

null 2 Jul 30, 2022