From c2ae3cdbbaaccbf0a7144b99e0de1380d505c5c1 Mon Sep 17 00:00:00 2001 From: dom Date: Fri, 12 Jun 2026 09:28:09 +0800 Subject: [PATCH] fix #2386 Signed-off-by: dom --- lib/http/video.dart | 33 ++++++++++++++++++--------------- lib/models/video/play/url.dart | 4 +++- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/http/video.dart b/lib/http/video.dart index 3d10063a1..706b12b5e 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -242,24 +242,27 @@ abstract final class VideoHttp { if (res.data['code'] == 0) { late PlayUrlModel data; switch (videoType) { - case VideoType.ugc: + case .ugc: data = PlayUrlModel.fromJson(res.data['data']); - break; - case VideoType.pugv: - final result = res.data['data']; - data = PlayUrlModel.fromJson(result) - ..lastPlayTime = - result?['play_view_business_info']?['user_status']?['watch_progress']?['current_watch_progress']; - break; - case VideoType.pgc: + + case .pgc: final result = res.data['result']; - data = PlayUrlModel.fromJson(result['video_info']) - ..lastPlayTime = - result?['play_view_business_info']?['user_status']?['watch_progress']?['current_watch_progress']; - break; + data = PlayUrlModel.fromJson(result['video_info']); + if (result['play_view_business_info']?['user_status']?['watch_progress']?['current_watch_progress'] + case final int progress when progress > 0) { + data.lastPlayTime = progress; + } + + case .pugv: + final result = res.data['data']; + data = PlayUrlModel.fromJson(result); + if (result['play_view_business_info']?['user_status']?['watch_progress']?['current_watch_progress'] + case final int progress when progress > 0) { + data.lastPlayTime = progress; + } } return Success(data); - } else if (epid != null && videoType == VideoType.ugc) { + } else if (epid != null && videoType == .ugc) { return await videoUrl( avid: avid, bvid: bvid, @@ -268,7 +271,7 @@ abstract final class VideoHttp { epid: epid, seasonId: seasonId, tryLook: tryLook, - videoType: VideoType.pgc, + videoType: .pgc, ); } return Error(_parseVideoErr(res.data['code'], res.data['message'])); diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index a8234de28..fd941964a 100644 --- a/lib/models/video/play/url.dart +++ b/lib/models/video/play/url.dart @@ -69,7 +69,9 @@ class PlayUrlModel { ?.map((e) => FormatItem.fromJson(e)) .toList(); volume = json['volume'] == null ? null : Volume.fromJson(json['volume']); - lastPlayTime = json['last_play_time']; + if (json['last_play_time'] case final int progress when progress > 0) { + lastPlayTime = progress; + } lastPlayCid = json['last_play_cid']; curLanguage = json['cur_language']; language = json['language'] == null