mediago-dev--mediago
21e232f042
Move ffmpeg execution from Electron to Go Core so conversion works in both Electron and web server modes. Go Core backend: - Add -ffmpeg-bin CLI flag to pass ffmpeg binary path - Enhance Conversion DB model with status, outputPath, outputFormat, quality, progress, and error fields - Create converter executor (service/converter.go) that spawns ffmpeg, builds args per format/quality, and parses stderr for progress - Add StartConversion/StopConversion to service with SSE events for real-time progress (conversion-start/progress/success/failed/stop) - Add POST /api/conversions/:id/start and /:id/stop endpoints Supported formats: - Video: MP4 (H.264), MKV (H.264), WebM (VP9) with CRF quality - Audio: MP3, AAC, FLAC, WAV with bitrate quality presets - Quality presets: high/medium/low mapping to CRF and bitrate values Frontend (converter-page): - Add format selector (Video/Audio groups) and quality dropdown - Show per-item status badge, progress bar during conversion - Action buttons: Start/Stop/Open Folder/Delete based on status - "Convert All" batch button for pending items - SWR auto-refresh during active conversions Integration: - Pass -ffmpeg-bin from Electron and core:dev to Go Core - Remove old broken Electron-only convertToAudio code - Add startConversion/stopConversion to core-sdk and GoApi - Add i18n keys for new UI elements (en/zh) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
50 行
2.7 KiB
Go
50 行
2.7 KiB
Go
package db
|
|
|
|
import "time"
|
|
|
|
// Video maps to the "video" table (legacy naming; actually represents download tasks).
|
|
// Column names must exactly match the table schema created by TypeORM (camelCase).
|
|
type Video struct {
|
|
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
Name string `gorm:"column:name;type:text;not null;uniqueIndex" json:"name"`
|
|
Type string `gorm:"column:type;type:text;not null;default:'m3u8'" json:"type"`
|
|
URL string `gorm:"column:url;type:text;not null" json:"url"`
|
|
Folder *string `gorm:"column:folder;type:text" json:"folder"`
|
|
Headers *string `gorm:"column:headers;type:text" json:"headers"`
|
|
IsLive bool `gorm:"column:isLive;not null;default:0" json:"isLive"`
|
|
Status string `gorm:"column:status;type:text;not null;default:'ready'" json:"status"`
|
|
CreatedDate time.Time `gorm:"column:createdDate;autoCreateTime" json:"createdDate"`
|
|
UpdatedDate time.Time `gorm:"column:updatedDate;autoUpdateTime" json:"updatedDate"`
|
|
}
|
|
|
|
func (Video) TableName() string { return "video" }
|
|
|
|
// Favorite maps to the "favorite" table.
|
|
type Favorite struct {
|
|
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
Title string `gorm:"column:title;type:text;not null" json:"title"`
|
|
URL string `gorm:"column:url;type:text;not null" json:"url"`
|
|
Icon *string `gorm:"column:icon;type:text" json:"icon"`
|
|
CreatedDate time.Time `gorm:"column:createdDate;autoCreateTime" json:"createdDate"`
|
|
UpdatedDate time.Time `gorm:"column:updatedDate;autoUpdateTime" json:"updatedDate"`
|
|
}
|
|
|
|
func (Favorite) TableName() string { return "favorite" }
|
|
|
|
// Conversion maps to the "conversion" table.
|
|
type Conversion struct {
|
|
ID int64 `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
|
|
Name *string `gorm:"column:name;type:text" json:"name"`
|
|
Path string `gorm:"column:path;type:text;not null;default:''" json:"path"`
|
|
Status string `gorm:"column:status;type:text;not null;default:'pending'" json:"status"`
|
|
OutputPath string `gorm:"column:outputPath;type:text;default:''" json:"outputPath"`
|
|
OutputFormat string `gorm:"column:outputFormat;type:text;default:''" json:"outputFormat"`
|
|
Quality string `gorm:"column:quality;type:text;default:'medium'" json:"quality"`
|
|
Progress int `gorm:"column:progress;not null;default:0" json:"progress"`
|
|
Error *string `gorm:"column:error;type:text" json:"error"`
|
|
CreatedDate time.Time `gorm:"column:createdDate;autoCreateTime" json:"createdDate"`
|
|
UpdatedDate time.Time `gorm:"column:updatedDate;autoUpdateTime" json:"updatedDate"`
|
|
}
|
|
|
|
func (Conversion) TableName() string { return "conversion" }
|