Skip to content

Commit

Permalink
Merge pull request #560 from xiaoyaocz/dev
Browse files Browse the repository at this point in the history
Release 1.7.5 / TV 1.2.2
  • Loading branch information
xiaoyaocz authored Dec 2, 2024
2 parents 4eb1846 + 9eb1461 commit 97f1d45
Show file tree
Hide file tree
Showing 40 changed files with 2,958 additions and 165 deletions.
6 changes: 3 additions & 3 deletions assets/app_version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.7.4",
"version_num": 10704,
"version_desc": "- 修复虎牙一起看播放中断 #543\n- 播放中断后取消保持亮屏 #541\n- 强制使用HTTPS链接 #538\n- Windows字体使用微软雅黑 #535",
"version": "1.7.5",
"version_num": 10705,
"version_desc": "- 修复虎牙一起看播放中断 #543",
"prerelease":false,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
}
4 changes: 2 additions & 2 deletions assets/tv_app_version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.2.1",
"version_num": 10201,
"version": "1.2.2",
"version_num": 10202,
"version_desc": "- 修复虎牙播放失败 #557",
"prerelease":true,
"download_url": "https://github.com/xiaoyaocz/dart_simple_live/releases"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,8 @@ class LiveRoomController extends PlayerController with WidgetsBindingObserver {
};
} else if (site.id == Constant.kHuya) {
headers = {
"referer": "https://m.huya.com",
"user-agent":
"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/130.0.0.0"
//"referer": "https://m.huya.com",
"user-agent": "HYSDK(Windows, 20000308)"
};
}

Expand Down
2 changes: 1 addition & 1 deletion simple_live_app/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: simple_live_app
version: 1.7.4+10704
version: 1.7.5+10705
publish_to: none
description: "Simple Live APP"
environment:
Expand Down
Binary file added simple_live_core/demo/getCdnTokenInfoReq.bin
Binary file not shown.
Binary file added simple_live_core/demo/getCdnTokenInfoResp.bin
Binary file not shown.
129 changes: 93 additions & 36 deletions simple_live_core/example/simple_live_core_example.dart
Original file line number Diff line number Diff line change
@@ -1,39 +1,96 @@
import 'package:simple_live_core/simple_live_core.dart';
import 'dart:io';

import 'package:dio/dio.dart';
import 'package:simple_live_core/src/model/tars/get_cdn_token_req.dart';
import 'package:simple_live_core/src/model/tars/get_cdn_token_resp.dart';
import 'package:tars_dart/tars/net/base_tars_http.dart';
import 'package:tars_dart/tars/tup/uni_packet.dart';

void main() async {
CoreLog.enableLog = true;
CoreLog.requestLogType = RequestLogType.short;
LiveSite site = BiliBiliSite();
var danmaku = site.getDanmaku();
danmaku.onMessage = (event) {
if (event.type == LiveMessageType.chat) {
print("[${event.color}]${event.userName}:${event.message}");
} else if (event.type == LiveMessageType.online) {
print("-----人气:${event.data}-----");
} else if (event.type == LiveMessageType.superChat) {
var scMessage = event.data as LiveSuperChatMessage;
print("[SC]${scMessage.userName}:${scMessage.message}");
}
};
danmaku.onClose = (event) {
print(event);
};

//var search = await site.searchRooms("东方");

//var categores = await site.getCategores();
//print(categores.length);
var detail = await site.getRoomDetail(roomId: '7734200');
// var playQualites = await site.getPlayQualites(detail: detail);
// print(playQualites);
// var playUrls =
// await site.getPlayUrls(detail: detail, quality: playQualites.first);
// for (var element in playUrls) {
// print(element);
// }
//print(detail);

danmaku.start(detail.danmakuData);

await Future.wait({});
// CoreLog.enableLog = true;
// CoreLog.requestLogType = RequestLogType.short;
// LiveSite site = BiliBiliSite();
// var danmaku = site.getDanmaku();
// danmaku.onMessage = (event) {
// if (event.type == LiveMessageType.chat) {
// print("[${event.color}]${event.userName}:${event.message}");
// } else if (event.type == LiveMessageType.online) {
// print("-----人气:${event.data}-----");
// } else if (event.type == LiveMessageType.superChat) {
// var scMessage = event.data as LiveSuperChatMessage;
// print("[SC]${scMessage.userName}:${scMessage.message}");
// }
// };
// danmaku.onClose = (event) {
// print(event);
// };

// //var search = await site.searchRooms("东方");

// //var categores = await site.getCategores();
// //print(categores.length);
// var detail = await site.getRoomDetail(roomId: '7734200');
// // var playQualites = await site.getPlayQualites(detail: detail);
// // print(playQualites);
// // var playUrls =
// // await site.getPlayUrls(detail: detail, quality: playQualites.first);
// // for (var element in playUrls) {
// // print(element);
// // }
// //print(detail);

// danmaku.start(detail.danmakuData);

// await Future.wait({});
sendReq();
}

