Skip to content

Commit

Permalink
Merge pull request #47 from fzxiao233/feature
Browse files Browse the repository at this point in the history
[feature]添加ts2MP4开关
  • Loading branch information
AlotOfBlahaj committed Mar 12, 2020
2 parents ad73d3a + 2ff95d4 commit 696f310
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"ExpressPort": 3000, // 配置同传获取服务器的端口,详细见后文
"DownloadQuality": "best", // 配置下载画质 best为最佳画质 建议不调整 可选: best 1080p60 720p
"DownloadDir": "/home/ubuntu/Matsuri", // 下载目录 注意后无斜杠
"EnableTS2MP4": true, // 是否启用ts转码mp4(关闭后断流文件不会合并
"Module": [
{
"Name": "Youtube", // 模块名,以下类推
Expand Down
23 changes: 1 addition & 22 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"ExpressPort": 3000,
"DownloadQuality": "best",
"DownloadDir": "",
"EnableTS2MP4": true,
"Module": [
{
"Name": "Youtube",
Expand All @@ -30,16 +31,6 @@
}
]
},
{
"Name": "Mirrativ",
"Enable": false,
"Users": [
{
"TargetId": "3264432",
"Name": "natsuiromatsuri"
}
]
},
{
"Name": "Bilibili",
"Enable": true,
Expand All @@ -50,18 +41,6 @@
"NeedDownload": true
}
]
},
{
"Name": "BilibiliArticle",
"Enable": false,
"Users": [
{
"TargetId": "420711844"
},
{
"TargetId": "418124907"
}
]
}
]
}
19 changes: 19 additions & 0 deletions plugins/monitor/twitch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package monitor

import "github.com/fzxiao233/Vtb_Record/utils"

type Twitch struct {
APIUrl string
}

func (t Twitch) getLiveStatus() error {
_, err := utils.HttpGet(t.APIUrl, map[string]string{})
if err != nil {
return err
}
return nil
}

func (t Twitch) CheckLive(userConfig utils.UsersConfig) {
t.APIUrl = "https://api.twitch.tv/helix/streams?user_login=" + userConfig.TargetId
}
10 changes: 6 additions & 4 deletions plugins/videoProcesser.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ func (p *ProcessVideo) startDownloadVideo(ch chan string) {
p.videoPathList = append(p.videoPathList, aFilePath)
if p.isNewLive() {
videoName := p.liveStatus.video.Title + ".ts"
if len(p.videoPathList) > 1 {
videoName = p.videoPathList.mergeVideo(p.liveStatus.video.Title, p.liveStatus.video.UsersConfig.DownloadDir)
} else {
videoName = ts2mp4(aFilePath, p.liveStatus.video.UsersConfig.DownloadDir, p.liveStatus.video.Title)
if utils.Config.EnableTS2MP4 {
if len(p.videoPathList) > 1 {
videoName = p.videoPathList.mergeVideo(p.liveStatus.video.Title, p.liveStatus.video.UsersConfig.DownloadDir)
} else {
videoName = ts2mp4(aFilePath, p.liveStatus.video.UsersConfig.DownloadDir, p.liveStatus.video.Title)
}
}
if videoName == "" {
return
Expand Down
1 change: 1 addition & 0 deletions utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type MainConfig struct {
Module []ModuleConfig
RedisHost string
ExpressPort string
EnableTS2MP4 bool
}

func init() {
Expand Down

0 comments on commit 696f310

Please sign in to comment.