mod: 补充scheme
This commit is contained in:
@ -65,13 +65,11 @@
|
|||||||
/>
|
/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<action android:name="android.intent.action.SEARCH" />
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.BROWSABLE" />
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
<data android:scheme="bilibili" android:host="forward" />
|
<data android:scheme="bilibili" android:host="forward" />
|
||||||
<data android:scheme="bilibili" android:host="comment"
|
<data android:scheme="bilibili" android:host="comment"
|
||||||
android:pathPattern="/detail/.*/.*/.*" />
|
android:pathPattern="/detail/.*/.*/.*" />
|
||||||
|
@ -12,7 +12,7 @@ class PiliSchame {
|
|||||||
static AppScheme appScheme = AppSchemeImpl.getInstance() as AppScheme;
|
static AppScheme appScheme = AppSchemeImpl.getInstance() as AppScheme;
|
||||||
static void init() async {
|
static void init() async {
|
||||||
///
|
///
|
||||||
SchemeEntity? value = await appScheme.getInitScheme();
|
final SchemeEntity? value = await appScheme.getInitScheme();
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
_routePush(value);
|
_routePush(value);
|
||||||
}
|
}
|
||||||
@ -34,9 +34,9 @@ class PiliSchame {
|
|||||||
|
|
||||||
/// 路由跳转
|
/// 路由跳转
|
||||||
static void _routePush(value) async {
|
static void _routePush(value) async {
|
||||||
String scheme = value.scheme;
|
final String scheme = value.scheme;
|
||||||
String host = value.host;
|
final String host = value.host;
|
||||||
String path = value.path;
|
final String path = value.path;
|
||||||
|
|
||||||
if (scheme == 'bilibili') {
|
if (scheme == 'bilibili') {
|
||||||
// bilibili://root
|
// bilibili://root
|
||||||
@ -55,9 +55,19 @@ class PiliSchame {
|
|||||||
|
|
||||||
// bilibili://video/{aid}
|
// bilibili://video/{aid}
|
||||||
else if (host == 'video') {
|
else if (host == 'video') {
|
||||||
var pathQuery = path.split('/').last;
|
String pathQuery = path.split('/').last;
|
||||||
int aid = int.parse(pathQuery);
|
final numericRegex = RegExp(r'^[0-9]+$');
|
||||||
_videoPush(aid, null);
|
if (numericRegex.hasMatch(pathQuery)) {
|
||||||
|
pathQuery = 'AV$pathQuery';
|
||||||
|
}
|
||||||
|
Map map = IdUtils.matchAvorBv(input: pathQuery);
|
||||||
|
if (map.containsKey('AV')) {
|
||||||
|
_videoPush(map['AV'], null);
|
||||||
|
} else if (map.containsKey('BV')) {
|
||||||
|
_videoPush(null, map['BV']);
|
||||||
|
} else {
|
||||||
|
SmartDialog.showToast('投稿匹配失败');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bilibili://live/{roomid}
|
// bilibili://live/{roomid}
|
||||||
@ -74,6 +84,22 @@ class PiliSchame {
|
|||||||
_bangumiPush(int.parse(seasonId));
|
_bangumiPush(int.parse(seasonId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 专栏 bilibili://opus/detail/883089655985078289
|
||||||
|
else if (host == 'opus') {
|
||||||
|
if (path.startsWith('/detail')) {
|
||||||
|
var opusId = path.split('/').last;
|
||||||
|
Get.toNamed(
|
||||||
|
'/webview',
|
||||||
|
parameters: {
|
||||||
|
'url': 'https://www.bilibili.com/opus/$opusId',
|
||||||
|
'type': 'url',
|
||||||
|
'pageTitle': '',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (host == 'search') {
|
||||||
|
Get.toNamed('/searchResult', parameters: {'keyword': ''});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,9 +135,9 @@ class PiliSchame {
|
|||||||
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: null);
|
var result = await SearchHttp.bangumiInfo(seasonId: seasonId, epId: null);
|
||||||
if (result['status']) {
|
if (result['status']) {
|
||||||
var bangumiDetail = result['data'];
|
var bangumiDetail = result['data'];
|
||||||
int cid = bangumiDetail.episodes!.first.cid;
|
final int cid = bangumiDetail.episodes!.first.cid;
|
||||||
String bvid = IdUtils.av2bv(bangumiDetail.episodes!.first.aid);
|
final String bvid = IdUtils.av2bv(bangumiDetail.episodes!.first.aid);
|
||||||
String heroTag = Utils.makeHeroTag(cid);
|
final String heroTag = Utils.makeHeroTag(cid);
|
||||||
var epId = bangumiDetail.episodes!.first.id;
|
var epId = bangumiDetail.episodes!.first.id;
|
||||||
SmartDialog.dismiss().then(
|
SmartDialog.dismiss().then(
|
||||||
(e) => Get.toNamed(
|
(e) => Get.toNamed(
|
||||||
@ -132,9 +158,9 @@ class PiliSchame {
|
|||||||
static void _fullPathPush(value) async {
|
static void _fullPathPush(value) async {
|
||||||
// https://m.bilibili.com/bangumi/play/ss39708
|
// https://m.bilibili.com/bangumi/play/ss39708
|
||||||
// https | m.bilibili.com | /bangumi/play/ss39708
|
// https | m.bilibili.com | /bangumi/play/ss39708
|
||||||
String scheme = value.scheme!;
|
final String scheme = value.scheme!;
|
||||||
String host = value.host!;
|
final String host = value.host!;
|
||||||
String? path = value.path;
|
final String? path = value.path;
|
||||||
// Map<String, String> query = value.query!;
|
// Map<String, String> query = value.query!;
|
||||||
if (host.startsWith('live.bilibili')) {
|
if (host.startsWith('live.bilibili')) {
|
||||||
int roomId = int.parse(path!.split('/').last);
|
int roomId = int.parse(path!.split('/').last);
|
||||||
@ -148,11 +174,11 @@ class PiliSchame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
String area = path.split('/')[1];
|
final String area = path.split('/')[1];
|
||||||
switch (area) {
|
switch (area) {
|
||||||
case 'bangumi':
|
case 'bangumi':
|
||||||
// print('番剧');
|
// print('番剧');
|
||||||
String seasonId = path.split('/').last;
|
final String seasonId = path.split('/').last;
|
||||||
_bangumiPush(matchNum(seasonId).first);
|
_bangumiPush(matchNum(seasonId).first);
|
||||||
break;
|
break;
|
||||||
case 'video':
|
case 'video':
|
||||||
@ -177,9 +203,9 @@ class PiliSchame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static List<int> matchNum(String str) {
|
static List<int> matchNum(String str) {
|
||||||
RegExp regExp = RegExp(r'\d+');
|
final RegExp regExp = RegExp(r'\d+');
|
||||||
Iterable<Match> matches = regExp.allMatches(str);
|
final Iterable<Match> matches = regExp.allMatches(str);
|
||||||
|
|
||||||
return matches.map((match) => int.parse(match.group(0)!)).toList();
|
return matches.map((Match match) => int.parse(match.group(0)!)).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ class IdUtils {
|
|||||||
result['BV'] = bvs[0].substring(0, 2).toUpperCase() + bvs[0].substring(2);
|
result['BV'] = bvs[0].substring(0, 2).toUpperCase() + bvs[0].substring(2);
|
||||||
}
|
}
|
||||||
if (avs.isNotEmpty) {
|
if (avs.isNotEmpty) {
|
||||||
result['AV'] = avs[0].substring(2);
|
result['AV'] = int.parse(avs[0].substring(2));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user