-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big refactor, make everything organized
Plugins were separated to manager
- Loading branch information
Showing
29 changed files
with
559 additions
and
301 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ builds: | |
- linux | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- arm64` | ||
goarm: | ||
- 7 | ||
archives: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package interfaces | ||
|
||
import ( | ||
"github.com/fzxiao233/Vtb_Record/utils" | ||
) | ||
|
||
type VideoInfo struct { | ||
Title string | ||
Date string | ||
Target string | ||
Provider string | ||
FileName string | ||
FilePath string | ||
StreamingLink string | ||
UsersConfig utils.UsersConfig | ||
TransRecordPath string | ||
} | ||
|
||
type LiveStatus struct { | ||
IsLive bool | ||
Video *VideoInfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package monitor | ||
|
||
import ( | ||
"github.com/fzxiao233/Vtb_Record/plugins/structUtils" | ||
"github.com/fzxiao233/Vtb_Record/live/interfaces" | ||
"github.com/fzxiao233/Vtb_Record/utils" | ||
) | ||
|
||
type Mock struct { | ||
Video *structUtils.VideoInfo | ||
Video *interfaces.VideoInfo | ||
IsLive bool | ||
} | ||
|
||
func (m *Mock) CheckLive(usersConfig utils.UsersConfig) bool { | ||
return m.IsLive | ||
} | ||
func (m *Mock) CreateVideo(usersConfig utils.UsersConfig) *structUtils.VideoInfo { | ||
func (m *Mock) CreateVideo(usersConfig utils.UsersConfig) *interfaces.VideoInfo { | ||
return m.Video | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package monitor | ||
|
||
import ( | ||
. "github.com/fzxiao233/Vtb_Record/live/interfaces" | ||
"github.com/fzxiao233/Vtb_Record/utils" | ||
"log" | ||
"net/http" | ||
"net/url" | ||
"time" | ||
) | ||
|
||
type MonitorCtx struct { | ||
Client *http.Client | ||
ExtraModConfig map[string]interface{} | ||
} | ||
|
||
func (c *MonitorCtx) HttpGet(url string, header map[string]string) ([]byte, error) { | ||
return utils.HttpGet(c.Client, url, header) | ||
} | ||
|
||
func (c *MonitorCtx) GetProxy() (string, bool) { | ||
enableProxy, ok1 := c.ExtraModConfig["EnableProxy"] | ||
proxy, ok2 := c.ExtraModConfig["Proxy"] | ||
if ok1 && ok2 && enableProxy == true { | ||
return proxy.(string), true | ||
} else { | ||
return "", false | ||
} | ||
} | ||
|
||
func createMonitorCtx(module utils.ModuleConfig) MonitorCtx { | ||
ctx := MonitorCtx{ExtraModConfig: module.ExtraConfig} | ||
var client *http.Client | ||
proxy, ok := ctx.GetProxy() | ||
if ok && proxy != "" { | ||
proxyUrl, _ := url.Parse("socks5://" + proxy) | ||
transport := &http.Transport{ | ||
Proxy: http.ProxyURL(proxyUrl), | ||
} | ||
|
||
//adding the Transport object to the http Client | ||
client = &http.Client{ | ||
Transport: transport, | ||
Timeout: 60 * time.Second, | ||
} | ||
} else { | ||
client = http.DefaultClient | ||
} | ||
ctx.Client = client | ||
return ctx | ||
} | ||
|
||
type BaseMonitor struct { | ||
ctx MonitorCtx | ||
} | ||
|
||
func (b *BaseMonitor) CreateVideo(usersConfig utils.UsersConfig) *VideoInfo { | ||
return nil | ||
} | ||
func (b *BaseMonitor) CheckLive(usersConfig utils.UsersConfig) bool { | ||
return false | ||
} | ||
|
||
func (b *BaseMonitor) GetCtx() *MonitorCtx { | ||
return &b.ctx | ||
} | ||
|
||
type VideoMonitor interface { | ||
CheckLive(usersConfig utils.UsersConfig) bool | ||
CreateVideo(usersConfig utils.UsersConfig) *VideoInfo | ||
GetCtx() *MonitorCtx | ||
} | ||
|
||
type LiveTrace func(monitor VideoMonitor, usersConfig utils.UsersConfig) *LiveStatus | ||
|
||
func CreateVideoMonitor(module utils.ModuleConfig) VideoMonitor { | ||
var monitor VideoMonitor | ||
//var monitor *BaseMonitor | ||
ctx := createMonitorCtx(module) | ||
switch module.Name { | ||
case "Youtube": | ||
monitor = &Youtube{BaseMonitor: BaseMonitor{ctx}} | ||
case "Twitcasting": | ||
monitor = &Twitcasting{BaseMonitor: BaseMonitor{ctx}} | ||
case "Bilibili": | ||
monitor = &Bilibili{BaseMonitor: BaseMonitor{ctx}} | ||
default: | ||
return nil | ||
} | ||
return monitor | ||
} | ||
|
||
func NoLiving(Provide string, Name string) { | ||
log.Printf("%s|%s|is not living\n", Provide, Name) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.