Crate sponsor_block[][src]

Expand description

A Rust wrapper for the SponsorBlock API.

Usage

Simply add it to your Cargo.toml as you would any other crate.

Features

Default features:

  • private_searches: This enables the use of private hash-based segment searching, which significantly improves privacy at a slight bandwidth and performance cost.

    You should almost certainly leave this on.

  • user: The standard set of user functions.

Optional features:

  • vip: The set of functions for only VIP users.

  • gen_user_id: A utility function for generating local user IDs for use with the service.

    Do not use this every time you start up a client - prefer using a single saved ID for the same ‘user’. This is for cases where you may want to generate new user IDs for users of your application, giving each user their own ID.

Example

The following is a short example of how you might fetch the segments for a video:

use sponsor_block::{AcceptedCategories, Client};

// This should be random, treated like a password, and stored across sessions
const USER_ID: &str = "your local user id";

let client = Client::new(USER_ID);
let video_segments = client
    .fetch_segments("9Yhc6mmdJC4", AcceptedCategories::all())
    .await
    .ok();

// Then do something with your video segments...

Structs

A struct for supplying the categories you want to look for in a video.

Additional segment information that isn’t always provided by the API, depending on the function.

The results of an API status request.

The client for interfacing with SponsorBlock.

The builder for the Client.

The overall stats for a user, similar to what UserInfo provides.

A segment, representing a section or point in time in a video that is worth skipping or otherwise treating specially.

A singular point in the video, category-agnostic.

A skippable section, category-agnostic. Contains a start and end time.

The results of a user info request.

The results of a user info request.

Enums

The action to take on a segment.

A video segment, containing timestamp information.

The library error type.

Functions

A utility function that generates a new local user ID.

Type Definitions

A local/private user ID. This value should be kept private and treated like a password.

The ref version of LocalUserId for use in functions.

A public user ID. This value is a hash of the LocalUserId and is used publicly.

The ref version of PublicUserId for use in functions.

A convenience type for the return result of service calls.

A UUID for a segment, uniquely identifying it in the database.

The ref version of SegmentUuid for use in functions.

An HTTP status code number.

A video ID.

The ref version of VideoId for use in functions.