Skip to main content

VideoClient

Struct VideoClient 

Source
pub struct VideoClient<'a> { /* private fields */ }
Expand description

视频领域 API 客户端。

Implementations§

Source§

impl<'a> VideoClient<'a>

Source

pub async fn coin_status( &self, params: VideoCoinStatusParams, ) -> BpiResult<VideoCoinStatusData>

检查当前账号已给视频投出多少硬币。

Self::coin 成功后,上游 endpoint 可能会短暂滞后。

Source

pub async fn like(&self, params: VideoLikeParams) -> BpiResult<Option<Value>>

点赞或取消点赞视频,并返回可选的标准 payload 结果。

Source

pub async fn coin(&self, params: VideoCoinParams) -> BpiResult<CoinData>

给视频投币,并返回标准 payload 结果。

Bilibili 的 Web endpoint 需要包含 buvid3 的正常登录 cookie 集合; 即使存在 SESSDATAbili_jct,缺少它的账号也可能触发风控。

Source

pub async fn favorite( &self, params: VideoFavoriteParams, ) -> BpiResult<FavoriteData>

将视频添加到收藏夹,或从收藏夹中移除。

Source§

impl<'a> VideoClient<'a>

Source

pub async fn view(&self, params: VideoViewParams) -> BpiResult<VideoView>

按 AV ID 或 BV ID 获取 Web 视频详情。

Examples found in repository?
examples/module_clients.rs (line 19)
9async fn main() -> BpiResult<()> {
10    let client = client_from_env()?;
11    let video_params = VideoViewParams::from_bvid("BV1xx411c7mD".parse::<Bvid>()?);
12    let bangumi_params = BangumiInfoParams::new(MediaId::new(28_220_978)?);
13
14    if !run_live_example() {
15        println!("module-client 快速示例已编译;设置 BPI_RUN_EXAMPLE=1 后会发起真实网络请求");
16        return Ok(());
17    }
18
19    let video = client.video().view(video_params).await?;
20    println!("video: {}", video.title);
21
22    let bangumi = client.bangumi().info(bangumi_params).await?;
23    println!("bangumi: {}", bangumi.media.title);
24
25    if env::var_os("BPI_COOKIE").is_some() {
26        let nav = client.login().nav().await?;
27        println!("logged in: {}", nav.is_login);
28    }
29
30    Ok(())
31}
More examples
Hide additional examples
examples/video_info.rs (line 26)
21async fn main() -> BpiResult<()> {
22    let bvid = video_bvid()?;
23    let client = BpiClient::new()?;
24    let video = client.video();
25
26    let view = video.view(VideoViewParams::from_bvid(bvid.clone())).await?;
27    println!(
28        "视频: {} ({}) UP={} 播放={} 点赞={}",
29        view.title, view.bvid, view.owner.name, view.stat.view, view.stat.like
30    );
31
32    let pages = video
33        .page_list(VideoPageListParams::from_bvid(bvid.clone()))
34        .await?;
35    println!("分 P 数: {}", pages.len());
36    for page in pages.iter().take(5) {
37        println!("  P{} cid={} {}", page.page, page.cid, page.part);
38    }
39
40    let desc = video.desc(VideoDescParams::from_bvid(bvid)).await?;
41    let first_line = desc.lines().next().unwrap_or("");
42    println!("简介首行: {first_line}");
43
44    Ok(())
45}
Source

pub async fn detail(&self, params: VideoDetailParams) -> BpiResult<VideoDetail>

获取 Web 视频详情,包括标签和相关视频。

Source

pub async fn page_list( &self, params: VideoPageListParams, ) -> BpiResult<Vec<VideoPage>>

获取视频的分 P/内容 ID。

Examples found in repository?
examples/video_info.rs (line 33)
21async fn main() -> BpiResult<()> {
22    let bvid = video_bvid()?;
23    let client = BpiClient::new()?;
24    let video = client.video();
25
26    let view = video.view(VideoViewParams::from_bvid(bvid.clone())).await?;
27    println!(
28        "视频: {} ({}) UP={} 播放={} 点赞={}",
29        view.title, view.bvid, view.owner.name, view.stat.view, view.stat.like
30    );
31
32    let pages = video
33        .page_list(VideoPageListParams::from_bvid(bvid.clone()))
34        .await?;
35    println!("分 P 数: {}", pages.len());
36    for page in pages.iter().take(5) {
37        println!("  P{} cid={} {}", page.page, page.cid, page.part);
38    }
39
40    let desc = video.desc(VideoDescParams::from_bvid(bvid)).await?;
41    let first_line = desc.lines().next().unwrap_or("");
42    println!("简介首行: {first_line}");
43
44    Ok(())
45}
Source

pub async fn desc(&self, params: VideoDescParams) -> BpiResult<String>

获取纯文本视频简介。

