From 76545397d4fabd3393d804ab1f8948e96d339d92 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 8 Feb 2025 23:22:13 +0800 Subject: [PATCH] mod: video push Signed-off-by: bggRGjQaUbCoE --- lib/utils/app_scheme.dart | 26 +++++++++----------------- lib/utils/id_utils.dart | 5 ++--- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index a0985a8b..93c2f6eb 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -77,10 +77,8 @@ class PiliScheme { 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']); + if (map.isNotEmpty) { + videoPush(map['AV'], map['BV']); } else { SmartDialog.showToast('投稿匹配失败'); } @@ -321,10 +319,8 @@ class PiliScheme { 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); + if (map.isNotEmpty) { + videoPush(map['AV'], map['BV']); } else { SmartDialog.showToast('投稿匹配失败'); } @@ -366,10 +362,8 @@ class PiliScheme { case 'video': debugPrint('投稿'); final Map map = IdUtils.matchAvorBv(input: path); - if (map.containsKey('AV')) { - videoPush(map['AV']! as int, null); - } else if (map.containsKey('BV')) { - videoPush(null, map['BV'] as String); + if (map.isNotEmpty) { + videoPush(map['AV'], map['BV']); } else { SmartDialog.showToast('投稿匹配失败'); } @@ -396,11 +390,9 @@ class PiliScheme { arguments: {'face': ''}); break; default: - var res = IdUtils.matchAvorBv(input: area.split('?').first); - if (res.containsKey('AV')) { - videoPush(res['AV']! as int, null); - } else if (res.containsKey('BV')) { - videoPush(null, res['BV'] as String); + Map map = IdUtils.matchAvorBv(input: area.split('?').first); + if (map.isNotEmpty) { + videoPush(map['AV'], map['BV']); } else { // SmartDialog.showToast('未知路径或匹配错误:$value,先采用浏览器打开'); Utils.handleWebview(value.toString()); diff --git a/lib/utils/id_utils.dart b/lib/utils/id_utils.dart index e7591fe6..ea8cb593 100644 --- a/lib/utils/id_utils.dart +++ b/lib/utils/id_utils.dart @@ -68,11 +68,10 @@ class IdUtils { if (input == null || input.isEmpty) { return result; } - final RegExp bvRegex = - RegExp(r'^bv([0-9A-Za-z]{10})', caseSensitive: false); + final RegExp bvRegex = RegExp(r'bv([0-9A-Za-z]{10})', caseSensitive: false); String? bvid = bvRegex.firstMatch(input)?.group(1); - late final RegExp avRegex = RegExp(r'^av(\d+)', caseSensitive: false); + late final RegExp avRegex = RegExp(r'av(\d+)', caseSensitive: false); late String? aid = avRegex.firstMatch(input)?.group(1); if (bvid != null) {