From 12a8226de0cca1273ee6cec3963bfa2f200d8750 Mon Sep 17 00:00:00 2001 From: orz12 Date: Wed, 24 Jan 2024 21:30:42 +0800 Subject: [PATCH] =?UTF-8?q?mod:=20=E5=8C=85=E6=9C=88=E5=85=85=E7=94=B5?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=88?= =?UTF-8?q?=E9=83=A8=E5=88=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/models/video/play/url.dart | 44 +++++++++++++++++++++++++- lib/pages/video/detail/controller.dart | 16 +++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/lib/models/video/play/url.dart b/lib/models/video/play/url.dart index 4c43cb00..965f0c0c 100644 --- a/lib/models/video/play/url.dart +++ b/lib/models/video/play/url.dart @@ -52,7 +52,15 @@ class PlayUrlModel { videoCodecid = json['video_codecid']; seekParam = json['seek_param']; seekType = json['seek_type']; - dash = Dash.fromJson(json['dash']); + if (json['dash'] != null) { + dash = Dash.fromJson(json['dash']); + } else if (json['durl'] != null) { + //试看的充电包月视频可能出现没有dash只有durl的情况 + var durlList = json['durl'] + .map((e) => Durl.fromJson(e)) + .toList(); + //TODO + } supportFormats = json['support_formats'] != null ? json['support_formats'] .map((e) => FormatItem.fromJson(e)) @@ -92,6 +100,40 @@ class Dash { } } +class Durl { + int? order; + int? length; + int? size; + String? ahead; + String? vhead; + String? url; + List? backupUrl; + + Durl({ + this.order, + this.length, + this.size, + this.ahead, + this.vhead, + this.url, + this.backupUrl, + }); + + factory Durl.fromJson(Map json) { + return Durl( + order: json['order'], + length: json['length'], + size: json['size'], + ahead: json['ahead'], + vhead: json['vhead'], + url: json['url'], + backupUrl: json['backup_url'] != null + ? List.from(json['backup_url']) + : [], + ); + } +} + class VideoItem { VideoItem({ this.id, diff --git a/lib/pages/video/detail/controller.dart b/lib/pages/video/detail/controller.dart index f36eb589..440a6383 100644 --- a/lib/pages/video/detail/controller.dart +++ b/lib/pages/video/detail/controller.dart @@ -246,6 +246,16 @@ class VideoDetailController extends GetxController var result = await VideoHttp.videoUrl(cid: cid.value, bvid: bvid); if (result['status']) { data = result['data']; + if (data.dash == null) { + // isEffective.value = false; + if (data.acceptDesc != null) { + SmartDialog.showToast('当前视频acceptDesc为:${data.acceptDesc},不支持获取视频链接'); + } else { + SmartDialog.showToast('当前视频未能获取视频链接'); + } + result['status'] = false; + return result; + } final List allVideosList = data.dash!.video!; try { // 当前可播放的最高质量视频 @@ -349,7 +359,11 @@ class VideoDetailController extends GetxController if (result['code'] == -404) { isShowCover.value = false; } - SmartDialog.showToast(result['msg'].toString()); + if (result['code'] == 87008){ + SmartDialog.showToast("当前视频可能是专属视频,可能需包月充电观看(${result['msg']})"); + } else { + SmartDialog.showToast("错误(${result['code']}):${result['msg']}"); + } } return result; }