Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2026-01-02 12:05:31 +08:00
parent 80e007bac6
commit 041af37bb0
67 changed files with 775 additions and 838 deletions

View File

@@ -1,3 +1,4 @@
import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/http/video.dart';
import 'package:PiliPlus/models/common/account_type.dart';
import 'package:PiliPlus/models/common/video/audio_quality.dart';
@@ -37,18 +38,17 @@ abstract final class DownloadHttp {
_ => VideoType.ugc,
},
);
if (res.isSuccess) {
final PlayUrlModel data = res.data;
final Dash? dash = data.dash;
if (res case Success(:final response)) {
final Dash? dash = response.dash;
if (dash != null) {
final List<VideoItem> videoList = dash.video!;
final curHighestVideoQa = videoList.first.quality.code;
final preferVideoQa = entry.preferedVideoQuality;
int targetVideoQa = curHighestVideoQa;
if (data.acceptQuality?.isNotEmpty == true &&
if (response.acceptQuality?.isNotEmpty == true &&
preferVideoQa <= curHighestVideoQa) {
// 如果预设的画质低于当前最高
targetVideoQa = data.acceptQuality!.findClosestTarget(
targetVideoQa = response.acceptQuality!.findClosestTarget(
(e) => e <= preferVideoQa,
(a, b) => a > b ? a : b,
);
@@ -60,7 +60,7 @@ abstract final class DownloadHttp {
.toList();
/// 优先顺序 设置中指定解码格式 -> 当前可选的首个解码格式
final List<FormatItem> supportFormats = data.supportFormats!;
final List<FormatItem> supportFormats = response.supportFormats!;
// 根据画质选编码格式
final FormatItem targetSupportFormats = supportFormats.firstWhere(
(e) => e.quality == targetVideoQa,
@@ -170,7 +170,7 @@ abstract final class DownloadHttp {
userAgent: userAgent,
);
} else {
final first = data.durl!.first;
final first = response.durl!.first;
final List<Type1Segment> segmentList = [
Type1Segment(
backupUrls: [],
@@ -182,9 +182,8 @@ abstract final class DownloadHttp {
url: VideoUtils.getCdnUrl(first.playUrls),
),
];
final FormatItem? formatItem = data.supportFormats?.firstWhereOrNull(
(e) => e.quality == data.quality,
);
final FormatItem? formatItem = response.supportFormats
?.firstWhereOrNull((e) => e.quality == response.quality);
final String description =
formatItem?.newDesc ?? VideoQuality.clear480.desc;
final int targetVideoQa =
@@ -223,7 +222,7 @@ abstract final class DownloadHttp {
marlinToken: '',
videoCodecId: 0,
videoProject: true,
format: data.format!,
format: response.format!,
playerError: 0,
needVip: false,
needLogin: false,