Skip to content

Commit

Permalink
修复虎牙直播状态错误 #410
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyaocz committed May 30, 2024
1 parent eda8a79 commit a7b0004
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
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.5.4+10504
version: 1.5.5+10505
publish_to: none
description: "Simple Live APP"
environment:
Expand Down
13 changes: 10 additions & 3 deletions simple_live_core/lib/src/huya_site.dart
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,18 @@ class HuyaSite implements LiveSite {
.getText("https://m.huya.com/$roomId", queryParameters: {}, header: {
"user-agent": kUserAgent,
});
var text = RegExp(r"window\.HNF_GLOBAL_INIT.=.\{(.*?)\}.</script>",
var text = RegExp(
r"window\.HNF_GLOBAL_INIT.=.\{[\s\S]*?\}[\s\S]*?</script>",
multiLine: false)
.firstMatch(resultText)
?.group(1);
var jsonObj = json.decode("{$text}");
?.group(0);
var jsonText = text!
.replaceAll(RegExp(r"window\.HNF_GLOBAL_INIT.=."), '')
.replaceAll("</script>", "")
.replaceAllMapped(RegExp(r'function.*?\(.*?\).\{[\s\S]*?\}'), (match) {
return '""';
});
var jsonObj = json.decode(jsonText);
return jsonObj["roomInfo"]["eLiveStatus"] == 2;
}

Expand Down
2 changes: 1 addition & 1 deletion simple_live_tv_app/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: simple_live_tv_app
description: A new Flutter project.
publish_to: 'none'
version: 1.0.4+10004
version: 1.0.5+10005

environment:
sdk: '>=3.1.2 <4.0.0'
Expand Down

0 comments on commit a7b0004

Please sign in to comment.