mirror of
https://github.com/ProudMuBai/GoFilm.git
synced 2026-02-27 23:34:42 +08:00
update docker deploy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package dp
|
||||
|
||||
import (
|
||||
"server/model"
|
||||
@@ -1,4 +1,4 @@
|
||||
package common
|
||||
package dp
|
||||
|
||||
import (
|
||||
"server/model"
|
||||
38
film/server/plugin/common/param/SimpleParam.go
Normal file
38
film/server/plugin/common/param/SimpleParam.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package param
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
)
|
||||
|
||||
/*
|
||||
简单参数处理
|
||||
*/
|
||||
|
||||
// IsEmpty 判断各种基本类型是否为空
|
||||
func IsEmpty(target any) bool {
|
||||
switch target.(type) {
|
||||
case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64:
|
||||
return target == reflect.Zero(reflect.TypeOf(target)).Interface()
|
||||
case string:
|
||||
return target == ""
|
||||
case bool:
|
||||
return target.(bool)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func IsEmptyRe[T ~int | ~uint | float32 | float64 | string | bool](target T) bool {
|
||||
v := reflect.ValueOf(target)
|
||||
switch v.Kind() {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float32,
|
||||
reflect.Float64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
|
||||
return v.Interface() == 0
|
||||
case reflect.String:
|
||||
return v.String() == ""
|
||||
case reflect.Bool:
|
||||
return v.Bool()
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ func InitRedisConn() error {
|
||||
Addr: config.RedisAddr,
|
||||
Password: config.RedisPassword,
|
||||
DB: config.RedisDBNo,
|
||||
PoolSize: 10, // 默认连接数
|
||||
PoolSize: 10, // 最大连接数
|
||||
DialTimeout: time.Second * 10, // 超时时间
|
||||
})
|
||||
// 测试连接是否正常
|
||||
@@ -31,7 +31,7 @@ func InitRedisConn() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 关闭redis连接
|
||||
// CloseRedis 关闭redis连接
|
||||
func CloseRedis() error {
|
||||
return Rdb.Close()
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"net/url"
|
||||
"server/config"
|
||||
"server/model"
|
||||
"server/plugin/common"
|
||||
"server/plugin/common/dp"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
*/
|
||||
|
||||
const (
|
||||
MainSite = "https://www.feisuzyapi.com/api.php/provide/vod/"
|
||||
MainSite = "https://cj.lzcaiji.com/api.php/provide/vod/"
|
||||
)
|
||||
|
||||
type Site struct {
|
||||
@@ -39,14 +39,17 @@ type Site struct {
|
||||
|
||||
// SiteList 播放源采集站
|
||||
var SiteList = []Site{
|
||||
//{"tk", "https://api.tiankongapi.com/api.php/provide/vod"},
|
||||
//{"yh", "https://m3u8.apiyhzy.com/api.php/provide/vod/"},
|
||||
//{"zk", "https://api.1080zyku.com/inc/apijson.php"}, 数据格式不规范,不采用
|
||||
// 备用采集站
|
||||
//{"lz_bk", "https://cj.lzcaiji.com/api.php/provide/vod/"},
|
||||
//{"fs", "https://www.feisuzyapi.com/api.php/provide/vod/"},
|
||||
//{"su", "https://subocaiji.com/api.php/provide/vod/at/json"},
|
||||
//{"bf", "https://bfzyapi.com/api.php/provide/vod/"},
|
||||
//{"ff", "https://svip.ffzyapi8.com/api.php/provide/vod/"},
|
||||
|
||||
{"lz", "https://cj.lziapi.com/api.php/provide/vod/"},
|
||||
//{"lz", "https://cj.lziapi.com/api.php/provide/vod/"},
|
||||
{"kk", "https://kuaikan-api.com/api.php/provide/vod/from/kuaikan"},
|
||||
{"bf", "http://by.bfzyapi.com/api.php/provide/vod/"},
|
||||
{"ff", "https://cj.ffzyapi.com/api.php/provide/vod/"},
|
||||
{"su", "https://subocaiji.com/api.php/provide/vod/at/json"},
|
||||
}
|
||||
|
||||
// StartSpider 执行多源spider
|
||||
@@ -57,15 +60,16 @@ func StartSpider() {
|
||||
// 爬取主站点数据
|
||||
MainSiteSpider()
|
||||
log.Println("MainSiteSpider 主站点影片信息保存完毕")
|
||||
// 查找并创建search数据库
|
||||
// 查找并创建search数据库, 保存search信息, 添加索引
|
||||
time.Sleep(time.Second * 10)
|
||||
model.CreateSearchTable()
|
||||
SearchInfoToMdb()
|
||||
model.AddSearchIndex()
|
||||
log.Println("SearchInfoToMdb 影片检索信息保存完毕")
|
||||
// 获取其他站点数据
|
||||
//获取其他站点数据13
|
||||
go MtSiteSpider()
|
||||
log.Println("Spider End , 数据保存执行完成")
|
||||
//time.Sleep(time.Second * 10)
|
||||
time.Sleep(time.Second * 10)
|
||||
}
|
||||
|
||||
// CategoryList 获取分类数据
|
||||
@@ -86,7 +90,7 @@ func CategoryList() {
|
||||
// 获取分类列表信息
|
||||
classList := movieListInfo.Class
|
||||
// 组装分类数据信息树形结构
|
||||
categoryTree := common.CategoryTree(classList)
|
||||
categoryTree := dp.CategoryTree(classList)
|
||||
// 序列化tree
|
||||
data, _ := json.Marshal(categoryTree)
|
||||
// 保存 tree 到redis
|
||||
@@ -287,7 +291,7 @@ func StartSpiderRe() {
|
||||
func GetPageCount(r RequestInfo) (count int, err error) {
|
||||
// 发送请求获取pageCount
|
||||
r.Params.Set("ac", "detail")
|
||||
r.Params.Set("pg", "1")
|
||||
r.Params.Set("pg", "2")
|
||||
ApiGet(&r)
|
||||
// 判断请求结果是否为空, 如果为空直接输出错误并终止
|
||||
if len(r.Resp) <= 0 {
|
||||
@@ -328,6 +332,6 @@ func GetMovieDetail(pageNumber int, r RequestInfo) (list []model.MovieDetail, er
|
||||
return
|
||||
}
|
||||
// 处理details信息
|
||||
list = common.ProcessMovieDetailList(details.List)
|
||||
list = dp.ProcessMovieDetailList(details.List)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ var (
|
||||
// RequestInfo 请求参数结构体
|
||||
type RequestInfo struct {
|
||||
Uri string `json:"uri"` // 请求url地址
|
||||
Params url.Values `json:"params"` // 请求参数
|
||||
Params url.Values `json:"param"` // 请求参数
|
||||
Header http.Header `json:"header"` // 请求头数据
|
||||
Resp []byte `json:"resp"` // 响应结果数据
|
||||
}
|
||||
@@ -30,6 +30,10 @@ var RefererUrl string
|
||||
// CreateClient 初始化请求客户端
|
||||
func CreateClient() *colly.Collector {
|
||||
c := colly.NewCollector()
|
||||
|
||||
// 设置请求使用clash的socks5代理
|
||||
//setProxy(c)
|
||||
|
||||
// 设置代理信息
|
||||
//if proxy, err := proxy.RoundRobinProxySwitcher("127.0.0.1:7890"); err != nil {
|
||||
// c.SetProxyFunc(proxy)
|
||||
@@ -46,6 +50,7 @@ func CreateClient() *colly.Collector {
|
||||
c.OnRequest(func(request *colly.Request) {
|
||||
// 设置一些请求头信息
|
||||
request.Headers.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
request.Headers.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36")
|
||||
//request.Headers.Set("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7")
|
||||
// 请求完成后设置请求头Referer
|
||||
if len(RefererUrl) <= 0 || !strings.Contains(RefererUrl, request.URL.Host) {
|
||||
@@ -89,3 +94,9 @@ func ApiGet(r *RequestInfo) {
|
||||
log.Println("获取数据失败: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 本地代理测试
|
||||
func setProxy(c *colly.Collector) {
|
||||
proxyUrl, _ := url.Parse("socks5://127.0.0.1:7890")
|
||||
c.WithTransport(&http.Transport{Proxy: http.ProxyURL(proxyUrl)})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user