opt video scheme

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-01-27 11:20:03 +08:00
parent fa348db7c5
commit 110469961d
5 changed files with 32 additions and 19 deletions

View File

@@ -41,6 +41,18 @@ abstract final class PiliScheme {
listener = appLinks.uriLinkStream.listen(routePush);
}
static int? _videoProgress(Map<String, String> queryParameters) {
if ((queryParameters['start_progress'] ?? queryParameters['dm_progress'])
case final p?) {
return int.tryParse(p);
} else if (queryParameters['t'] case final t0?) {
if (double.tryParse(t0) case final t1?) {
return (t1 * 1000).toInt();
}
}
return null;
}
static Future<bool> routePushFromUrl(
String url, {
bool selfHandle = false,
@@ -99,7 +111,7 @@ abstract final class PiliScheme {
PageUtils.viewPgc(
seasonId: isEp ? null : id,
epId: isEp ? id : null,
progress: uri.queryParameters['start_progress'],
progress: _videoProgress(uri.queryParameters),
);
return true;
}
@@ -121,7 +133,6 @@ abstract final class PiliScheme {
// bilibili://video/{aid}/?comment_root_id=***&comment_secondary_id=***
final queryParameters = uri.queryParameters;
if (queryParameters['comment_root_id'] != null) {
// to check
// to video reply
String? oid = uriDigitRegExp.firstMatch(path)?.group(1);
int? rpid = int.tryParse(queryParameters['comment_root_id']!);
@@ -146,11 +157,10 @@ abstract final class PiliScheme {
final cid = queryParameters['cid'];
if (cid != null) {
bvid ??= IdUtils.av2bv(int.parse(aid!));
final progress = queryParameters['dm_progress'];
PageUtils.toVideoPage(
bvid: bvid,
cid: int.parse(cid),
progress: progress == null ? null : int.parse(progress),
progress: _videoProgress(queryParameters),
off: off,
);
} else {
@@ -158,7 +168,7 @@ abstract final class PiliScheme {
aid != null ? int.parse(aid) : null,
bvid,
off: off,
progress: queryParameters['dm_progress'],
progress: _videoProgress(queryParameters),
);
}
return true;
@@ -629,12 +639,9 @@ abstract final class PiliScheme {
case 'bangumi':
// www.bilibili.com/bangumi/play/ep{eid}?start_progress={offset}&thumb_up_dm_id={dmid}
// if (kDebugMode) debugPrint('番剧');
final queryParameters = uri.queryParameters;
bool hasMatch = PageUtils.viewPgcFromUri(
path,
progress:
queryParameters['start_progress'] ??
queryParameters['dm_progress'],
progress: _videoProgress(uri.queryParameters),
);
if (hasMatch) {
return true;
@@ -662,7 +669,7 @@ abstract final class PiliScheme {
res.av,
res.bv,
off: off,
progress: queryParameters['dm_progress'],
progress: _videoProgress(queryParameters),
part: part,
);
return true;
@@ -850,7 +857,7 @@ abstract final class PiliScheme {
String? bvid, {
bool showDialog = true,
bool off = false,
String? progress,
int? progress, // milliseconds
String? part,
}) async {
try {
@@ -872,7 +879,7 @@ abstract final class PiliScheme {
aid: aid,
bvid: bvid,
cid: cid,
progress: progress == null ? null : int.parse(progress),
progress: progress,
off: off,
);
}