void testHuyaReq() async {
var reqBytes = await File('demo/getCdnTokenInfoReq.bin').readAsBytes();
// RequestPacket req = RequestPacket();
// req.readFrom(TarsInputStream(reqBytes));
// print(req.iVersion);

UniPacket uniPacket = UniPacket();
//uniPacket.readFrom(TarsInputStream(reqBytes));
uniPacket.decode(reqBytes);
var value = uniPacket.get<GetCdnTokenReq>('tReq', GetCdnTokenReq());
// GetCdnTokenReq reqData = GetCdnTokenReq();
// reqData.readFrom(TarsInputStream(req.sBuffer));
print(value.toString());
}

void sendReq() async {
var req = GetCdnTokenReq();
req.cdnType = "HW";
req.streamName =
"1199637826638-1199637826638-5763635889762729984-2399275776732-10057-A-0-1";

BaseTarsHttp http = BaseTarsHttp("http://wup.huya.com", "liveui");

var data = await http.tupRequest("getCdnTokenInfo", req, GetCdnTokenResp());

var url =
'http://hw.flv.huya.com/src/${data.streamName}.flv?${data.flvAntiCode}&codec=264';
print(url);
await Dio().download(
url,
'live-stream.flv',
options: Options(
responseType: ResponseType.bytes,
headers: {"user-agent": "HYSDK(Windows, 20000308)"},
),
onReceiveProgress: (count, total) {
var downBytes = count / 1024 / 1024;
print('downloading: $downBytes MB');
},
);
}

void testHuyaResp() async {
var respBytes = await File('demo/getCdnTokenInfoResp.bin').readAsBytes();
UniPacket uniPacket = UniPacket();
uniPacket.decode(respBytes);
var value = uniPacket.get<GetCdnTokenResp>('tRsp', GetCdnTokenResp());
print(value.toString());
}
1 change: 0 additions & 1 deletion simple_live_core/lib/src/common/core_log.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class CoreLog {
lineLength: 120,
colors: true,
printEmojis: true,
printTime: false,
),
);

Expand Down
90 changes: 3 additions & 87 deletions simple_live_core/lib/src/danmaku/huya_danmaku.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// ignore_for_file: no_leading_underscores_for_local_identifiers

import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';

import 'package:simple_live_core/simple_live_core.dart';
import 'package:simple_live_core/src/common/web_socket_util.dart';
import 'package:dart_tars_protocol/tars_input_stream.dart';
import 'package:dart_tars_protocol/tars_output_stream.dart';
import 'package:dart_tars_protocol/tars_struct.dart';
import 'package:simple_live_core/src/model/tars/huya_danmaku.dart';
import 'package:tars_dart/tars/codec/tars_input_stream.dart';
import 'package:tars_dart/tars/codec/tars_output_stream.dart';

class HuyaDanmakuArgs {
final int ayyuid;
Expand Down Expand Up @@ -160,85 +158,3 @@ class HuyaDanmaku implements LiveDanmaku {
}
}
}

class HYPushMessage extends TarsStruct {
int pushType = 0;
int uri = 0;
List<int> msg = <int>[];
int protocolType = 0;

@override
void readFrom(TarsInputStream _is) {
pushType = _is.read(pushType, 0, false);
uri = _is.read(uri, 1, false);
msg = _is.readBytes(2, false);
protocolType = _is.read(protocolType, 3, false);
}

@override
void display(StringBuffer sb, int level) {}

@override
void writeTo(TarsOutputStream _os) {}
}

class HYSender extends TarsStruct {
int uid = 0;
int lMid = 0;
String nickName = "";
int gender = 0;

@override
void readFrom(TarsInputStream _is) {
uid = _is.read(uid, 0, false);
lMid = _is.read(lMid, 0, false);
nickName = _is.read(nickName, 2, false);
gender = _is.read(gender, 3, false);
}

@override
void display(StringBuffer sb, int level) {}

@override
void writeTo(TarsOutputStream _os) {}
}

class HYMessage extends TarsStruct {
HYSender userInfo = HYSender();
String content = "";
HYBulletFormat bulletFormat = HYBulletFormat();

@override
void readFrom(TarsInputStream _is) {
userInfo = _is.readTarsStruct(userInfo, 0, false) as HYSender;
content = _is.read(content, 3, false);
bulletFormat = _is.readTarsStruct(bulletFormat, 6, false) as HYBulletFormat;
}

@override
void display(StringBuffer sb, int level) {}

@override
void writeTo(TarsOutputStream _os) {}
}

class HYBulletFormat extends TarsStruct {
int fontColor = 0;
int fontSize = 4;
int textSpeed = 0;
int transitionType = 1;

@override
void readFrom(TarsInputStream _is) {
fontColor = _is.read(fontColor, 0, false);
fontSize = _is.read(fontSize, 1, false);
textSpeed = _is.read(textSpeed, 2, false);
transitionType = _is.read(transitionType, 3, false);
}

@override
void display(StringBuffer sb, int level) {}

@override
void writeTo(TarsOutputStream _os) {}
}
Loading

0 comments on commit 97f1d45

Please sign in to comment.