1.重构命名, 简化代码, 加入build.sh
2.重构数据字段结构, 使数据合理性提高. 3.测试通过openrec获取数据完整性. TODO: 测试时区问题.
This commit is contained in:
3
tasks/openrec/openrec_task2/.gitignore
vendored
3
tasks/openrec/openrec_task2/.gitignore
vendored
@@ -1 +1,2 @@
|
||||
openrec_task2
|
||||
openrec_task2
|
||||
log
|
||||
|
||||
@@ -44,24 +44,27 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
atomic.StoreInt32(&loop, 0)
|
||||
}()
|
||||
|
||||
var lasterr error = nil
|
||||
|
||||
for atomic.LoadInt32(&loop) > 0 {
|
||||
|
||||
source, err := store.Pop(string(intimate.TTOpenrecUser))
|
||||
|
||||
if source == nil || err != nil {
|
||||
log.Println(err)
|
||||
if err != lasterr {
|
||||
log.Println(err, lasterr)
|
||||
lasterr = err
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
continue
|
||||
}
|
||||
|
||||
userSource := &intimate.Source{}
|
||||
userid := source.GetSource().String
|
||||
userUrl := "https://www.openrec.tv/user/" + userid
|
||||
userSource.SetUrl(userUrl)
|
||||
userId := source.Source.String
|
||||
userUrl := "https://www.openrec.tv/user/" + userId
|
||||
|
||||
wf := cxt.Session().Get(userUrl)
|
||||
resp, err := wf.Execute()
|
||||
source.SetUpdateTime(sql.NullTime{Time: time.Now(), Valid: true})
|
||||
tp := cxt.Session().Get(userUrl)
|
||||
resp, err := tp.Execute()
|
||||
source.UpdateTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -69,7 +72,7 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
continue
|
||||
}
|
||||
|
||||
cookies := cxt.Session().GetCookies(wf.GetParsedURL())
|
||||
cookies := cxt.Session().GetCookies(tp.GetParsedURL())
|
||||
|
||||
scurl := "https://www.openrec.tv/viewapp/api/v6/supporters?identify_id=sumomo_xqx&month=&Uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683&Token=46598c320408bd69ae3c63298f6f4a3a97354175&Random=AZVXNAAXQVMOSVWNDPIQ&page_number=1 -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' -H 'cookie: uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683;' --compressed"
|
||||
curl := gcurl.ParseRawCURL(scurl)
|
||||
@@ -99,7 +102,7 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
}
|
||||
}
|
||||
|
||||
supportersQuery.Set("identify_id", source.GetSource().String)
|
||||
supportersQuery.Set("identify_id", userId)
|
||||
temporary.SetQuery(supportersQuery)
|
||||
|
||||
resp, err := temporary.Execute()
|
||||
@@ -131,8 +134,8 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
ext["supporters"] = supporters
|
||||
ext["user"] = string(resp.Content())
|
||||
|
||||
wf = cxt.Session().Get("https://www.openrec.tv/live/" + userid)
|
||||
resp, err = wf.Execute()
|
||||
tp = cxt.Session().Get("https://www.openrec.tv/live/" + userId)
|
||||
resp, err = tp.Execute()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
store.UpdateError(source, err)
|
||||
@@ -147,8 +150,8 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
continue
|
||||
}
|
||||
|
||||
source.SetOperator(int32(intimate.OperatorOK))
|
||||
source.SetExt(string(extJsonBytes))
|
||||
source.Operator = int32(intimate.OperatorOK)
|
||||
source.Ext = string(extJsonBytes)
|
||||
store.Update(source)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user