From 86c87dc1d5c18b4dc78412799f9c93773c8be375 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 16 Oct 2023 00:06:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E9=A6=96=E9=A1=B5=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/widgets/video_card_v.dart | 34 +++++++++++- lib/http/api.dart | 6 ++ lib/http/dynamics.dart | 31 +++++++++++ lib/http/html.dart | 82 +++++++++++++++++----------- lib/pages/html/view.dart | 2 +- 5 files changed, 121 insertions(+), 34 deletions(-) diff --git a/lib/common/widgets/video_card_v.dart b/lib/common/widgets/video_card_v.dart index 04f6ee3f0..0c315f7b6 100644 --- a/lib/common/widgets/video_card_v.dart +++ b/lib/common/widgets/video_card_v.dart @@ -5,6 +5,7 @@ import 'package:pilipala/common/constants.dart'; import 'package:pilipala/common/widgets/badge.dart'; import 'package:pilipala/common/widgets/stat/danmu.dart'; import 'package:pilipala/common/widgets/stat/view.dart'; +import 'package:pilipala/http/dynamics.dart'; import 'package:pilipala/http/search.dart'; import 'package:pilipala/http/user.dart'; import 'package:pilipala/models/common/search_type.dart'; @@ -27,6 +28,11 @@ class VideoCardV extends StatelessWidget { this.longPressEnd, }) : super(key: key); + bool isStringNumeric(String str) { + RegExp numericRegex = RegExp(r'^\d+$'); + return numericRegex.hasMatch(str); + } + void onPushDetail(heroTag) async { String goto = videoItem.goto; switch (goto) { @@ -64,11 +70,35 @@ class VideoCardV extends StatelessWidget { break; // 动态 case 'picture': + String dynamicType = 'picture'; + String uri = videoItem.uri; + if (videoItem.uri.contains('bilibili://article/')) { + dynamicType = 'article'; + RegExp regex = RegExp(r'\d+'); + Match match = regex.firstMatch(videoItem.uri)!; + String matchedNumber = match.group(0)!; + videoItem.param = 'cv' + matchedNumber; + } + if (uri.startsWith('http')) { + String path = Uri.parse(uri).path; + if (isStringNumeric(path.split('/')[1])) { + // 请求接口 + var res = await DynamicsHttp.dynamicDetail(id: path.split('/')[1]); + if (res['status']) { + Get.toNamed('/dynamicDetail', arguments: { + 'item': res['data'], + 'floor': 1, + 'action': 'detail' + }); + } + return; + } + } Get.toNamed('/htmlRender', parameters: { - 'url': videoItem.uri, + 'url': uri, 'title': videoItem.title, 'id': videoItem.param.toString(), - 'dynamicType': 'picture' + 'dynamicType': dynamicType }); break; default: diff --git a/lib/http/api.dart b/lib/http/api.dart index 50106daed..14f553197 100644 --- a/lib/http/api.dart +++ b/lib/http/api.dart @@ -321,4 +321,10 @@ class Api { // 获取指定分组下的up static const String followUpGroup = '/x/relation/tag'; + + // 获取某个动态详情 + // timezone_offset=-480 + // id=849312409672744983 + // features=itemOpusStyle + static const String dynamicDetail = '/x/polymer/web-dynamic/v1/detail'; } diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index da18cfa4d..7a22ab13c 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -86,4 +86,35 @@ class DynamicsHttp { }; } } + + // + static Future dynamicDetail({ + String? id, + }) async { + var res = await Request().get(Api.dynamicDetail, data: { + 'timezone_offset': -480, + 'id': id, + 'features': 'itemOpusStyle', + }); + if (res.data['code'] == 0) { + try { + return { + 'status': true, + 'data': DynamicItemModel.fromJson(res.data['data']['item']), + }; + } catch (err) { + return { + 'status': false, + 'data': [], + 'msg': err.toString(), + }; + } + } else { + return { + 'status': false, + 'data': [], + 'msg': res.data['message'], + }; + } + } } diff --git a/lib/http/html.dart b/lib/http/html.dart index 4a922e8f9..41570d0ae 100644 --- a/lib/http/html.dart +++ b/lib/http/html.dart @@ -9,37 +9,57 @@ class HtmlHttp { "https://www.bilibili.com/opus/$id", extra: {'ua': 'pc'}, ); - Document rootTree = parse(response.data); - Element body = rootTree.body!; - Element appDom = body.querySelector('#app')!; - Element authorHeader = appDom.querySelector('.fixed-author-header')!; - // 头像 - String avatar = authorHeader.querySelector('img')!.attributes['src']!; - avatar = 'https:${avatar.split('@')[0]}'; - String uname = - authorHeader.querySelector('.fixed-author-header__author__name')!.text; - // 动态详情 - Element opusDetail = appDom.querySelector('.opus-detail')!; - // 发布时间 - String updateTime = - opusDetail.querySelector('.opus-module-author__pub__text')!.text; - // - String opusContent = - opusDetail.querySelector('.opus-module-content')!.innerHtml; - String commentId = opusDetail - .querySelector('.bili-comment-container')! - .className - .split(' ')[1] - .split('-')[2]; - // List imgList = opusDetail.querySelectorAll('bili-album__preview__picture__img'); - return { - 'status': true, - 'avatar': avatar, - 'uname': uname, - 'updateTime': updateTime, - 'content': opusContent, - 'commentId': int.parse(commentId) - }; + + if (response.data.contains('Redirecting to')) { + RegExp regex = RegExp(r'//([\w\.]+)/(\w+)/(\w+)'); + Match match = regex.firstMatch(response.data)!; + String matchedString = match.group(0)!; + response = await Request().get( + 'https:$matchedString' + '/', + extra: {'ua': 'pc'}, + ); + } + try { + Document rootTree = parse(response.data); + // log(response.data.body.toString()); + Element body = rootTree.body!; + Element appDom = body.querySelector('#app')!; + Element authorHeader = appDom.querySelector('.fixed-author-header')!; + // 头像 + String avatar = authorHeader.querySelector('img')!.attributes['src']!; + avatar = 'https:${avatar.split('@')[0]}'; + String uname = authorHeader + .querySelector('.fixed-author-header__author__name')! + .text; + + // 动态详情 + Element opusDetail = appDom.querySelector('.opus-detail')!; + // 发布时间 + String updateTime = + opusDetail.querySelector('.opus-module-author__pub__text')!.text; + // + String opusContent = + opusDetail.querySelector('.opus-module-content')!.innerHtml; + String test = opusDetail + .querySelector('.horizontal-scroll-album__pic__img')! + .innerHtml; + String commentId = opusDetail + .querySelector('.bili-comment-container')! + .className + .split(' ')[1] + .split('-')[2]; + // List imgList = opusDetail.querySelectorAll('bili-album__preview__picture__img'); + return { + 'status': true, + 'avatar': avatar, + 'uname': uname, + 'updateTime': updateTime, + 'content': test + opusContent, + 'commentId': int.parse(commentId) + }; + } catch (err) { + print('err: $err'); + } } // read diff --git a/lib/pages/html/view.dart b/lib/pages/html/view.dart index d5e4556d3..64fabff8e 100644 --- a/lib/pages/html/view.dart +++ b/lib/pages/html/view.dart @@ -139,7 +139,7 @@ class _HtmlRenderPageState extends State IconButton( onPressed: () { Get.toNamed('/webview', parameters: { - 'url': 'https:$url', + 'url': url.startsWith('http') ? url : 'https:$url', 'type': 'url', 'pageTitle': title, }); From 789d95e728d8547a78bf5cc07092d8de2ab350ff Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 16 Oct 2023 23:16:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E9=95=BF=E6=8C=89=E5=80=8D=E9=80=9F?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugin/pl_player/controller.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 78845e602..2c116b164 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -577,7 +577,8 @@ class PlPlayerController { duration: (currentOption.duration / speed) * playbackSpeed); danmakuController!.updateOption(updatedOption); } catch (_) {} - _playbackSpeed.value = speed; + // fix 长按倍速后放开不恢复 + // _playbackSpeed.value = speed; } /// 设置倍速 From 45bd4fc6d5cdbbe0b365356d011f9c9b48eab7f4 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 16 Oct 2023 23:29:37 +0800 Subject: [PATCH 3/4] =?UTF-8?q?v1.0.10=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_log/1.0.10.1016.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 change_log/1.0.10.1016.md diff --git a/change_log/1.0.10.1016.md b/change_log/1.0.10.1016.md new file mode 100644 index 000000000..e0e8672e6 --- /dev/null +++ b/change_log/1.0.10.1016.md @@ -0,0 +1,4 @@ +## 1.0.9 + +### 修复 ++ 长按倍速抬起后未恢复默认倍速 \ No newline at end of file From 41e9cfcbbbaa49d4bc5b92f9fc069f7c5ec45ab7 Mon Sep 17 00:00:00 2001 From: guozhigq Date: Mon, 16 Oct 2023 23:45:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- change_log/1.0.10.1016.md | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/change_log/1.0.10.1016.md b/change_log/1.0.10.1016.md index e0e8672e6..2e3f1fe87 100644 --- a/change_log/1.0.10.1016.md +++ b/change_log/1.0.10.1016.md @@ -1,4 +1,4 @@ -## 1.0.9 +## 1.0.10 ### 修复 + 长按倍速抬起后未恢复默认倍速 \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 4fb8df020..e2f00f2c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: "none" # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.0.9 +version: 1.0.10 environment: sdk: ">=2.19.6 <3.0.0"