增加多地区每日图片抓取能力

This commit is contained in:
2026-01-30 13:33:40 +08:00
parent b69db53f0a
commit 93690e10d3
24 changed files with 980 additions and 149 deletions

View File

@@ -413,6 +413,12 @@ const docTemplate = `{
"in": "path",
"required": true
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -455,6 +461,12 @@ const docTemplate = `{
"name": "date",
"in": "path",
"required": true
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
@@ -478,6 +490,12 @@ const docTemplate = `{
],
"summary": "获取随机图片",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -513,6 +531,14 @@ const docTemplate = `{
"image"
],
"summary": "获取随机图片元数据",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@@ -534,6 +560,12 @@ const docTemplate = `{
],
"summary": "获取今日图片",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -569,6 +601,14 @@ const docTemplate = `{
"image"
],
"summary": "获取今日图片元数据",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@@ -614,6 +654,12 @@ const docTemplate = `{
"description": "按月份过滤 (格式: YYYY-MM)",
"name": "month",
"in": "query"
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
@@ -628,12 +674,39 @@ const docTemplate = `{
}
}
}
},
"/regions": {
"get": {
"description": "返回系统支持的所有必应地区编码及标签。如果配置中指定了抓取地区,这些地区将排在列表最前面(置顶)。",
"produces": [
"application/json"
],
"tags": [
"image"
],
"summary": "获取支持的地区列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/util.Region"
}
}
}
}
}
}
},
"definitions": {
"config.APIConfig": {
"type": "object",
"properties": {
"enableMktFallback": {
"description": "当请求的地区不存在时,是否回退到默认地区",
"type": "boolean"
},
"mode": {
"description": "local | redirect",
"type": "string"
@@ -666,6 +739,9 @@ const docTemplate = `{
"feature": {
"$ref": "#/definitions/config.FeatureConfig"
},
"fetcher": {
"$ref": "#/definitions/config.FetcherConfig"
},
"log": {
"$ref": "#/definitions/config.LogConfig"
},
@@ -717,6 +793,17 @@ const docTemplate = `{
}
}
},
"config.FetcherConfig": {
"type": "object",
"properties": {
"regions": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"config.LocalConfig": {
"type": "object",
"properties": {
@@ -917,6 +1004,9 @@ const docTemplate = `{
"hsh": {
"type": "string"
},
"mkt": {
"type": "string"
},
"quiz": {
"type": "string"
},
@@ -1006,6 +1096,17 @@ const docTemplate = `{
"type": "string"
}
}
},
"util.Region": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"securityDefinitions": {

View File

@@ -407,6 +407,12 @@
"in": "path",
"required": true
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -449,6 +455,12 @@
"name": "date",
"in": "path",
"required": true
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
@@ -472,6 +484,12 @@
],
"summary": "获取随机图片",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -507,6 +525,14 @@
"image"
],
"summary": "获取随机图片元数据",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@@ -528,6 +554,12 @@
],
"summary": "获取今日图片",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
},
{
"type": "string",
"default": "UHD",
@@ -563,6 +595,14 @@
"image"
],
"summary": "获取今日图片元数据",
"parameters": [
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
@@ -608,6 +648,12 @@
"description": "按月份过滤 (格式: YYYY-MM)",
"name": "month",
"in": "query"
},
{
"type": "string",
"description": "地区编码 (如 zh-CN, en-US)",
"name": "mkt",
"in": "query"
}
],
"responses": {
@@ -622,12 +668,39 @@
}
}
}
},
"/regions": {
"get": {
"description": "返回系统支持的所有必应地区编码及标签。如果配置中指定了抓取地区,这些地区将排在列表最前面(置顶)。",
"produces": [
"application/json"
],
"tags": [
"image"
],
"summary": "获取支持的地区列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/util.Region"
}
}
}
}
}
}
},
"definitions": {
"config.APIConfig": {
"type": "object",
"properties": {
"enableMktFallback": {
"description": "当请求的地区不存在时,是否回退到默认地区",
"type": "boolean"
},
"mode": {
"description": "local | redirect",
"type": "string"
@@ -660,6 +733,9 @@
"feature": {
"$ref": "#/definitions/config.FeatureConfig"
},
"fetcher": {
"$ref": "#/definitions/config.FetcherConfig"
},
"log": {
"$ref": "#/definitions/config.LogConfig"
},
@@ -711,6 +787,17 @@
}
}
},
"config.FetcherConfig": {
"type": "object",
"properties": {
"regions": {
"type": "array",
"items": {
"type": "string"
}
}
}
},
"config.LocalConfig": {
"type": "object",
"properties": {
@@ -911,6 +998,9 @@
"hsh": {
"type": "string"
},
"mkt": {
"type": "string"
},
"quiz": {
"type": "string"
},
@@ -1000,6 +1090,17 @@
"type": "string"
}
}
},
"util.Region": {
"type": "object",
"properties": {
"label": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"securityDefinitions": {

View File

@@ -2,6 +2,9 @@ basePath: /api/v1
definitions:
config.APIConfig:
properties:
enableMktFallback:
description: 当请求的地区不存在时,是否回退到默认地区
type: boolean
mode:
description: local | redirect
type: string
@@ -23,6 +26,8 @@ definitions:
$ref: '#/definitions/config.DBConfig'
feature:
$ref: '#/definitions/config.FeatureConfig'
fetcher:
$ref: '#/definitions/config.FetcherConfig'
log:
$ref: '#/definitions/config.LogConfig'
retention:
@@ -56,6 +61,13 @@ definitions:
writeDailyFiles:
type: boolean
type: object
config.FetcherConfig:
properties:
regions:
items:
type: string
type: array
type: object
config.LocalConfig:
properties:
root:
@@ -190,6 +202,8 @@ definitions:
type: string
hsh:
type: string
mkt:
type: string
quiz:
type: string
startdate:
@@ -248,6 +262,13 @@ definitions:
updated_at:
type: string
type: object
util.Region:
properties:
label:
type: string
value:
type: string
type: object
host: localhost:8080
info:
contact: {}
@@ -501,6 +522,10 @@ paths:
name: date
required: true
type: string
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
- default: UHD
description: 分辨率
in: query
@@ -530,6 +555,10 @@ paths:
name: date
required: true
type: string
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
produces:
- application/json
responses:
@@ -544,6 +573,10 @@ paths:
get:
description: 随机返回一张已抓取的图片流或重定向
parameters:
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
- default: UHD
description: 分辨率
in: query
@@ -567,6 +600,11 @@ paths:
/image/random/meta:
get:
description: 随机获取一张已抓取图片的元数据
parameters:
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
produces:
- application/json
responses:
@@ -581,6 +619,10 @@ paths:
get:
description: 根据参数返回今日必应图片流或重定向
parameters:
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
- default: UHD
description: 分辨率 (UHD, 1920x1080, 1366x768, 1280x720, 1024x768, 800x600, 800x480,
640x480, 640x360, 480x360, 400x240, 320x240)
@@ -605,6 +647,11 @@ paths:
/image/today/meta:
get:
description: 获取今日必应图片的标题、版权等元数据
parameters:
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
produces:
- application/json
responses:
@@ -637,6 +684,10 @@ paths:
in: query
name: month
type: string
- description: 地区编码 (如 zh-CN, en-US)
in: query
name: mkt
type: string
produces:
- application/json
responses:
@@ -649,6 +700,21 @@ paths:
summary: 获取图片列表
tags:
- image
/regions:
get:
description: 返回系统支持的所有必应地区编码及标签。如果配置中指定了抓取地区,这些地区将排在列表最前面(置顶)。
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/util.Region'
type: array
summary: 获取支持的地区列表
tags:
- image
securityDefinitions:
BearerAuth:
in: header