mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-03 20:26:36 +08:00
feat: site management + cross-site torrent search
Port the complete site management system from the original MediaStation:
Model:
- model/model.go: Added Site table with fields for name, base_url,
site_type (nexusphp/gazelle/unit3d/mteam/custom_rss), auth_type
(cookie/api_key/authorization), cookie, api_key, auth_header,
user_agent, rss_url, timeout, priority, use_proxy, enabled,
login_status, downloader. Registered in AllModels().
Backend services:
- service/site.go: SiteService with CRUD (Create/List/FindByID/Update/
Delete), TestConnection (validates credentials via HTTP, updates
login_status in DB), and Search (cross-site fan-out that queries
every enabled site adapter and returns merged results sorted by
seeders descending).
- service/site_adapter.go: SiteAdapter interface + NewSiteAdapter
factory + 5 implementations:
* nexusPhpAdapter — regex HTML scraping of torrents.php
* gazelleAdapter — JSON API /ajax.php?action=browse
* unit3dAdapter — REST API /api/torrents/filter
* mteamAdapter — M-Team v3 POST /api/torrent/search with x-api-key
* rssAdapter — XML RSS/Atom feed parsing with keyword filter
Handler + routes:
- handler/sites.go: listSites, getSite, createSite, updateSite,
deleteSite, testSite, siteSearch handlers.
- handler/handler.go: 7 new routes under authed group:
GET/POST /sites, GET/PUT/DELETE /sites/:id,
POST /sites/:id/test, GET /sites/search.
Frontend:
- api/sites.ts: typed interfaces (Site, SiteSearchResult,
CreateSiteInput) and sitesAPI helper.
- pages/SitesPage.tsx: full CRUD UI with add-site form (site_type +
auth_type selectors, cookie/api_key/rss inputs), connection test
button with live status indicator, delete action.
- pages/SiteSearchPage.tsx: cross-site search with keyword input,
merged result table (site/title/size/seeders/leechers/free),
one-click download-to-qBittorrent button.
- App.tsx: lazy-loaded routes /sites and /site-search.
- Layout.tsx: sidebar links 站点管理 + 站点搜索 under 自动化 group.
Verified: go build + go vet + go test pass; tsc -b + vite build passes
(32 lazy chunks, main bundle 255 KB / 85 KB gzipped).
This commit is contained in:
@@ -205,6 +205,30 @@ type AccessLog struct {
|
||||
Detail string `gorm:"type:text" json:"detail"`
|
||||
}
|
||||
|
||||
// Site stores a PT/BT tracker site configuration used by the subscription
|
||||
// and cross-site search system. Mirrors the original MediaStation sites table.
|
||||
//
|
||||
// Supported site types: nexusphp / gazelle / unit3d / mteam / custom_rss
|
||||
// Supported auth types: cookie / api_key / authorization
|
||||
type Site struct {
|
||||
Base
|
||||
Name string `gorm:"size:128;not null" json:"name"`
|
||||
BaseURL string `gorm:"size:512;not null" json:"base_url"`
|
||||
SiteType string `gorm:"size:32;default:nexusphp" json:"site_type"`
|
||||
AuthType string `gorm:"size:32;default:cookie" json:"auth_type"`
|
||||
Cookie string `gorm:"type:text" json:"cookie,omitempty"`
|
||||
APIKey string `gorm:"size:512" json:"api_key,omitempty"`
|
||||
AuthHeader string `gorm:"size:512" json:"auth_header,omitempty"`
|
||||
UserAgent string `gorm:"size:512" json:"user_agent,omitempty"`
|
||||
RSSURL string `gorm:"size:1024" json:"rss_url,omitempty"`
|
||||
Timeout int `gorm:"default:15" json:"timeout"`
|
||||
Priority int `gorm:"default:50" json:"priority"`
|
||||
UseProxy bool `gorm:"default:false" json:"use_proxy"`
|
||||
Enabled bool `gorm:"default:true" json:"enabled"`
|
||||
LoginStatus string `gorm:"size:20;default:unknown" json:"login_status"`
|
||||
Downloader string `gorm:"size:50" json:"downloader,omitempty"`
|
||||
}
|
||||
|
||||
// AllModels returns the slice consumed by gorm.AutoMigrate.
|
||||
func AllModels() []interface{} {
|
||||
return []interface{}{
|
||||
@@ -219,6 +243,7 @@ func AllModels() []interface{} {
|
||||
&DownloadTask{},
|
||||
&Subscription{},
|
||||
&Setting{},
|
||||
&Site{},
|
||||
&AccessLog{},
|
||||
&APIConfig{},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user