Crate sponsor_block

Crate sponsor_block 

Source
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§

AcceptedCategories
A struct for supplying the categories you want to look for in a video.
AdditionalSegmentInfo
Additional segment information that isn’t always provided by the API, depending on the function.
ApiStatus
The results of an API status request.
Client
The client for interfacing with SponsorBlock.
ClientBuilder
The builder for the Client.
OverallStats
The overall stats for a user, similar to what UserInfo provides.
Segment
A segment, representing a section or point in time in a video that is worth skipping or otherwise treating specially.
TimePoint
A singular point in the video, category-agnostic.
TimeSection
A skippable section, category-agnostic. Contains a start and end time.
UserInfo
The results of a user info request.
UserStats
The results of a user info request.

Enums§

Action
The action to take on a segment.
ActionableSegment
A video segment, containing timestamp information.
ActionableSegmentKind
SponsorBlockError
The library error type.

Functions§

gen_user_id
A utility function that generates a new local user ID.

Type Aliases§

LocalUserId
A local/private user ID. This value should be kept private and treated like a password.
LocalUserIdSlice
The ref version of LocalUserId for use in functions.
PublicUserId
A public user ID. This value is a hash of the LocalUserId and is used publicly.
PublicUserIdSlice
The ref version of PublicUserId for use in functions.
Result
A convenience type for the return result of service calls.
SegmentUuid
A UUID for a segment, uniquely identifying it in the database.
SegmentUuidSlice
The ref version of SegmentUuid for use in functions.
StatusCode
An HTTP status code number.
VideoId
A video ID.
VideoIdSlice
The ref version of VideoId for use in functions.