Skip to content

Commit

Permalink
mod
Browse files Browse the repository at this point in the history
  • Loading branch information
guozhigq committed Dec 8, 2024
1 parent 9666ab7 commit a53429d
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 107 deletions.
33 changes: 33 additions & 0 deletions lib/http/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -562,4 +562,37 @@ class Api {
/// 系统通知标记已读
static const String systemMarkRead =
'${HttpString.messageBaseUrl}/x/sys-msg/update_cursor';

/// 编辑收藏夹
static const String editFavFolder = '/x/v3/fav/folder/edit';

/// 新建收藏夹
static const String addFavFolder = '/x/v3/fav/folder/add';

/// 直播间弹幕信息
static const String getDanmuInfo =
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/getDanmuInfo';

/// 直播间发送弹幕
static const String sendLiveMsg = '${HttpString.liveBaseUrl}/msg/send';

/// 我的关注 - 正在直播
static const String getFollowingLive =
'${HttpString.liveBaseUrl}/xlive/web-ucenter/user/following';

/// 稍后再看&收藏夹视频列表
static const String mediaList = '/x/v2/medialist/resource/list';

/// 用户专栏
static const String opusList = '/x/polymer/web-dynamic/v1/opus/feed/space';

///
static const String getViewInfo = '/x/article/viewinfo';

/// 直播间记录
static const String liveRoomEntry =
'${HttpString.liveBaseUrl}/xlive/web-room/v1/index/roomEntryAction';

/// 删除评论
static const String replyDel = '/x/v2/reply/del';
}
1 change: 1 addition & 0 deletions lib/http/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class HttpString {
static const String liveBaseUrl = 'https://api.live.bilibili.com';
static const String passBaseUrl = 'https://passport.bilibili.com';
static const String messageBaseUrl = 'https://message.bilibili.com';
static const String bangumiBaseUrl = 'https://bili.meark.me';
static const List<int> validateStatusCodes = [
302,
304,
Expand Down
2 changes: 1 addition & 1 deletion lib/http/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class HtmlHttp {
static Future reqReadHtml(id, dynamicType) async {
var response = await Request().get(
"https://www.bilibili.com/$dynamicType/$id/",
extra: {'ua': 'pc', 'opus-goback': '1'},
extra: {'ua': 'pc'},
);
Document rootTree = parse(response.data);
Element body = rootTree.body!;
Expand Down
9 changes: 0 additions & 9 deletions lib/http/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,6 @@ class Request {
if (extra['ua'] != null) {
options.headers = {'user-agent': headerUa(type: extra['ua'])};
}
if (extra['opus-goback'] != null) {
List<Cookie> cookies = await cookieManager.cookieJar
.loadForRequest(Uri.parse(HttpString.baseUrl));
String cookieHeader = cookies
.map((cookie) => '${cookie.name}=${cookie.value}')
.join('; ');
options.headers!['cookie'] =
'$cookieHeader; opus-goback = ${extra['opus-goback']}';
}
}
options.responseType = resType;

Expand Down
14 changes: 14 additions & 0 deletions lib/http/live.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,18 @@ class LiveHttp {
};
}
}

// 直播历史记录
static Future liveRoomEntry({required int roomId}) async {
await Request().post(
Api.liveRoomEntry,
data: {
'room_id': roomId,
'platform': 'pc',
'csrf_token': await Request.getCsrf(),
'csrf': await Request.getCsrf(),
'visit_id': '',
},
);
}
}
40 changes: 0 additions & 40 deletions lib/models/video_detail_res.dart
Original file line number Diff line number Diff line change
Expand Up @@ -703,43 +703,3 @@ class Vip {
status = json['status'];
}
}

class Staff {
Staff({
this.mid,
this.title,
this.name,
this.face,
this.vip,
});

int? mid;
String? title;
String? name;
String? face;
int? status;
Vip? vip;

Staff.fromJson(Map<String, dynamic> json) {
mid = json['mid'];
title = json['title'];
name = json['name'];
face = json['face'];
vip = Vip.fromJson(json['vip']);
}
}

class Vip {
Vip({
this.type,
this.status,
});

int? type;
int? status;

Vip.fromJson(Map<String, dynamic> json) {
type = json['type'];
status = json['status'];
}
}
18 changes: 18 additions & 0 deletions lib/pages/fav_detail/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,22 @@ class FavDetailController extends GetxController {
title.value = res['title'];
print(title);
}

