From 108648cabf738d3cc1af50622c03534c820ce86d Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sun, 23 Feb 2025 11:28:10 +0800 Subject: [PATCH] mod: seek from url related #208 Signed-off-by: bggRGjQaUbCoE --- lib/http/search.dart | 8 ++++++-- lib/utils/app_scheme.dart | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/http/search.dart b/lib/http/search.dart index d547fc33..f57b7567 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:PiliPlus/utils/extension.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:PiliPlus/http/loading_state.dart'; @@ -140,7 +141,7 @@ class SearchHttp { } } - static Future ab2c({dynamic aid, dynamic bvid}) async { + static Future ab2c({dynamic aid, dynamic bvid, int? part}) async { Map data = {}; if (aid != null) { data['aid'] = aid; @@ -150,7 +151,10 @@ class SearchHttp { final dynamic res = await Request() .get(Api.ab2c, queryParameters: {...data}); if (res.data['code'] == 0) { - return res.data['data'].first['cid']; + return part != null + ? ((res.data['data'] as List).getOrNull(part - 1)?['cid'] ?? + res.data['data'].first['cid']) + : res.data['data'].first['cid']; } else { SmartDialog.showToast("ab2c error: ${res.data['message']}"); return -1; diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index 93671ea4..a00b83fb 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -453,10 +453,13 @@ class PiliScheme { debugPrint('投稿'); final Map map = IdUtils.matchAvorBv(input: path); if (map.isNotEmpty) { + final queryParameters = uri.queryParameters; videoPush( map['AV'], map['BV'], off: off, + progress: queryParameters['dm_progress'], + part: queryParameters['p'], ); return true; } @@ -547,6 +550,7 @@ class PiliScheme { bool showDialog = true, bool off = false, String? progress, + String? part, }) async { try { aid ??= IdUtils.bv2av(bvid!); @@ -554,7 +558,11 @@ class PiliScheme { if (showDialog) { SmartDialog.showLoading(msg: '获取中...'); } - final int cid = await SearchHttp.ab2c(bvid: bvid, aid: aid); + final int cid = await SearchHttp.ab2c( + bvid: bvid, + aid: aid, + part: part != null ? int.tryParse(part) : null, + ); if (showDialog) { SmartDialog.dismiss(); }