重构完成
This commit is contained in:
@@ -11,10 +11,10 @@ import (
|
||||
)
|
||||
|
||||
// sstore 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
|
||||
var sstore *intimate.StoreSource = intimate.NewStoreSource(string(intimate.STNimo))
|
||||
// var sstore *intimate.StoreSource = intimate.NewStoreSource(string(intimate.STNimo))
|
||||
|
||||
// estore 解析存储连接实例
|
||||
var estore *intimate.StoreExtractor = intimate.NewStoreExtractor()
|
||||
// // estore 解析存储连接实例
|
||||
// var estore *intimate.StoreExtractor = intimate.NewStoreExtractor()
|
||||
|
||||
func main() {
|
||||
Execute()
|
||||
@@ -35,14 +35,18 @@ func Execute() {
|
||||
waitfor := intimate.NewWaitFor(wd)
|
||||
ps := intimate.NewPerfectShutdown()
|
||||
|
||||
queue := intimate.TStreamer.Queue(intimate.Streamer{}, intimate.ConditionDefault(intimate.PNimo))
|
||||
|
||||
for !ps.IsClose() {
|
||||
streamer, err := estore.Pop(intimate.PNimo)
|
||||
istreamer, err := queue.Pop()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
estore.UpdateError(streamer, err)
|
||||
intimate.TStreamer.UpdateError(istreamer, err)
|
||||
continue
|
||||
}
|
||||
|
||||
streamer := istreamer.(*intimate.Streamer)
|
||||
|
||||
wd.Get(streamer.LiveUrl.String)
|
||||
// wd.Get("https://www.nimo.tv/live/1253835677")
|
||||
|
||||
@@ -71,22 +75,25 @@ func Execute() {
|
||||
|
||||
clog := &intimate.CollectLog{}
|
||||
clog.Platform = intimate.PNimo
|
||||
clog.Followers = sql.NullInt64{Int64: li.Followers, Valid: true}
|
||||
clog.Views = sql.NullInt64{Int64: li.Views, Valid: true}
|
||||
clog.UpdateTime = utime
|
||||
clog.Followers = &sql.NullInt64{Int64: li.Followers, Valid: true}
|
||||
clog.Views = &sql.NullInt64{Int64: li.Views, Valid: true}
|
||||
clog.UpdateTime = &utime
|
||||
clog.StreamerUid = streamer.Uid
|
||||
|
||||
var sum int64 = 0
|
||||
for _, v := range li.Gratuity {
|
||||
sum += v
|
||||
}
|
||||
clog.Gratuity = sql.NullInt64{Int64: sum, Valid: true}
|
||||
clog.Gratuity = &sql.NullInt64{Int64: sum, Valid: true}
|
||||
|
||||
cuid := estore.InsertClog(clog)
|
||||
cuid, err := intimate.TClog.InsertRetAutoID(clog)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
streamer.Channel = sql.NullString{String: li.Channel, Valid: true}
|
||||
streamer.Channel = &sql.NullString{String: li.Channel, Valid: true}
|
||||
streamer.LatestLogUid = cuid
|
||||
streamer.UpdateTime = utime
|
||||
streamer.UpdateTime = &utime
|
||||
streamer.Operator = 0
|
||||
|
||||
switch {
|
||||
@@ -102,7 +109,11 @@ func Execute() {
|
||||
streamer.UpdateInterval = 60
|
||||
}
|
||||
|
||||
estore.Update(streamer, "update_interval", streamer.UpdateInterval, "operator", streamer.Operator, "channel", streamer.Channel, "latest_log_uid", streamer.LatestLogUid, "update_time", streamer.UpdateTime)
|
||||
// estore.Update(streamer, "update_interval", streamer.UpdateInterval, "operator", streamer.Operator, "channel", streamer.Channel, "latest_log_uid", streamer.LatestLogUid, "update_time", streamer.UpdateTime)
|
||||
err = intimate.TStreamer.Update(streamer)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
count++
|
||||
if count >= countlimit {
|
||||
|
||||
@@ -123,7 +123,6 @@ func main() {
|
||||
}
|
||||
|
||||
streamer := &intimate.Streamer{}
|
||||
|
||||
matches := regexp.MustCompile(`https://www.twitch.tv/(\w+)`).FindStringSubmatch(href)
|
||||
if len(matches) == 2 {
|
||||
mc := matches[1]
|
||||
|
||||
Reference in New Issue
Block a user