mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: webview to video
Closes #209 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -225,18 +225,12 @@ class PiliScheme {
|
||||
}
|
||||
|
||||
// 投稿跳转
|
||||
static Future<void> videoPush(int? aidVal, String? bvidVal) async {
|
||||
static Future<void> videoPush(int? aid, String? bvid) async {
|
||||
try {
|
||||
int? aid = aidVal;
|
||||
String? bvid = bvidVal;
|
||||
if (aidVal == null) {
|
||||
aid = IdUtils.bv2av(bvidVal!);
|
||||
}
|
||||
if (bvidVal == null) {
|
||||
bvid = IdUtils.av2bv(aidVal!);
|
||||
}
|
||||
aid ??= IdUtils.bv2av(bvid!);
|
||||
bvid ??= IdUtils.av2bv(aid);
|
||||
SmartDialog.showLoading<dynamic>(msg: '获取中...');
|
||||
final int cid = await SearchHttp.ab2c(bvid: bvidVal, aid: aidVal);
|
||||
final int cid = await SearchHttp.ab2c(bvid: bvid, aid: aid);
|
||||
SmartDialog.dismiss();
|
||||
Utils.toDupNamed(
|
||||
'/video?bvid=$bvid&cid=$cid',
|
||||
|
||||
@@ -68,23 +68,16 @@ class IdUtils {
|
||||
if (input == null || input.isEmpty) {
|
||||
return result;
|
||||
}
|
||||
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 RegExp bvRegex = RegExp(r'bv([0-9A-Za-z]+)', caseSensitive: false);
|
||||
String? bvid = bvRegex.firstMatch(input)?.group(1);
|
||||
|
||||
final Iterable<Match> bvMatches = bvRegex.allMatches(input);
|
||||
final Iterable<Match> avMatches = avRegex.allMatches(input);
|
||||
late final RegExp avRegex = RegExp(r'av(\d+)', caseSensitive: false);
|
||||
late String? aid = avRegex.firstMatch(input)?.group(1);
|
||||
|
||||
final List<String> bvs =
|
||||
bvMatches.map((Match match) => match.group(0)!).toList();
|
||||
final List<String> avs =
|
||||
avMatches.map((Match match) => match.group(0)!).toList();
|
||||
|
||||
if (bvs.isNotEmpty) {
|
||||
result['BV'] = bvs[0].substring(0, 2).toUpperCase() + bvs[0].substring(2);
|
||||
}
|
||||
if (avs.isNotEmpty) {
|
||||
result['AV'] = int.parse(avs[0].substring(2));
|
||||
if (bvid != null) {
|
||||
result['BV'] = 'BV$bvid';
|
||||
} else if (aid != null) {
|
||||
result['AV'] = int.parse(aid);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user