@@ -6,10 +6,13 @@ import (
66 "errors"
77 "fmt"
88
9+ "github.com/go-olive/olive/src/config"
910 "github.com/go-olive/olive/src/dispatcher"
1011 "github.com/go-olive/olive/src/enum"
1112 "github.com/go-olive/olive/src/parser"
1213 "github.com/go-olive/olive/src/platform"
14+
15+ "github.com/go-olive/tv"
1316)
1417
1518type ID string
@@ -19,40 +22,46 @@ type Show interface {
1922 GetPlatform () string
2023 GetRoomID () string
2124 GetStreamerName () string
22- StreamURL () (string , error )
23- Snapshot () (* platform.Snapshot , error )
2425
2526 AddMonitor () error
2627 RemoveMonitor () error
2728 AddRecorder () error
2829 RemoveRecorder () error
2930
3031 NewParser () (parser.Parser , error )
32+
33+ tv.ITv
3134}
3235
3336type show struct {
34- ID ID
35- Platform string
36- RoomID string
37- StreamerName string
37+ ID ID
38+ Platform string
39+ RoomID string
40+ Streamer string
3841 enum.ShowTaskStatusID
3942 stop chan struct {}
4043 ctrl platform.PlatformCtrl
44+
45+ * tv.Tv
4146}
4247
4348func NewShow (platformType , roomID , streamerName string ) (Show , error ) {
44- pc , valid := platform .SharedManager .Ctrl (platformType )
45- if ! valid {
46- return nil , errors .New ("platform not exist" )
49+ var parms * tv.Parms
50+ if platformType == "douyin" {
51+ parms .Cookie = config .APP .PlatformConfig .DouyinCookie
52+ }
53+ tv , err := tv .Snap (tv .NewTv (platformType , roomID ), parms )
54+ if err != nil {
55+ return nil , err
4756 }
4857
4958 s := & show {
50- Platform : platformType ,
51- RoomID : roomID ,
52- StreamerName : streamerName ,
53- stop : make (chan struct {}),
59+ Platform : platformType ,
60+ RoomID : roomID ,
61+ Streamer : streamerName ,
62+ stop : make (chan struct {}),
5463
55- ctrl : pc ,
64+ Tv : tv ,
5665 }
5766 s .ID = s .genID ()
5867 return s , nil
@@ -67,7 +76,7 @@ func (s *show) GetRoomID() string {
6776}
6877
6978func (s * show ) GetStreamerName () string {
70- return s .StreamerName
79+ return s .Streamer
7180}
7281
7382func (s * show ) GetPlatform () string {
@@ -81,16 +90,12 @@ func (s *show) genID() ID {
8190 return ID (hex .EncodeToString (h .Sum (nil )))
8291}
8392
84- func (s * show ) StreamURL () (string , error ) {
85- return s .ctrl .StreamURL (s .ctrl , s .RoomID )
86- }
87-
88- func (s * show ) Snapshot () (* platform.Snapshot , error ) {
89- return s .ctrl .Snapshot (s .ctrl , s .RoomID )
90- }
91-
9293func (s * show ) NewParser () (parser.Parser , error ) {
93- v , ok := parser .SharedManager .Parser (s .ctrl .ParserType ())
94+ typ := "flv"
95+ if s .SiteID == "youtube" {
96+ typ = "streamlink"
97+ }
98+ v , ok := parser .SharedManager .Parser (typ )
9499 if ! ok {
95100 return nil , errors .New ("parser not exist" )
96101 }
0 commit comments