TODO: Insert OpenrecRanking Data
This commit is contained in:
parent
ae56d86026
commit
db782a3533
5
main.go
5
main.go
|
@ -3,14 +3,11 @@ package main
|
||||||
// InitConfig 初始化配置加载 config.yaml(yml)
|
// InitConfig 初始化配置加载 config.yaml(yml)
|
||||||
var InitConfig *Config
|
var InitConfig *Config
|
||||||
|
|
||||||
// SourceStore 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
|
|
||||||
var SourceStore *Store
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
InitConfig = &Config{}
|
InitConfig = &Config{}
|
||||||
InitConfig.Load()
|
InitConfig.Load()
|
||||||
|
|
||||||
SourceStore = NewStore()
|
storeOpenrec = NewStore()
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -7,6 +7,28 @@ import (
|
||||||
"github.com/474420502/hunter"
|
"github.com/474420502/hunter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var openrecRanking *OpenrecRanking
|
||||||
|
|
||||||
|
// storeOpenrec 源存储实例, 为存储源数据的实现. 表格具体参考sql/intimate_source.sql
|
||||||
|
var storeOpenrec *Store
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
|
||||||
|
openrecRanking = &OpenrecRanking{}
|
||||||
|
openrecRanking.PreCurlUrl = `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
|
||||||
|
-H 'authority: public.openrec.tv' \
|
||||||
|
-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 'origin: https://www.openrec.tv' \
|
||||||
|
-H 'sec-fetch-site: same-site' \
|
||||||
|
-H 'sec-fetch-mode: cors' \
|
||||||
|
-H 'sec-fetch-dest: empty' \
|
||||||
|
-H 'referer: https://www.openrec.tv/ranking' \
|
||||||
|
-H 'accept-language: zh-CN,zh;q=0.9' \
|
||||||
|
-H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
|
||||||
|
--compressed`
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CREATE TABLE `platform_openrec` (
|
CREATE TABLE `platform_openrec` (
|
||||||
`url` text NOT NULL,
|
`url` text NOT NULL,
|
||||||
|
|
|
@ -32,20 +32,20 @@ func (or *OpenrecRankingTest) Execute(cxt *hunter.TaskContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRanking(t *testing.T) {
|
func TestRanking(t *testing.T) {
|
||||||
curlBash := `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
|
// curlBash := `curl 'https://public.openrec.tv/external/api/v5/channel-ranks?period=monthly&date=&tag=&page=1' \
|
||||||
-H 'authority: public.openrec.tv' \
|
// -H 'authority: public.openrec.tv' \
|
||||||
-H 'accept: application/json, text/javascript, */*; q=0.01' \
|
// -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 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \
|
||||||
-H 'origin: https://www.openrec.tv' \
|
// -H 'origin: https://www.openrec.tv' \
|
||||||
-H 'sec-fetch-site: same-site' \
|
// -H 'sec-fetch-site: same-site' \
|
||||||
-H 'sec-fetch-mode: cors' \
|
// -H 'sec-fetch-mode: cors' \
|
||||||
-H 'sec-fetch-dest: empty' \
|
// -H 'sec-fetch-dest: empty' \
|
||||||
-H 'referer: https://www.openrec.tv/ranking' \
|
// -H 'referer: https://www.openrec.tv/ranking' \
|
||||||
-H 'accept-language: zh-CN,zh;q=0.9' \
|
// -H 'accept-language: zh-CN,zh;q=0.9' \
|
||||||
-H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
|
// -H 'if-none-match: W/"25edb-aUYBdmLqZcr6DW4ZWKX9r2aqolg"' \
|
||||||
--compressed`
|
// --compressed`
|
||||||
|
|
||||||
ht := hunter.NewHunter(&OpenrecRankingTest{hunter.PreCurlUrl(curlBash)})
|
ht := hunter.NewHunter(openrecRanking)
|
||||||
ht.SetShare("test", t)
|
ht.SetShare("test", t)
|
||||||
ht.Execute()
|
ht.Execute()
|
||||||
}
|
}
|
||||||
|
|
6
store.go
6
store.go
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
|
@ -32,5 +33,8 @@ func NewStore() *Store {
|
||||||
|
|
||||||
// Save 储存数据
|
// Save 储存数据
|
||||||
func (store *Store) Save(isource ISource) {
|
func (store *Store) Save(isource ISource) {
|
||||||
store.db.Exec("insert into `platform_openrec`(url, target_type, source, ext) values(?,?,?,?)", isource.GetUrl(), isource.GetTargetType(), isource.GetSource(), isource.GetExt())
|
_, err := store.db.Exec("insert into `platform_openrec`(url, target_type, source, ext) values(?,?,?,?)", isource.GetUrl(), isource.GetTargetType(), isource.GetSource(), isource.GetExt())
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user