1. 修复 store_extractor Update 错误.

2. 重构前两个网站的代码架构不合理.
3. 减少冗余代码
This commit is contained in:
eson
2020-08-13 19:11:53 +08:00
parent 36c28826ba
commit b20f97f7c9
16 changed files with 76 additions and 148 deletions

View File

@@ -5,13 +5,9 @@ import (
"encoding/json"
"intimate"
"log"
"os"
"os/signal"
"regexp"
"strconv"
"strings"
"sync/atomic"
"syscall"
"time"
"github.com/tidwall/gjson"
@@ -29,17 +25,10 @@ type OpenrecExtractor struct {
func (oe *OpenrecExtractor) Execute() {
var loop int32 = 1
go func() {
signalchan := make(chan os.Signal)
signal.Notify(signalchan, syscall.SIGKILL, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP)
log.Println("accept stop command:", <-signalchan)
atomic.StoreInt32(&loop, 0)
}()
ps := intimate.NewPerfectShutdown()
var lasterr error = nil
for atomic.LoadInt32(&loop) > 0 {
for !ps.IsClose() {
var err error
source, err := sstore.Pop(intimate.TOpenrecUser, 0)
@@ -60,7 +49,7 @@ func (oe *OpenrecExtractor) Execute() {
streamer := &intimate.Streamer{}
streamer.UserId = userId
streamer.Platform = intimate.Popenrec
// streamer.Platform = intimate.Popenrec
htmlUser := datamap["html_user"]
oe.user = intimate.NewExtractorSource(&htmlUser)
@@ -94,10 +83,20 @@ func (oe *OpenrecExtractor) Execute() {
logUid := estore.InsertClog(clog)
LiveUrl := "https://www.openrec.tv/live/" + userId
streamer.LiveUrl = sql.NullString{String: LiveUrl, Valid: true}
streamer.LatestLogUid = logUid
streamer.Operator = 0
estore.UpdateStreamer(streamer)
// streamer.Operator = 0
log.Println(streamer.UserId)
estore.Update(streamer,
"user_name", streamer.UserName,
"user_id", streamer.UserId,
"live_url", streamer.LiveUrl,
"latest_log_uid", streamer.LatestLogUid,
"update_time", streamer.UpdateTime,
"tags", streamer.Tags,
)
source.Operator = int32(intimate.OperatorExtractorOK)
sstore.UpdateOperator(source)