main
commit
990963cd70
@ -0,0 +1,65 @@ |
|||||||
|
.DS_Store |
||||||
|
# Byte-compiled / optimized / DLL files |
||||||
|
__pycache__/ |
||||||
|
*.py[cod] |
||||||
|
*$py.class |
||||||
|
|
||||||
|
# C extensions |
||||||
|
*.so |
||||||
|
|
||||||
|
# Distribution / packaging |
||||||
|
.Python |
||||||
|
env/ |
||||||
|
build/ |
||||||
|
develop-eggs/ |
||||||
|
dist/ |
||||||
|
downloads/ |
||||||
|
eggs/ |
||||||
|
.eggs/ |
||||||
|
lib/ |
||||||
|
lib64/ |
||||||
|
parts/ |
||||||
|
sdist/ |
||||||
|
var/ |
||||||
|
*.egg-info/ |
||||||
|
.installed.cfg |
||||||
|
*.egg |
||||||
|
.idea/* |
||||||
|
xml_files/ |
||||||
|
|
||||||
|
# PyInstaller |
||||||
|
# Usually these files are written by a python script from a template |
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it. |
||||||
|
*.manifest |
||||||
|
*.spec |
||||||
|
|
||||||
|
# Installer logs |
||||||
|
pip-log.txt |
||||||
|
pip-delete-this-directory.txt |
||||||
|
|
||||||
|
# Unit test / coverage reports |
||||||
|
htmlcov/ |
||||||
|
.tox/ |
||||||
|
.coverage |
||||||
|
.coverage.* |
||||||
|
.cache |
||||||
|
nosetests.xml |
||||||
|
coverage.xml |
||||||
|
*,cover |
||||||
|
|
||||||
|
# Translations |
||||||
|
*.mo |
||||||
|
*.pot |
||||||
|
|
||||||
|
# Django stuff: |
||||||
|
*.log |
||||||
|
|
||||||
|
# Sphinx documentation |
||||||
|
docs/_build/ |
||||||
|
|
||||||
|
# PyBuilder |
||||||
|
target/ |
||||||
|
|
||||||
|
other/split_clash_config/split_config |
||||||
|
ai_news/save_data |
||||||
|
daily/*.txt |
||||||
@ -0,0 +1,48 @@ |
|||||||
|
syntax = "v1" |
||||||
|
|
||||||
|
info( |
||||||
|
title: "HD4K漫画下载服务" |
||||||
|
desc: "下载HD4K漫画图片的API服务" |
||||||
|
author: "hd4k-downloader" |
||||||
|
version: "v1.0.0" |
||||||
|
) |
||||||
|
|
||||||
|
type ( |
||||||
|
// 下载请求 |
||||||
|
DownloadRequest { |
||||||
|
Title string `json:"title"` |
||||||
|
Imgs map[string]string `json:"imgs"` |
||||||
|
} |
||||||
|
|
||||||
|
// 下载进度详情 |
||||||
|
ProgressDetail { |
||||||
|
Key string `json:"key"` |
||||||
|
URL string `json:"url"` |
||||||
|
Status string `json:"status"` |
||||||
|
Message string `json:"message"` |
||||||
|
SavedAs string `json:"saved_as,optional"` |
||||||
|
} |
||||||
|
|
||||||
|
// 下载响应 |
||||||
|
DownloadResponse { |
||||||
|
Success bool `json:"success"` |
||||||
|
Message string `json:"message"` |
||||||
|
Title string `json:"title"` |
||||||
|
Folder string `json:"folder"` |
||||||
|
JsonPath string `json:"json_path"` |
||||||
|
Total int `json:"total"` |
||||||
|
Saved int `json:"saved"` |
||||||
|
Skipped int `json:"skipped"` |
||||||
|
Failed int `json:"failed"` |
||||||
|
Details []ProgressDetail `json:"details"` |
||||||
|
} |
||||||
|
) |
||||||
|
|
||||||
|
@server( |
||||||
|
middleware: Cors |
||||||
|
timeout: 300000ms # 添加时间单位ms |
||||||
|
) |
||||||
|
service hd4k_downloader { |
||||||
|
@handler SaveImages |
||||||
|
post /api/save_imgs (DownloadRequest) returns (DownloadResponse) |
||||||
|
} |
||||||
@ -0,0 +1,3 @@ |
|||||||
|
Name: hd4k_downloader |
||||||
|
Host: 0.0.0.0 |
||||||
|
Port: 8888 |
||||||
@ -0,0 +1,5 @@ |
|||||||
|
module hd4k-downloader |
||||||
|
|
||||||
|
go 1.24.7 |
||||||
|
|
||||||
|
require github.com/zeromicro/go-zero v1.9.3 // indirect |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
github.com/zeromicro/go-zero v1.9.3 h1:dJ568uUoRJY0RUxo4aH4htSglbEUF60WiM1MZVkTK9A= |
||||||
|
github.com/zeromicro/go-zero v1.9.3/go.mod h1:JBAtfXQvErk+V7pxzcySR0mW6m2I4KPhNQZGASltDRQ= |
||||||
@ -0,0 +1,34 @@ |
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"flag" |
||||||
|
"fmt" |
||||||
|
|
||||||
|
"hd4k-downloader/internal/config" |
||||||
|
"hd4k-downloader/internal/handler" |
||||||
|
"hd4k-downloader/internal/svc" |
||||||
|
|
||||||
|
"github.com/zeromicro/go-zero/core/conf" |
||||||
|
"github.com/zeromicro/go-zero/rest" |
||||||
|
) |
||||||
|
|
||||||
|
var configFile = flag.String("f", "etc/hd4kdownloader.yaml", "the config file") |
||||||
|
|
||||||
|
func main() { |
||||||
|
flag.Parse() |
||||||
|
|
||||||
|
var c config.Config |
||||||
|
conf.MustLoad(*configFile, &c) |
||||||
|
|
||||||
|
server := rest.MustNewServer(c.RestConf) |
||||||
|
defer server.Stop() |
||||||
|
|
||||||
|
ctx := svc.NewServiceContext(c) |
||||||
|
handler.RegisterHandlers(server, ctx) |
||||||
|
|
||||||
|
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) |
||||||
|
server.Start() |
||||||
|
} |
||||||
@ -0,0 +1,10 @@ |
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package config |
||||||
|
|
||||||
|
import "github.com/zeromicro/go-zero/rest" |
||||||
|
|
||||||
|
type Config struct { |
||||||
|
rest.RestConf |
||||||
|
} |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
// Code scaffolded by goctl. Safe to edit.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package svc |
||||||
|
|
||||||
|
import ( |
||||||
|
"github.com/zeromicro/go-zero/rest" |
||||||
|
"hd4k-downloader/internal/config" |
||||||
|
"hd4k-downloader/internal/middleware" |
||||||
|
) |
||||||
|
|
||||||
|
type ServiceContext struct { |
||||||
|
Config config.Config |
||||||
|
Cors rest.Middleware |
||||||
|
} |
||||||
|
|
||||||
|
func NewServiceContext(c config.Config) *ServiceContext { |
||||||
|
return &ServiceContext{ |
||||||
|
Config: c, |
||||||
|
Cors: middleware.NewCorsMiddleware().Handle, |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,30 @@ |
|||||||
|
// Code generated by goctl. DO NOT EDIT.
|
||||||
|
// goctl 1.9.2
|
||||||
|
|
||||||
|
package types |
||||||
|
|
||||||
|
type DownloadRequest struct { |
||||||
|
Title string `json:"title"` |
||||||
|
Imgs map[string]string `json:"imgs"` |
||||||
|
} |
||||||
|
|
||||||
|
type DownloadResponse struct { |
||||||
|
Success bool `json:"success"` |
||||||
|
Message string `json:"message"` |
||||||
|
Title string `json:"title"` |
||||||
|
Folder string `json:"folder"` |
||||||
|
JsonPath string `json:"json_path"` |
||||||
|
Total int `json:"total"` |
||||||
|
Saved int `json:"saved"` |
||||||
|
Skipped int `json:"skipped"` |
||||||
|
Failed int `json:"failed"` |
||||||
|
Details []ProgressDetail `json:"details"` |
||||||
|
} |
||||||
|
|
||||||
|
type ProgressDetail struct { |
||||||
|
Key string `json:"key"` |
||||||
|
URL string `json:"url"` |
||||||
|
Status string `json:"status"` |
||||||
|
Message string `json:"message"` |
||||||
|
SavedAs string `json:"saved_as,optional"` |
||||||
|
} |
||||||
Loading…
Reference in new issue