Skip to content

Commit

Permalink
douyin: update model, fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
luxcgo committed Aug 12, 2022
1 parent 9d395d3 commit 6781dc5
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 349 deletions.
6 changes: 3 additions & 3 deletions douyin.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ func (this *douyin) set(tv *Tv) error {
}

// 抖音 status == 2 代表是开播的状态
if autoGenerated.InitialState.RoomStore.RoomInfo.Room.Status != 2 {
if autoGenerated.App.InitialState.RoomStore.RoomInfo.Room.Status != 2 {
return nil
}

streamDataStr := autoGenerated.InitialState.RoomStore.RoomInfo.Room.StreamURL.LiveCoreSdkData.PullData.StreamData
streamDataStr := autoGenerated.App.InitialState.RoomStore.RoomInfo.Room.StreamURL.LiveCoreSdkData.PullData.StreamData
var streamData model.DouyinStreamData
err = jsoniter.UnmarshalFromString(streamDataStr, &streamData)
if err != nil {
Expand All @@ -86,7 +86,7 @@ func (this *douyin) set(tv *Tv) error {
tv.streamUrl = streamData.Data.Origin.Main.Flv
tv.roomOn = true

tv.roomName = autoGenerated.InitialState.RoomStore.RoomInfo.Room.Title
tv.roomName = autoGenerated.App.InitialState.RoomStore.RoomInfo.Room.Title

return nil
}
19 changes: 19 additions & 0 deletions douyin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package tv_test

import (
"testing"

"github.com/go-olive/tv"
)

func TestDouyin_Snap(t *testing.T) {
u := "https://live.douyin.com/278246244716"
cookie := "__ac_nonce=062f60f640020c76e5b7c; __ac_signature=_02B4Z6wo00f011BxI-gAAIDAxKd45w5q9dNQUSdAALb1WEJMf.7Ma1NuqG0oiO7cYko5mx60CrOZ7DEMeiImZWCkLuxGYUV7nL8NBVxgyWeCnQdWfhttJNV21omp7bThIi8SVu-58ihu3EiU32;"
dy, err := tv.NewWithUrl(u, tv.SetCookie(cookie))
if err != nil {
println(err.Error())
return
}
dy.Snap()
t.Log(dy)
}
18 changes: 18 additions & 0 deletions huya_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package tv_test

import (
"testing"

"github.com/go-olive/tv"
)

func TestHuya_Snap(t *testing.T) {
u := "https://www.huya.com/520588"
huya, err := tv.NewWithUrl(u)
if err != nil {
println(err.Error())
return
}
huya.Snap()
t.Log(huya)
}
Loading

0 comments on commit 6781dc5

Please sign in to comment.