两处原因,分别处理: 1. contentsync 只按 _id 水位线插新增,源库事后打上的 isDelete 传不过来, 源站删掉的重复集在目标库一直留着。每轮同步后补扫一次 media / media_content / video_info,把源库的软删除标记同步过去,并按 web/service/mediacontentser 的同一口径重算父级 currentEpisode / freeEpisode。只做「源库删了→目标也删」一个方向,不与本地下架保护冲突。 2. 各站 skd 的媒资库同步会为同一集(mediaId+hashId 相同)另插一条自己的 _id, 与 contentsync 带过来的源库那条并存。媒资库那条在 SaleCoin=0 时 listenPermission=2,本该收费的集可以白看。插入时若发现本地已有同一集, 把本地那条 isActive:false 下架;并新增 skd 配置开关 switch.mediaSyncDisabled,非源站可直接关掉这条同步链。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
115 lines
4.2 KiB
Go
115 lines
4.2 KiB
Go
package skdg
|
|
|
|
import (
|
|
"91porn-server/common/constant"
|
|
"91porn-server/common/db"
|
|
"91porn-server/common/elastic"
|
|
"91porn-server/common/redis"
|
|
"91porn-server/common/tg"
|
|
)
|
|
|
|
type GlobalConfig struct {
|
|
Base struct {
|
|
Port int64 `json:"port"`
|
|
Env string `json:"env"`
|
|
// 媒体分片(TS)鉴权签名密钥对象(含 keyVersion/key);未配置时回退内置默认(版本 default + constant.MediaSourceAuthKey)
|
|
TsAuth constant.TsAuthKeyConfig `json:"tsAuth"`
|
|
} `json:"base"`
|
|
Mongo struct {
|
|
VideoDbUrl string `json:"videoDbUrl"` //主数据库 存放强业务相关的数据
|
|
StatDbUrl string `json:"statDbUrl"` //统计数据库 存放统计 日志 渠道相关的数据
|
|
LogDbUrl string `json:"logDbUrl"` //日志数据库
|
|
SpiderDbUrl string `json:"spiderDbUrl"` //爬虫库
|
|
} `json:"mongo"`
|
|
Log struct {
|
|
Level string `json:"level"`
|
|
} `json:"log"`
|
|
Redis struct {
|
|
URL string `json:"url"`
|
|
} `json:"redis"`
|
|
ShortRecommend ShortRecommendConfig `json:"shortRecommend"`
|
|
DataReport struct {
|
|
Url string `json:"url"`
|
|
AppUrl string `json:"appUrl"`
|
|
} `json:"dataReport"`
|
|
DaiChong struct {
|
|
AppID string `json:"appId"`
|
|
AppSecret string `json:"appSecret"`
|
|
PlatName string `json:"platName"`
|
|
Domain string `json:"domain"`
|
|
} `json:"daichong"`
|
|
LSJ struct {
|
|
AppID string `json:"appId"`
|
|
APIKey string `json:"apiKey"`
|
|
APIUrl string `json:"apiUrl"`
|
|
ImageYuan string `json:"imageYuan"`
|
|
NoticeURL string `json:"noticeUrl"`
|
|
} `json:"lsj"`
|
|
Hevc struct {
|
|
EnableTranscode *bool `json:"enableTranscode"` // nil: 仅生产环境默认开启;true: 显式开启;false: 所有环境熔断
|
|
PullSecret string `json:"pullSecret"` // 与 App 共享的 H265 拉流签名密钥,至少 32 个随机字节
|
|
} `json:"hevc"`
|
|
AdCenter struct {
|
|
ApiDomain string `json:"apiDomain"` // api 地址
|
|
MerchantCode string `json:"merchantCode"` // 商户 code
|
|
AppCode string `json:"appCode"` // 应用 code
|
|
AesKey string `json:"aesKey"` // 数据解密 KEY
|
|
} `json:"adCenter"`
|
|
ImV2 struct {
|
|
BaseURL string `json:"baseUrl"`
|
|
DynamicConfigDomain string `json:"dynamicConfigDomain"`
|
|
SocketURL string `json:"socketUrl"`
|
|
MerchantCode string `json:"merchantCode"`
|
|
TenantCode string `json:"tenantCode"`
|
|
AppKey string `json:"appKey"`
|
|
ClientID string `json:"clientId"`
|
|
ClientSecret string `json:"clientSecret"`
|
|
} `json:"imv2"`
|
|
Elastic struct {
|
|
VideoUrl string `json:"videoUrl"`
|
|
UserName string `json:"userName"`
|
|
PassWord string `json:"passWord"`
|
|
} `json:"elastic"`
|
|
Url struct {
|
|
CheckUrl string `json:"checkUrl"`
|
|
SpiderDataURL string `json:"spiderDataUrl"` //统计中心数据同步域名
|
|
PullFileInfo string `json:"pullFileInfo"`
|
|
AiServer string `json:"aiServer"` //ai订单请求地址
|
|
AppApiUrl string `json:"appApiUrl"` // App 对外 HTTPS origin(无路径),供 H265 云转码拉取源 m3u8
|
|
} `json:"url"`
|
|
Switch struct {
|
|
NotifyExpire bool `json:"notifyExpire"`
|
|
// MediaSyncDisabled 关掉 skd 每 30 分钟的媒资库同步。
|
|
//
|
|
// 本站内容由 scripts/contentsync 从源站整体同步过来,源站自己会跑媒资库
|
|
// 同步;本站再跑一遍会为同一集(mediaId+hashId 相同)另插一条自己的 _id,
|
|
// 剧集列表就出现「1 1 2 2」,而且媒资库那条在 SaleCoin=0 时
|
|
// listenPermission=2(免费),等于本该收费的集可以白看。
|
|
//
|
|
// 留空/false 表示照旧开启——源站必须保持开启,否则新剧集无从进库。
|
|
MediaSyncDisabled bool `json:"mediaSyncDisabled"`
|
|
} `json:"switch"`
|
|
StartDate string `json:"startDate"`
|
|
MediaResourcesCfg struct {
|
|
UploadMediaUrl string `json:"uploadMediaUrl"` // 请求域名
|
|
ProId string `json:"proId"` // 商户号
|
|
AppSecret string `json:"appSecret"` // 商户密钥
|
|
} `json:"mediaResourceCfg"` //媒体资源库配置
|
|
}
|
|
|
|
var (
|
|
Conf *GlobalConfig
|
|
Redis *redis.Client
|
|
VideoES *elastic.Client
|
|
Static *StaticSource
|
|
StatDB *db.MongoDB
|
|
VideoDB *db.MongoDB
|
|
LogDB *db.MongoDB
|
|
SpiderDB *db.MongoDB
|
|
Bot *tg.Bot
|
|
)
|
|
|
|
type StaticSource struct {
|
|
Portrait []string `json:"portrait"`
|
|
}
|