Future toViewPlayAll() async {
final FavDetailItemData firstItem = favList.first;
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
Get.toNamed(
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
arguments: {
'videoItem': firstItem,
'heroTag': heroTag,
'sourceType': 'fav',
'mediaId': favInfo['id'],
'oid': firstItem.id,
'favTitle': favInfo['title'],
'favInfo': favInfo,
'count': favInfo['media_count'],
},
);
}
}
10 changes: 5 additions & 5 deletions lib/pages/video/detail/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -668,11 +668,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
tag: heroTag,
child: Stack(
children: <Widget>[
if (isShowing)
Padding(
padding: EdgeInsets.only(top: 0),
child: videoPlayerPanel,
),
Obx(
() => isShowing.value
? buildVideoPlayerPanel()
: const SizedBox(),
),

/// 关闭自动播放时 手动播放
Obx(
Expand Down
28 changes: 5 additions & 23 deletions lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,7 @@ class PlPlayerController {
}
// 配置Player 音轨、字幕等等
_videoPlayerController = await _createVideoController(
dataSource,
_looping,
enableHA,
width,
height,
seekTo,
);
dataSource, _looping, enableHA, width, height, seekTo);
// 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration;
updateDurationSecond();
Expand Down Expand Up @@ -403,7 +397,7 @@ class PlPlayerController {
bool enableHA,
double? width,
double? height,
Duration? seekTo,
Duration seekTo,
) async {
// 每次配置时先移除监听
removeListeners();
Expand Down Expand Up @@ -491,12 +485,9 @@ class PlPlayerController {
play: false,
);
}
player.open(
Media(
dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders,
start: seekTo ?? Duration.zero,
),
await player.open(
Media(dataSource.videoSource!,
httpHeaders: dataSource.httpHeaders, start: seekTo),
play: false,
);
// 音轨
Expand Down Expand Up @@ -536,15 +527,6 @@ class PlPlayerController {
await setPlaybackSpeed(1.0);
}
}
getVideoFit();
// if (_looping) {
// await setLooping(_looping);
// }

// 自动播放
if (_autoPlay) {
await play(duration: duration);
}
}

List<StreamSubscription> subscriptions = [];
Expand Down
3 changes: 3 additions & 0 deletions lib/router/app_pages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ class Routes {
// 专栏
CustomGetPage(name: '/opus', page: () => const OpusPage()),
CustomGetPage(name: '/read', page: () => const ReadPage()),
// 用户专栏
CustomGetPage(
name: '/memberArticle', page: () => const MemberArticlePage()),
];
}

Expand Down
15 changes: 0 additions & 15 deletions lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,6 @@ class Utils {
}
} catch (_) {}

// 向上查找
if (closestNumber == 0) {
try {
for (int number in numbers) {
int diff = (number - target).abs();

if (diff < minDiff) {
minDiff = diff;
closestNumber = number;
return closestNumber;
}
}
} catch (_) {}
}

// 向上查找
if (closestNumber == 0) {
try {
Expand Down
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.4"
brotli:
dependency: "direct main"
description:
name: brotli
sha256: "7f891558ed779aab2bed874f0a36b8123f9ff3f19cf6efbee89e18ed294945ae"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0"
build:
dependency: transitive
description:
Expand Down
18 changes: 4 additions & 14 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ dependencies:
# 二维码
qr_flutter: ^4.1.0
bottom_sheet: ^4.0.4
web_socket_channel: ^2.4.5
brotli: ^0.6.0
# 文本语法高亮
re_highlight: ^0.0.3

dev_dependencies:
flutter_test:
Expand Down Expand Up @@ -180,20 +184,6 @@ dependency_overrides:
url: https://github.com/media-kit/media-kit
path: libs/universal/media_kit_libs_video

dependency_overrides:
media_kit:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit
media_kit_video:
git:
url: https://github.com/media-kit/media-kit.git
path: media_kit_video
media_kit_libs_video:
git:
url: https://github.com/media-kit/media-kit.git
path: libs/universal/media_kit_libs_video

flutter_launcher_icons:
android: true
ios: true
Expand Down

0 comments on commit a53429d

Please sign in to comment.