Examples found in repository?
examples/video_info.rs (line 40)
21async fn main() -> BpiResult<()> {
22    let bvid = video_bvid()?;
23    let client = BpiClient::new()?;
24    let video = client.video();
25
26    let view = video.view(VideoViewParams::from_bvid(bvid.clone())).await?;
27    println!(
28        "视频: {} ({}) UP={} 播放={} 点赞={}",
29        view.title, view.bvid, view.owner.name, view.stat.view, view.stat.like
30    );
31
32    let pages = video
33        .page_list(VideoPageListParams::from_bvid(bvid.clone()))
34        .await?;
35    println!("分 P 数: {}", pages.len());
36    for page in pages.iter().take(5) {
37        println!("  P{} cid={} {}", page.page, page.cid, page.part);
38    }
39
40    let desc = video.desc(VideoDescParams::from_bvid(bvid)).await?;
41    let first_line = desc.lines().next().unwrap_or("");
42    println!("简介首行: {first_line}");
43
44    Ok(())
45}
Source

pub async fn play_url( &self, params: VideoPlayUrlParams, ) -> BpiResult<PlayUrlResponseData>

按 AV ID 或 BV ID 以及分 P/内容 ID 获取已签名的 Web 播放 URL。

Source

pub async fn seasons_archives_list( &self, params: VideoCollectionSeasonsArchivesParams, ) -> BpiResult<GetSeasonsArchivesData>

获取指定视频合集中的视频。

Source

pub async fn home_seasons_series( &self, params: VideoCollectionHomeSeasonsSeriesParams, ) -> BpiResult<GetSeasonsSeriesData>

获取用户主页的合集和系列列表。

Source

pub async fn seasons_series_list( &self, params: VideoCollectionSeasonsSeriesParams, ) -> BpiResult<GetSeasonsSeriesData>

分页获取用户的合集和系列列表。

Source

pub async fn series_info( &self, params: VideoCollectionSeriesInfoParams, ) -> BpiResult<GetSeriesData>

获取指定视频系列的元数据。

Source

pub async fn series_archives( &self, params: VideoCollectionSeriesArchivesParams, ) -> BpiResult<GetSeriesArchivesData>

获取指定视频系列中的视频。

Source

pub async fn online_total( &self, params: VideoOnlineTotalParams, ) -> BpiResult<OnlineTotalResponseData>

获取视频分 P 的在线人数计数。

Source

pub async fn player_info_v2( &self, params: VideoPlayerInfoParams, ) -> BpiResult<PlayerInfoResponseData>

获取视频分 P 的 Web 播放器元数据。

Source

pub async fn related_videos( &self, params: VideoRelatedParams, ) -> BpiResult<Vec<RelatedVideo>>

获取与某个视频相关的视频。

Source

pub async fn homepage_recommendations( &self, params: VideoHomepageRecommendationsParams, ) -> BpiResult<RcmdFeedResponseData>

获取首页视频推荐。

Source

pub async fn ai_summary( &self, params: VideoAiSummaryParams, ) -> BpiResult<AiSummaryResponseData>

获取视频的 AI 总结。

Source

pub async fn tags(&self, params: VideoTagsParams) -> BpiResult<Vec<VideoTag>>

获取视频关联的标签。

Source

pub async fn interactive_video_info( &self, params: InteractiveVideoInfoParams, ) -> BpiResult<InteractiveVideoInfoResponseData>

获取互动视频节点的元数据。

Source§

impl<'a> VideoClient<'a>

Source

pub async fn create_collection_series( &self, params: CollectionCreateAndAddArchivesParams, ) -> BpiResult<CreateSeriesResponseData>

创建视频系列,并可选择向其中添加稿件。

Source

pub async fn delete_collection_series( &self, params: CollectionDeleteSeriesParams, ) -> BpiResult<Option<Value>>

删除视频系列。

Source

pub async fn delete_collection_archives( &self, params: CollectionArchivesMutationParams, ) -> BpiResult<Option<Value>>

从视频系列中删除稿件。

Source

pub async fn add_collection_archives( &self, params: CollectionArchivesMutationParams, ) -> BpiResult<Option<Value>>

向视频系列中添加稿件。

Source

pub async fn update_collection_series( &self, params: CollectionUpdateSeriesParams, ) -> BpiResult<Option<Value>>

更新视频系列。

Source§

impl<'a> VideoClient<'a>

Source

pub async fn report_watch_progress( &self, params: VideoWatchProgressParams, ) -> BpiResult<Option<Value>>

上报视频观看进度并返回标准 payload 结果。

Trait Implementations§

Source§

impl<'a> Clone for VideoClient<'a>

Source§

fn clone(&self) -> VideoClient<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for VideoClient<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for VideoClient<'a>

§

impl<'a> !UnwindSafe for VideoClient<'a>

§

impl<'a> Freeze for VideoClient<'a>

§

impl<'a> Send for VideoClient<'a>

§

impl<'a> Sync for VideoClient<'a>

§

impl<'a> Unpin for VideoClient<'a>

§

impl<'a> UnsafeUnpin for VideoClient<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more