feat: 完成大部分下载功能,移除许多无意义的 Arc 使用
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_stream::stream;
|
||||
use chrono::serde::ts_seconds;
|
||||
use chrono::{DateTime, Utc};
|
||||
@@ -8,8 +6,8 @@ use serde_json::Value;
|
||||
|
||||
use crate::bilibili::BiliClient;
|
||||
use crate::Result;
|
||||
pub struct FavoriteList {
|
||||
client: Arc<BiliClient>,
|
||||
pub struct FavoriteList<'a> {
|
||||
client: &'a BiliClient,
|
||||
fid: String,
|
||||
}
|
||||
|
||||
@@ -43,8 +41,8 @@ pub struct Upper {
|
||||
pub name: String,
|
||||
pub face: String,
|
||||
}
|
||||
impl FavoriteList {
|
||||
pub fn new(client: Arc<BiliClient>, fid: String) -> Self {
|
||||
impl<'a> FavoriteList<'a> {
|
||||
pub fn new(client: &'a BiliClient, fid: String) -> Self {
|
||||
Self { client, fid }
|
||||
}
|
||||
|
||||
@@ -89,7 +87,7 @@ impl FavoriteList {
|
||||
}
|
||||
|
||||
// 拿到收藏夹的所有权,返回一个收藏夹下的视频流
|
||||
pub fn into_video_stream(self) -> impl Stream<Item = VideoInfo> {
|
||||
pub fn into_video_stream(self) -> impl Stream<Item = VideoInfo> + 'a {
|
||||
stream! {
|
||||
let mut page = 1;
|
||||
loop {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use reqwest::Method;
|
||||
|
||||
use crate::bilibili::analyzer::PageAnalyzer;
|
||||
@@ -16,8 +14,8 @@ static DATA: &[char] = &[
|
||||
'f',
|
||||
];
|
||||
|
||||
pub struct Video {
|
||||
client: Arc<BiliClient>,
|
||||
pub struct Video<'a> {
|
||||
client: &'a BiliClient,
|
||||
pub aid: String,
|
||||
pub bvid: String,
|
||||
}
|
||||
@@ -36,18 +34,17 @@ impl serde::Serialize for Tag {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
#[derive(Debug, serde::Deserialize, Default)]
|
||||
pub struct PageInfo {
|
||||
pub cid: i32,
|
||||
pub page: i32,
|
||||
#[serde(rename = "part")]
|
||||
pub name: String,
|
||||
#[serde(default = "String::new")]
|
||||
pub first_frame: String, // 可能不存在,默认填充为空
|
||||
pub first_frame: Option<String>,
|
||||
}
|
||||
|
||||
impl Video {
|
||||
pub fn new(client: Arc<BiliClient>, bvid: String) -> Self {
|
||||
impl<'a> Video<'a> {
|
||||
pub fn new(client: &'a BiliClient, bvid: String) -> Self {
|
||||
let aid = bvid_to_aid(&bvid).to_string();
|
||||
Self { client, aid, bvid }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user