AI intergration WIP

This commit is contained in:
Simon Ding
2025-01-07 10:25:52 +08:00
parent 03105a1989
commit 0954632b65
12 changed files with 725 additions and 148 deletions

View File

@@ -24,6 +24,8 @@ const (
SettingMovieSizeLimiter = "movie_size_limiter"
SettingAcceptedVideoFormats = "accepted_video_formats"
SettingAcceptedSubtitleFormats = "accepted_subtitle_formats"
SettingAIConfig = "ai_config"
)
const (
@@ -46,17 +48,18 @@ const (
const DefaultNamingFormat = "{{.NameCN}} {{.NameEN}} {{if .Year}} ({{.Year}}) {{end}}"
//https://en.wikipedia.org/wiki/Video_file_format
// https://en.wikipedia.org/wiki/Video_file_format
var defaultAcceptedVideoFormats = []string{
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts",".ts",
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts", ".ts",
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v",
".svi", ".3gp", ".3g2", ".nsv",
}
var defaultAcceptedSubtitleFormats = []string{
".ass", ".srt",".vtt", ".webvtt", ".sub", ".idx",
".ass", ".srt", ".vtt", ".webvtt", ".sub", ".idx",
}
type NamingInfo struct {
NameCN string
NameEN string
@@ -96,3 +99,9 @@ type ProwlarrSetting struct {
ApiKey string `json:"api_key"`
URL string `json:"url"`
}
type AIConfig struct {
Enabled bool `json:"enabled"`
GeminiApiKey string `json:"gemini_api_key"`
GeminiModelName string `json:"gemini_model_name"`
}

View File

@@ -760,4 +760,25 @@ func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
}
func (c *Client) GetAIConfig() (AIConfig, error) {
cfg := c.GetSetting(SettingAIConfig)
var ai AIConfig
if cfg == "" {
return ai, nil
}
err := json.Unmarshal([]byte(cfg), &ai)
if err != nil {
return AIConfig{}, err
}
return ai, nil
}
func (c *Client) SetAIConfig(cfg *AIConfig) error {
if data, err := json.Marshal(cfg); err != nil {
return err
} else {
return c.SetSetting(SettingAIConfig, string(data))
}
}