76e426c5d3
- Add internal/musicfs package: gRPC client, TriggerRescan (stream consumer), EnrichFiles (BatchUpdateMetadata), DeriveSubdir helper - Add MusicFS config section (enabled, endpoint, origin_id, origin_root, timeout) - Wire MusicFSClient into PollDownloadWorker: on download completion, trigger scoped rescan then push enriched metadata - Fix album auto-persist in monitor workflow: persist artist+album from metadata-agregator before saving torrent/download - Add filterByActiveSeeders: skip torrents where magnet resolution found 0 real active seeders - Add musicfs proto to buf.gen.yaml inputs - Enricher only sends non-empty fields to avoid overwriting existing file tag data with empty values
86 lines
1.8 KiB
Go
86 lines
1.8 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
IndexerTypeJackett IndexerType = "jackett"
|
|
)
|
|
|
|
const (
|
|
TorrentClientQbittorrent TorrentClientType = "qbittorrent"
|
|
)
|
|
|
|
type IndexerType string
|
|
type TorrentClientType string
|
|
|
|
type Config struct {
|
|
App struct {
|
|
Host string `yaml:"host"`
|
|
Port string `yaml:"port"`
|
|
} `yaml:"app"`
|
|
|
|
Database struct {
|
|
URL string `yaml:"url"`
|
|
} `yaml:"database"`
|
|
|
|
Indexer struct {
|
|
Url string `yaml:"url"`
|
|
Port string `yaml:"port"`
|
|
Type IndexerType `yaml:"type"`
|
|
ApiKey string `yaml:"api_key"`
|
|
Cache CacheConfig `yaml:"cache"`
|
|
} `yaml:"indexer"`
|
|
|
|
Torrent struct {
|
|
ClientType TorrentClientType `yaml:"client_type"`
|
|
Url string `yaml:"url"`
|
|
Username string `yaml:"username"`
|
|
Password string `yaml:"password"`
|
|
ContainerName string `yaml:"container_name"`
|
|
} `yaml:"torrent"`
|
|
|
|
Metadata struct {
|
|
Endpoint string `yaml:"endpoint"`
|
|
} `yaml:"metadata"`
|
|
|
|
MusicFS struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
Endpoint string `yaml:"endpoint"`
|
|
OriginID string `yaml:"origin_id"`
|
|
OriginRoot string `yaml:"origin_root"`
|
|
TimeoutSeconds int `yaml:"timeout_seconds"`
|
|
} `yaml:"musicfs"`
|
|
}
|
|
|
|
type CacheConfig struct {
|
|
Enabled bool `yaml:"enabled"`
|
|
RefreshInterval time.Duration `yaml:"refresh_interval"`
|
|
TTL time.Duration `yaml:"ttl"`
|
|
}
|
|
|
|
func (t *IndexerType) UnmarshalYAML(unmarshal func(any) error) error {
|
|
var value string
|
|
if err := unmarshal(&value); err != nil {
|
|
return err
|
|
}
|
|
|
|
switch IndexerType(value) {
|
|
case IndexerTypeJackett:
|
|
*t = IndexerType(value)
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("unknown indexer type: %s", value)
|
|
}
|
|
}
|
|
|
|
func NewConfig() *Config {
|
|
config := Config{}
|
|
config.App.Host = "localhost"
|
|
config.App.Port = "8080"
|
|
|
|
return &config
|
|
}
|