summaryrefslogtreecommitdiff
path: root/bilibili/play_url_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'bilibili/play_url_test.go')
-rw-r--r--bilibili/play_url_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/bilibili/play_url_test.go b/bilibili/play_url_test.go
new file mode 100644
index 0000000..7ec17ee
--- /dev/null
+++ b/bilibili/play_url_test.go
@@ -0,0 +1,35 @@
+package bilibili
+
+import (
+ "github.com/keuin/slbr/common"
+ "github.com/keuin/slbr/logging"
+ "log"
+ "testing"
+)
+
+func TestBilibili_GetStreamingInfo(t *testing.T) {
+ // get an online live room for testing
+ liveList, err := common.GetLiveListForGuestUser()
+ if err != nil {
+ t.Fatalf("cannot get live list for testing: %v", err)
+ }
+ lives := liveList.Data.Data
+ if len(lives) <= 0 {
+ t.Fatalf("no live for guest available")
+ }
+ roomId := common.RoomId(lives[0].Roomid)
+
+ logger := log.Default()
+ bi := NewBilibili(logging.NewWrappedLogger(logger, "test-logger"))
+ info, err := bi.GetStreamingInfo(roomId)
+ if err != nil {
+ t.Fatalf("GetStreamingInfo: %v", err)
+ }
+ if info.Code != 0 ||
+ info.Message != "0" ||
+ len(info.Data.URLs) <= 0 ||
+ len(info.Data.AcceptQuality) <= 0 ||
+ len(info.Data.QualityDescription) <= 0 {
+ t.Fatalf("Invalid GetStreamingInfo response: %v", info)
+ }
+}