mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-05 23:49:53 +08:00
feat: 确保 video stream 在出现错误时返回 Err (#231)
This commit is contained in:
@@ -98,7 +98,10 @@ pub(super) async fn collection_from<'a>(
|
||||
path: &Path,
|
||||
bili_client: &'a BiliClient,
|
||||
connection: &DatabaseConnection,
|
||||
) -> Result<(Box<dyn VideoListModel>, Pin<Box<dyn Stream<Item = VideoInfo> + 'a>>)> {
|
||||
) -> Result<(
|
||||
Box<dyn VideoListModel>,
|
||||
Pin<Box<dyn Stream<Item = Result<VideoInfo>> + 'a>>,
|
||||
)> {
|
||||
let collection = Collection::new(bili_client, collection_item);
|
||||
let collection_info = collection.get_info().await?;
|
||||
collection::Entity::insert(collection::ActiveModel {
|
||||
@@ -133,6 +136,6 @@ pub(super) async fn collection_from<'a>(
|
||||
.await?
|
||||
.context("collection not found")?,
|
||||
),
|
||||
Box::pin(collection.into_simple_video_stream()),
|
||||
Box::pin(collection.into_video_stream()),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -70,7 +70,10 @@ pub(super) async fn favorite_from<'a>(
|
||||
path: &Path,
|
||||
bili_client: &'a BiliClient,
|
||||
connection: &DatabaseConnection,
|
||||
) -> Result<(Box<dyn VideoListModel>, Pin<Box<dyn Stream<Item = VideoInfo> + 'a>>)> {
|
||||
) -> Result<(
|
||||
Box<dyn VideoListModel>,
|
||||
Pin<Box<dyn Stream<Item = Result<VideoInfo>> + 'a>>,
|
||||
)> {
|
||||
let favorite = FavoriteList::new(bili_client, fid.to_owned());
|
||||
let favorite_info = favorite.get_info().await?;
|
||||
favorite::Entity::insert(favorite::ActiveModel {
|
||||
|
||||
@@ -67,7 +67,10 @@ pub async fn video_list_from<'a>(
|
||||
path: &Path,
|
||||
bili_client: &'a BiliClient,
|
||||
connection: &DatabaseConnection,
|
||||
) -> Result<(Box<dyn VideoListModel>, Pin<Box<dyn Stream<Item = VideoInfo> + 'a>>)> {
|
||||
) -> Result<(
|
||||
Box<dyn VideoListModel>,
|
||||
Pin<Box<dyn Stream<Item = Result<VideoInfo>> + 'a>>,
|
||||
)> {
|
||||
match args {
|
||||
Args::Favorite { fid } => favorite_from(fid, path, bili_client, connection).await,
|
||||
Args::Collection { collection_item } => collection_from(collection_item, path, bili_client, connection).await,
|
||||
|
||||
@@ -82,7 +82,10 @@ pub(super) async fn submission_from<'a>(
|
||||
path: &Path,
|
||||
bili_client: &'a BiliClient,
|
||||
connection: &DatabaseConnection,
|
||||
) -> Result<(Box<dyn VideoListModel>, Pin<Box<dyn Stream<Item = VideoInfo> + 'a>>)> {
|
||||
) -> Result<(
|
||||
Box<dyn VideoListModel>,
|
||||
Pin<Box<dyn Stream<Item = Result<VideoInfo>> + 'a>>,
|
||||
)> {
|
||||
let submission = Submission::new(bili_client, upper_id.to_owned());
|
||||
let upper = submission.get_info().await?;
|
||||
submission::Entity::insert(submission::ActiveModel {
|
||||
|
||||
@@ -66,7 +66,10 @@ pub(super) async fn watch_later_from<'a>(
|
||||
path: &Path,
|
||||
bili_client: &'a BiliClient,
|
||||
connection: &DatabaseConnection,
|
||||
) -> Result<(Box<dyn VideoListModel>, Pin<Box<dyn Stream<Item = VideoInfo> + 'a>>)> {
|
||||
) -> Result<(
|
||||
Box<dyn VideoListModel>,
|
||||
Pin<Box<dyn Stream<Item = Result<VideoInfo>> + 'a>>,
|
||||
)> {
|
||||
let watch_later = WatchLater::new(bili_client);
|
||||
watch_later::Entity::insert(watch_later::ActiveModel {
|
||||
id: Set(1),
|
||||
|
||||
Reference in New Issue
Block a user