Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

移除个人依赖 #81

Merged
merged 7 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ builds:
- linux
goarch:
- amd64
# - arm64
# goarm:
# - 7
goarm:
- 7
archives:
- replacements:
darwin: Macos
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@
{
"EnableProxy": false, // 是否启用代理
"Proxy": "127.0.0.1:10800", //代理地址,应为socks5代理
"RedisHost": "127.0.0.1:6379", //Redis数据库地址 用于启用上传功能,不使用无需配置
"CriticalCheckSec": 30, // 检测间隔
"NormalCheckSec": 30, // 检测间隔
"ExpressPort": 3000, // 配置同传获取服务器的端口,详细见后文
"DownloadQuality": "best", // 配置下载画质 best为最佳画质 建议不调整 可选: best 1080p60 720p
"DownloadDir": "/home/ubuntu/Matsuri", // 下载目录 注意后无斜杠
"EnableTS2MP4": true, // 是否启用ts转码mp4(关闭后断流文件不会合并
Expand Down
28 changes: 3 additions & 25 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/fsnotify/fsnotify"
"github.com/mitchellh/mapstructure"
"github.com/rclone/rclone/fs"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"log"
Expand All @@ -23,7 +22,6 @@ type UsersConfig struct {
DownloadDir string
NeedDownload bool
TransBiliId string
UserHeaders map[string]string
ExtraConfig map[string]interface{}
}
type ModuleConfig struct {
Expand All @@ -46,13 +44,9 @@ type MainConfig struct {
DownloadDir []string
UploadDir string
Module []ModuleConfig
//PprofHost string
//OutboundAddrs []string
DomainRewrite map[string]([]string)
//RedisHost string
//ExpressPort string
EnableTS2MP4 bool
ExtraConfig map[string]interface{}
ExpressPort string
EnableTS2MP4 bool
ExtraConfig map[string]interface{}
}

var v *viper.Viper
Expand Down Expand Up @@ -123,10 +117,6 @@ func ReloadConfig() (bool, error) {
if err != nil {
fmt.Printf("Struct config error: %s", err)
}
/*modules := viper.AllSettings()["module"].([]interface{})
for i := 0; i < len(modules); i++ {
Config.Module[i].ExtraConfig = modules[i].(map[string]interface{})
}*/
Config = config
UpdateLogLevel()
return true, nil
Expand All @@ -147,18 +137,6 @@ func LevelStrParse(levelStr string) (level logrus.Level) {
}

func UpdateLogLevel() {
fs.Config.LogLevel = fs.LogLevelInfo
if Config.RLogLevel == "debug" {
fs.Config.LogLevel = fs.LogLevelDebug
} else if Config.RLogLevel == "info" {
fs.Config.LogLevel = fs.LogLevelInfo
} else if Config.RLogLevel == "warn" {
fs.Config.LogLevel = fs.LogLevelWarning
} else if Config.RLogLevel == "error" {
fs.Config.LogLevel = fs.LogLevelError
}
logrus.Printf("Set rclone logrus level to %s", fs.Config.LogLevel)

if ConsoleHook != nil {
level := LevelStrParse(Config.LogLevel)
ConsoleHook.LogLevel = level
Expand Down
17 changes: 0 additions & 17 deletions config/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"fmt"
"github.com/fzxiao233/Vtb_Record/utils"
"github.com/knq/sdhook"
"github.com/orandin/lumberjackrus"
"github.com/sirupsen/logrus"
"io"
Expand Down Expand Up @@ -45,7 +44,6 @@ func (hook *WriterHook) Levels() []logrus.Level {

var ConsoleHook *WriterHook
var FileHook *lumberjackrus.Hook
var GoogleHook *sdhook.StackdriverHook

// Can't be func init as we need the parsed config
func InitLog() {
Expand Down Expand Up @@ -93,20 +91,5 @@ func InitLog() {

logrus.AddHook(FileHook)

GoogleHook, err = sdhook.New(
sdhook.GoogleLoggingAgent(),
sdhook.LogName(Config.LogFile),
sdhook.Levels(logrus.AllLevels[:logrus.DebugLevel+1]...),
)
if err != nil {
logrus.WithField("prof", true).Warnf("Failed to initialize the sdhook: %v", err)
} else {
logrus.AddHook(GoogleHook)
}

//fs.LogPrint = func(level fs.LogLevel, text string) {
// logrus.WithField("src", "rclone").Infof(fmt.Sprintf("%-6s: %s", level, text))
//}

UpdateLogLevel()
}
63 changes: 14 additions & 49 deletions config/prof.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package config

import (
log "github.com/sirupsen/logrus"
"net/http"
"runtime"
"time"
)
Expand All @@ -23,38 +22,7 @@ func PrintMemUsage() {
m.NumGC)
}

var PprofServer *http.Server

func InitProfiling() {
//go func() {
// logger := log.WithField("prof", true)
// ticker := time.NewTicker(time.Minute * 1)
// for {
// //go http.ListenAndServe("0.0.0.0:49314", nil)
// if PprofServer == nil || PprofServer.Addr != Config.PprofHost {
// logger.Warnf("Starting pprof server")
// if PprofServer != nil {
// go PprofServer.Shutdown(context.Background())
// }
// //PprofServer = &http.Server{Addr: config.Config.PprofHost, Handler: nil}
// listener, err := greuse.Listen("tcp", Config.PprofHost)
// if listener == nil {
// logger.Warnf("Error creating reusable listener, creating a normal one instead!")
// listener, err = net.Listen("tcp", Config.PprofHost)
// }
// if err != nil {
// logger.WithError(err).Warnf("Failed to reuse-listen addr")
// }
// PprofServer = &http.Server{
// Addr: Config.PprofHost,
// }
// //go PprofServer.ListenAndServe()
// go PprofServer.Serve(listener)
// }
// <-ticker.C
// }
//}()

go func() {
ticker := time.NewTicker(time.Minute * 1)
for {
Expand All @@ -63,21 +31,18 @@ func InitProfiling() {
}
}()

//go func() {
// ticker := time.NewTicker(time.Millisecond * 3000)
// for {
// //start := time.Now()
// runtime.GC()
// //log.WithField("prof", true).Debugf("G C & scvg use %s", time.Now().Sub(start))
// <-ticker.C
// }
//}()

//ticker := time.NewTicker(time.Second * 3)
//for {
// start := time.Now()
// debug.FreeOSMemory()
// log.WithField("prof", true).Debugf("scvg use %s", time.Now().Sub(start))
// <-ticker.C
//}
go func() {
ticker := time.NewTicker(time.Millisecond * 3000)
for {
runtime.GC()
<-ticker.C
}
}()
ticker := time.NewTicker(time.Second * 3)
for {
start := time.Now()
debug.FreeOSMemory()
log.WithField("prof", true).Debugf("scvg use %s", time.Now().Sub(start))
<-ticker.C
}
}
69 changes: 42 additions & 27 deletions config_example.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,74 @@
{
"LogFile": "Record.log",
"LogFileSize": 20,
"LogLevel": "debug",
"RLogLevel": "debug", // rclone's log level
"CriticalCheckSec": 30, // in every hour such as 19:55 ~ 20:05, 20:25 ~ 20:35, we increase the speed of checking
"NormalCheckSec": 60,
"NormalCheckSec": 30,
"CriticalCheckSec": 25,
"DownloadQuality": "best",
"DownloadDir": ["GDrive-VTB1:/vtest"], // DownloadDir stores the download result temporarily, before they were moved into uploaddir, so you can specify multiple. Beware that streamlink provider does not support rclone backend
"UploadDir": "GDrive-VTB1:/vtest", // UploadDir stores the final recording result
"EnableTS2MP4": false, // if you want to use rclone's cloud backend, then you definitely don't want to auto merge.
"DownloadDir": "./save",
"EnableTS2MP4": true,
"SRT": false,
"VTT": true,
"Module": [
{
"Name": "Youtube",
"Enable": false,
"EnableProxy": true,
"Proxy": "127.0.0.1:10801",
"DownloadProvider": "streamlink",
"Users": [
{
"TargetId": "UCQ0UDLQCjY0rmuxCDE38FGg",
"Name": "natsuiromatsuri",
"NeedDownload": true,
"StreamLinkArgs": ["--http-cookies", "YOUR_YOUTUBE_COOKIE"]
"NeedDownload": false,
"CQConfig": {
"NeedCQBot": true,
"CQHost": "127.0.0.1:5700",
"CQToken": "",
"QQGroupID": [
""
]
}
}
],
"HttpHeaders": {
"Cookie": "YOUTUBE_COOKIE_FOR_MONITOR"
}
]
},
{
"Name": "Twitcasting",
"Enable": false,
"DownloadProvider": "streamlink",
"Users": [
{
"TargetId": "natsuiromatsuri",
"Name": "natsuiromatsuri",
"NeedDownload": true
"NeedDownload": false,
"CQConfig": {
"NeedCQBot": true,
"CQHost": "127.0.0.1:5700",
"CQToken": "",
"QQGroupID": [
""
]
}
}
]
},
{
"Name": "Bilibili",
"Enable": true,
"DownloadProvider": "go", // go provider uses much less memory and cpu time than streamlink + rclone mount, which is much more suitable for recoding in large scale
"UseFollowPolling": true, // use this when you have hundreds of rooms to record, which will make us enable batch request, so that we won't be ratelimited
"UseFollowPolling": true,
"DownloadProvider": "streamlink",
"Users": [
{
"TargetId": "4634167",
"Name": "tamaki",
"TargetId": "",
"Name": "",
"NeedDownload": true,
"StreamLinkArgs": ["--bilibili-apihost", "http://direct.misty.moe:16384"], // main api host to retrive video, can be changed to avoid rate limiting
"AltStreamLinkArgs": ["--bilibili-apihost", "http://7s6dgkcy7btyx.cfc-execute.bj.baidubce.com"], // change api host to resolve to another cdn
"AltProxy": "127.0.0.1:10396" // if direct downloading failed (e.g. rate limited), try this proxy
"CQConfig": {
"NeedCQBot": false,
"CQHost": "",
"CQToken": "",
"QQGroupID": [
""
]
}
}
],
"HttpHeaders": {
"Cookie": "BILI_COOKIE_FOR_MONITOR"
}
]
}
]
}
8 changes: 3 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ go 1.13
require (
github.com/bitly/go-simplejson v0.5.0
github.com/etherlabsio/go-m3u8 v0.1.2
github.com/fsnotify/fsnotify v1.4.7
github.com/fsnotify/fsnotify v1.4.9
github.com/fzxiao233/Go-Emoji-Utils v0.0.0-20200305114615-005e99b02c2f
github.com/go-redis/redis v6.15.8+incompatible
github.com/go-redis/redis/v8 v8.7.1
github.com/gogf/greuse v1.1.0
github.com/hashicorp/golang-lru v0.5.4
github.com/knq/sdhook v0.0.0-20190801142816-0b7fa827d09a
github.com/mitchellh/mapstructure v1.1.2
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/orandin/lumberjackrus v1.0.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/rclone/rclone v1.52.2
Expand All @@ -23,8 +22,7 @@ require (
github.com/tidwall/pretty v1.0.1 // indirect
github.com/valyala/bytebufferpool v1.0.0
go.uber.org/ratelimit v0.1.0
golang.org/x/crypto v0.0.0-20200423211502-4bdfaf469ed5 // indirect
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down