redirect ugc to pgc

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-03-08 11:25:20 +08:00
parent a1f15b5da5
commit 01a74e191a
6 changed files with 34 additions and 12 deletions

View File

@@ -7,6 +7,7 @@ import 'package:PiliPlus/models/model_avatar.dart';
import 'package:PiliPlus/models/model_owner.dart';
import 'package:PiliPlus/models_new/live/live_feed_index/watched_show.dart';
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
import 'package:PiliPlus/utils/parse_string.dart';
import 'package:PiliPlus/utils/storage_pref.dart';
import 'package:PiliPlus/utils/utils.dart';
@@ -429,7 +430,7 @@ class ModuleAuthorModel extends Avatar {
pendant = null;
}
isTop = json['is_top'];
badgeText = _parseString(json['icon_badge']?['text']);
badgeText = noneNullOrEmptyString(json['icon_badge']?['text']);
}
}
@@ -682,7 +683,9 @@ class Vote {
Vote.fromJson(Map<String, dynamic> json) {
joinNum = Utils.safeToInt(json['join_num']);
voteId = Utils.safeToInt(json['vote_id']);
title = _parseString(json['title']) ?? _parseString(json['desc']);
title =
noneNullOrEmptyString(json['title']) ??
noneNullOrEmptyString(json['desc']);
}
}
@@ -1170,18 +1173,13 @@ class Emoji {
Emoji.fromJson(Map<String, dynamic> json) {
url =
_parseString(json['webp_url']) ??
_parseString(json['gif_url']) ??
_parseString(json['icon_url']);
noneNullOrEmptyString(json['webp_url']) ??
noneNullOrEmptyString(json['gif_url']) ??
noneNullOrEmptyString(json['icon_url']);
size = json['size'] ?? 1;
}
}
String? _parseString(String? value) {
if (value == null || value.isEmpty) return null;
return value;
}
class DynamicNoneModel {
DynamicNoneModel({
this.tips,
@@ -1297,7 +1295,7 @@ class ModuleTag {
String? text;
ModuleTag.fromJson(Map<String, dynamic> json) {
text = _parseString(json['text']);
text = noneNullOrEmptyString(json['text']);
}
}

View File

@@ -9,6 +9,7 @@ import 'package:PiliPlus/models_new/video/video_detail/stat.dart';
import 'package:PiliPlus/models_new/video/video_detail/subtitle.dart';
import 'package:PiliPlus/models_new/video/video_detail/ugc_season.dart';
import 'package:PiliPlus/models_new/video/video_detail/user_garb.dart';
import 'package:PiliPlus/utils/parse_string.dart';
class VideoDetailData {
String? bvid;
@@ -177,6 +178,6 @@ class VideoDetailData {
staff: (json["staff"] as List?)
?.map((item) => Staff.fromJson(item))
.toList(),
redirectUrl: json['redirect_url'],
redirectUrl: noneNullOrEmptyString(json['redirect_url']),
);
}

View File

@@ -90,6 +90,14 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
queryVideoTags();
final res = await VideoHttp.videoIntro(bvid: bvid);
if (res case Success(:final response)) {
if (response.redirectUrl != null &&
videoDetailCtr.epId == null &&
videoDetailCtr.seasonId == null) {
if (!isClosed) {
PageUtils.viewPgcFromUri(response.redirectUrl!, off: true);
}
return;
}
videoPlayerServiceHandler?.onVideoDetailChange(
response,
cid.value,

View File

@@ -1592,6 +1592,9 @@ class PlPlayerController with BlockConfigMixin {
if (playerStatus.isPlaying) {
WakelockPlus.disable();
}
if (kDebugMode) {
debugPrint('dispose player');
}
_videoPlayerController?.dispose();
_videoPlayerController = null;
_videoController = null;

View File

@@ -585,6 +585,7 @@ abstract final class PageUtils {
bool isPgc = true,
int? progress, // milliseconds
int? aid,
bool off = false,
}) {
RegExpMatch? match = _pgcRegex.firstMatch(uri);
if (match != null) {
@@ -595,12 +596,14 @@ abstract final class PageUtils {
seasonId: isSeason ? id : null,
epId: isSeason ? null : id,
progress: progress,
off: off,
);
} else {
viewPugv(
seasonId: isSeason ? id : null,
epId: isSeason ? null : id,
aid: aid,
off: off,
);
}
return true;
@@ -628,6 +631,7 @@ abstract final class PageUtils {
dynamic seasonId,
dynamic epId,
int? progress, // milliseconds
bool off = false,
}) async {
try {
SmartDialog.showLoading(msg: '资源获取中');
@@ -652,6 +656,7 @@ abstract final class PageUtils {
'pgcApi': true,
'pgcItem': response,
},
off: off,
);
}
@@ -700,6 +705,7 @@ abstract final class PageUtils {
extraArguments: {
'pgcItem': response,
},
off: off,
);
return;
} else {
@@ -725,6 +731,7 @@ abstract final class PageUtils {
dynamic seasonId,
dynamic epId,
int? aid,
bool off = false,
}) async {
try {
SmartDialog.showLoading(msg: '资源获取中');
@@ -752,6 +759,7 @@ abstract final class PageUtils {
extraArguments: {
'pgcItem': response,
},
off: off,
);
} else {
SmartDialog.showToast('资源加载失败');

View File

@@ -0,0 +1,4 @@
String? noneNullOrEmptyString(String? value) {
if (value == null || value.isEmpty) return null;
return value;
}