diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index d82845fea..c52d8447a 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -223,6 +223,10 @@
android:pathPattern="/mobile/video/.*" />
+
+
diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart
index 6820050c9..bb9d556f9 100644
--- a/lib/utils/app_scheme.dart
+++ b/lib/utils/app_scheme.dart
@@ -5,6 +5,7 @@ import 'package:get/get.dart';
import '../http/search.dart';
import '../models/common/search_type.dart';
import 'id_utils.dart';
+import 'url_utils.dart';
import 'utils.dart';
class PiliSchame {
@@ -38,23 +39,16 @@ class PiliSchame {
final String path = value.path;
if (scheme == 'bilibili') {
- // bilibili://root
if (host == 'root') {
Navigator.popUntil(
Get.context!, (Route route) => route.isFirst);
- }
-
- // bilibili://space/{uid}
- else if (host == 'space') {
+ } else if (host == 'space') {
final String mid = path.split('/').last;
Get.toNamed(
'/member?mid=$mid',
arguments: {'face': null},
);
- }
-
- // bilibili://video/{aid}
- else if (host == 'video') {
+ } else if (host == 'video') {
String pathQuery = path.split('/').last;
final numericRegex = RegExp(r'^[0-9]+$');
if (numericRegex.hasMatch(pathQuery)) {
@@ -68,24 +62,16 @@ class PiliSchame {
} else {
SmartDialog.showToast('投稿匹配失败');
}
- }
-
- // bilibili://live/{roomid}
- else if (host == 'live') {
+ } else if (host == 'live') {
final String roomId = path.split('/').last;
Get.toNamed('/liveRoom?roomid=$roomId',
arguments: {'liveItem': null, 'heroTag': roomId});
- }
-
- // bilibili://bangumi/season/${ssid}
- else if (host == 'bangumi') {
+ } else if (host == 'bangumi') {
if (path.startsWith('/season')) {
final String seasonId = path.split('/').last;
- _bangumiPush(int.parse(seasonId));
+ _bangumiPush(int.parse(seasonId), null);
}
- }
- // 专栏 bilibili://opus/detail/883089655985078289
- else if (host == 'opus') {
+ } else if (host == 'opus') {
if (path.startsWith('/detail')) {
var opusId = path.split('/').last;
Get.toNamed(
@@ -101,6 +87,9 @@ class PiliSchame {
Get.toNamed('/searchResult', parameters: {'keyword': ''});
}
}
+ if (scheme == 'https') {
+ _fullPathPush(value);
+ }
}
// 投稿跳转
@@ -131,10 +120,10 @@ class PiliSchame {
}
// 番剧跳转
- static Future _bangumiPush(int seasonId) async {
+ static Future _bangumiPush(int? seasonId, int? epId) async {
SmartDialog.showLoading(msg: '获取中...');
try {
- var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: null);
+ var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: epId);
if (result['status']) {
var bangumiDetail = result['data'];
final int cid = bangumiDetail.episodes!.first.cid;
@@ -151,6 +140,8 @@ class PiliSchame {
},
),
);
+ } else {
+ SmartDialog.showToast(result['msg']);
}
} catch (e) {
SmartDialog.showToast('番剧获取失败:$e');
@@ -163,29 +154,67 @@ class PiliSchame {
// final String scheme = value.scheme!;
final String host = value.host!;
final String? path = value.path;
- // Map query = value.query!;
- if (host.startsWith('live.bilibili')) {
+ Map? query = value.query;
+ RegExp regExp = RegExp(r'^(www\.)?m?\.(bilibili\.com)$');
+ if (regExp.hasMatch(host)) {
+ print('bilibili.com');
+ } else if (host.contains('live')) {
int roomId = int.parse(path!.split('/').last);
- // print('直播');
- Get.toNamed('/liveRoom?roomid=$roomId',
- arguments: {'liveItem': null, 'heroTag': roomId.toString()});
- return;
- }
- if (host.startsWith('space.bilibili')) {
- print('个人空间');
+ Get.toNamed(
+ '/liveRoom?roomid=$roomId',
+ arguments: {'liveItem': null, 'heroTag': roomId.toString()},
+ );
+ } else if (host.contains('space')) {
+ var mid = path!.split('/').last;
+ Get.toNamed('/member?mid=$mid', arguments: {'face': ''});
return;
+ } else if (host == 'b23.tv') {
+ final String fullPath = 'https://$host$path';
+ final String redirectUrl = await UrlUtils.parseRedirectUrl(fullPath);
+ final String pathSegment = Uri.parse(redirectUrl).path;
+ final String lastPathSegment = pathSegment.split('/').last;
+ final RegExp avRegex = RegExp(r'^[aA][vV]\d+', caseSensitive: false);
+ if (avRegex.hasMatch(lastPathSegment)) {
+ final Map map =
+ IdUtils.matchAvorBv(input: lastPathSegment);
+ if (map.containsKey('AV')) {
+ _videoPush(map['AV']! as int, null);
+ } else if (map.containsKey('BV')) {
+ _videoPush(null, map['BV'] as String);
+ } else {
+ SmartDialog.showToast('投稿匹配失败');
+ }
+ } else if (lastPathSegment.startsWith('ep')) {
+ _handleEpisodePath(lastPathSegment, redirectUrl);
+ } else if (lastPathSegment.startsWith('ss')) {
+ _handleSeasonPath(lastPathSegment, redirectUrl);
+ } else if (lastPathSegment.startsWith('BV')) {
+ UrlUtils.matchUrlPush(
+ lastPathSegment,
+ '',
+ redirectUrl,
+ );
+ } else {
+ Get.toNamed(
+ '/webview',
+ parameters: {'url': redirectUrl, 'type': 'url', 'pageTitle': ''},
+ );
+ }
}
if (path != null) {
- final String area = path.split('/')[1];
+ final String area = path.split('/').last;
switch (area) {
case 'bangumi':
- // print('番剧');
- final String seasonId = path.split('/').last;
- _bangumiPush(matchNum(seasonId).first);
+ print('番剧');
+ if (area.startsWith('ep')) {
+ _bangumiPush(null, matchNum(area).first);
+ } else if (area.startsWith('ss')) {
+ _bangumiPush(matchNum(area).first, null);
+ }
break;
case 'video':
- // print('投稿');
+ print('投稿');
final Map map = IdUtils.matchAvorBv(input: path);
if (map.containsKey('AV')) {
_videoPush(map['AV']! as int, null);
@@ -200,6 +229,7 @@ class PiliSchame {
break;
case 'space':
print('个人空间');
+ Get.toNamed('/member?mid=$area', arguments: {'face': ''});
break;
}
}
@@ -211,4 +241,18 @@ class PiliSchame {
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
}
+
+ static void _handleEpisodePath(String lastPathSegment, String redirectUrl) {
+ final String seasonId = _extractIdFromPath(lastPathSegment);
+ _bangumiPush(null, matchNum(seasonId).first);
+ }
+
+ static void _handleSeasonPath(String lastPathSegment, String redirectUrl) {
+ final String seasonId = _extractIdFromPath(lastPathSegment);
+ _bangumiPush(matchNum(seasonId).first, null);
+ }
+
+ static String _extractIdFromPath(String lastPathSegment) {
+ return lastPathSegment.split('/').last;
+ }
}
diff --git a/lib/utils/id_utils.dart b/lib/utils/id_utils.dart
index 906f63481..7fefc2689 100644
--- a/lib/utils/id_utils.dart
+++ b/lib/utils/id_utils.dart
@@ -68,8 +68,9 @@ class IdUtils {
if (input == null || input.isEmpty) {
return result;
}
- final RegExp bvRegex = RegExp(r'BV[0-9A-Za-z]{10}', caseSensitive: false);
- final RegExp avRegex = RegExp(r'AV\d+', caseSensitive: false);
+ final RegExp bvRegex =
+ RegExp(r'[bB][vV][0-9A-Za-z]{10}', caseSensitive: false);
+ final RegExp avRegex = RegExp(r'[aA][vV]\d+', caseSensitive: false);
final Iterable bvMatches = bvRegex.allMatches(input);
final Iterable avMatches = avRegex.allMatches(input);