一、后台只留一个「爬虫」页(/admin/spider) 抓取与入库本就是同一条流水线的上下游,分两页看谁都看不全。 新页三块:状态条(在线/卡住 + 队列数 + 待入库数)、正在抓(含进度与心跳)、 最近入库结果(品牌/场次/结果/说明)。只读,取消与重试一并下线。 二、抓取一律全量 删除品牌页的场次上限下拉与 hidden maxShows=3,入队固定 0(全量)。 crawl_tasks.max_shows 列保留,历史任务照常显示。 三、跳过判定改覆盖率 - brand_runways 增加 expected_images(spider 上报的应有张数) - /shows/covered 返回 images + expected - 实际张数 >= 应有 - 5 才跳过;expected=0 时回落 10 张阈值 - 实体已存在时不再直接跳过:按 key 比对把缺的图补进库(repaired) 否则「判定不完整→重爬→后端跳过」会形成死循环,带宽白花、缺图永远补不上 四、租约 900→300 秒,且心跳算存活 只看 locked_at 会把跑了几小时的全量抓取误判成卡死; 加上 progress_at 后,真卡住 5 分钟才回收。
62 lines
3.9 KiB
Go
62 lines
3.9 KiB
Go
package dto
|
||
|
||
// 入库类型(payload.Kind)。
|
||
const (
|
||
IngestKindRunway = "runway" // 走秀(默认,需 brand_uid)
|
||
IngestKindStreet = "street" // 街拍(无品牌,需 city/title)
|
||
)
|
||
|
||
// RunwayIngest 爬虫上报的单场载荷(ingest_jobs.payload 的 JSON 结构)。
|
||
//
|
||
// 设计:爬虫只传「元数据 + 图片 URL 列表」,不传图、不直写业务表;
|
||
// 下载与存储上传由后台 worker 完成。
|
||
//
|
||
// 通用字段:
|
||
// - Kind: runway | street(决定 worker 走哪条晋升管线;缺省 runway)
|
||
// - Images: 图片原始 URL 列表(worker 下载)
|
||
//
|
||
// runway 专属:BrandUID(品牌 hashid 编码,必填)、TitleEn/TitleCn、Description*、Year、Season、CollectionType。
|
||
// street 专属:City(地区/城市)、TitleEn(单标题)。
|
||
type RunwayIngest struct {
|
||
Kind string `json:"kind"` // runway | street,缺省 runway
|
||
BrandUID string `json:"brand_uid"` // 品牌编码 id(hashid),runway 必填
|
||
TitleEn string `json:"title_en"` // 英文标题(runway 优先;street 作为单标题)
|
||
TitleCn string `json:"title_cn"` // 中文标题(可空)
|
||
DescriptionEn string `json:"description_en"` // 英文描述(可空)
|
||
DescriptionCn string `json:"description_cn"` // 中文描述(可空)
|
||
Year uint16 `json:"year"` // 年份,如 2026
|
||
Season string `json:"season"` // spring / fall
|
||
CollectionType string `json:"collection_type"` // rtw / menswear / couture / resort / pre_fall
|
||
City string `json:"city"` // 地区/城市(street 用)
|
||
PublishedAt uint32 `json:"published_at"` // Vogue 详情页 datePublished 的 Unix 时间戳(秒);0=未抽取。标题缺年份时用于矫正 year
|
||
// ExpectedImages 本场秀应有的图片总数(spider 侧已知,含细节图)。
|
||
// 用于重爬前的覆盖率判定:实际入库张数接近它才算抓全了;0=未知(旧爬虫不上报)。
|
||
ExpectedImages int `json:"expected_images,omitempty"`
|
||
Images []string `json:"images"` // 兼容旧 worker:铺平的主图 URL 列表(无细节分组时回退用)
|
||
// Looks 结构化「主图 + 细节图」分组(Vogue 一个 gallery item = 1 主图 + N 细节图)。
|
||
// 爬虫结构化上报时优先用 Looks;为空时 worker 回退到 Images(全部视为主图,无细节)。
|
||
Looks []RunwayLook `json:"looks,omitempty"`
|
||
}
|
||
|
||
// RunwayLook 一场秀中的一个 look:1 张主图 + 0..N 张细节图。
|
||
// 主图即对外默认展示的走秀图;细节图挂靠到对应主图,由「细节入口」按需展开。
|
||
//
|
||
// 图片有两种来源,二选一(同一条 payload 内可混用):
|
||
//
|
||
// ① 旧路径:Main / Details 给原始 URL,worker 自己下载 + 上传存储(默认行为);
|
||
// ② 新路径(媒体机直传):MainKey / DetailKeys 给「已上传到 S4 的对象 key」,
|
||
// worker 直接落库,不再下载、不再上传。
|
||
//
|
||
// 新路径的意义:抓取与入库分离后,下载/上传这类带宽密集的活由部署在快网络里的
|
||
// spider 完成,后端只做业务写库,吞吐不再被后端机器的出口带宽卡住。
|
||
// key 由 spider 按内容 sha1 生成(runway/<sha1>.jpg),因此重复上传天然幂等。
|
||
type RunwayLook struct {
|
||
Main string `json:"main"` // 主图(look)原始 URL
|
||
Details []string `json:"details"` // 细节图原始 URL 列表
|
||
|
||
MainKey string `json:"main_key,omitempty"` // 主图已上传的存储 key(新路径)
|
||
DetailKeys []string `json:"detail_keys,omitempty"` // 细节图已上传的存储 key(新路径)
|
||
MainSize int64 `json:"main_size,omitempty"` // 主图字节数(新路径,0=未知)
|
||
DetailSizes []int64 `json:"detail_sizes,omitempty"` // 细节图字节数(与 DetailKeys 对齐,0=未知)
|
||
}
|