Change observability service ports and add Arrtrix content management
- Update ports for Alloy, Grafana, Loki, Prometheus, Promtail, Tempo, and Uptime Kuma to new ranges - Add Arrtrix content management commands and subscriptions - Implement Radarr and Sonarr client logic for movie and series management - Add matrix commands for download and subscription management - Add subscription repository with database schema and logic - Update Arrtrix config and example config for content section - Update help text and command processor to include new commands - Update vendor hash for Arrtrix package
This commit is contained in:
parent
9b93f017b6
commit
e26e25b566
24 changed files with 1340 additions and 82 deletions
|
|
@ -8,13 +8,23 @@ import (
|
|||
up "go.mau.fi/util/configupgrade"
|
||||
"maunium.net/go/mautrix/bridgev2"
|
||||
|
||||
"sneeuwvlok/packages/arrtrix/pkg/arr"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/arrclient"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/subscriptions"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/webhook"
|
||||
)
|
||||
|
||||
//go:embed example-config.yaml
|
||||
var ExampleConfig string
|
||||
|
||||
type Config struct{}
|
||||
type Config struct {
|
||||
Content ContentConfig `yaml:"content"`
|
||||
}
|
||||
|
||||
type ContentConfig struct {
|
||||
Movies arrclient.RadarrConfig `yaml:"movies"`
|
||||
Series arrclient.SonarrConfig `yaml:"series"`
|
||||
}
|
||||
|
||||
func upgradeConfig(helper up.Helper) {}
|
||||
|
||||
|
|
@ -23,6 +33,14 @@ func (s *ArrtrixConnector) GetConfig() (string, any, up.Upgrader) {
|
|||
}
|
||||
|
||||
func (s *ArrtrixConnector) ValidateConfig() error {
|
||||
s.Config.Content.Movies.ApplyDefaults()
|
||||
s.Config.Content.Series.ApplyDefaults()
|
||||
if err := s.Config.Content.Movies.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Config.Content.Series.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +48,27 @@ func (s *ArrtrixConnector) MountRoutes(router *http.ServeMux) error {
|
|||
if s.Bridge == nil {
|
||||
return fmt.Errorf("bridge is not initialized")
|
||||
}
|
||||
return webhook.MountArr(router, s.Bridge)
|
||||
return webhook.MountArr(router, s.Bridge, s.Subscriptions())
|
||||
}
|
||||
|
||||
var _ bridgev2.ConfigValidatingNetwork = (*ArrtrixConnector)(nil)
|
||||
var _ webhook.SubscriptionFilter = (*subscriptions.Repository)(nil)
|
||||
|
||||
func (c ContentConfig) Client(contentType arr.ContentType) (arrclient.Client, bool, error) {
|
||||
switch contentType {
|
||||
case arr.ContentTypeMovies:
|
||||
if !c.Movies.Enabled() {
|
||||
return nil, false, nil
|
||||
}
|
||||
client, err := arrclient.NewRadarrClient(c.Movies)
|
||||
return client, true, err
|
||||
case arr.ContentTypeSeries:
|
||||
if !c.Series.Enabled() {
|
||||
return nil, false, nil
|
||||
}
|
||||
client, err := arrclient.NewSonarrClient(c.Series)
|
||||
return client, true, err
|
||||
default:
|
||||
return nil, false, fmt.Errorf("unsupported content type %q", contentType)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,17 @@ import (
|
|||
"maunium.net/go/mautrix/bridgev2/networkid"
|
||||
"maunium.net/go/mautrix/event"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"sneeuwvlok/packages/arrtrix/pkg/arr"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/arrclient"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/subscriptions"
|
||||
)
|
||||
|
||||
type ArrtrixConnector struct {
|
||||
Bridge *bridgev2.Bridge
|
||||
Config Config
|
||||
Bridge *bridgev2.Bridge
|
||||
Config Config
|
||||
clients map[arr.ContentType]arrclient.Client
|
||||
subscriptions *subscriptions.Repository
|
||||
}
|
||||
|
||||
var _ bridgev2.NetworkConnector = (*ArrtrixConnector)(nil)
|
||||
|
|
@ -33,6 +39,17 @@ func (s *ArrtrixConnector) GetName() bridgev2.BridgeName {
|
|||
|
||||
func (s *ArrtrixConnector) Init(bridge *bridgev2.Bridge) {
|
||||
s.Bridge = bridge
|
||||
s.subscriptions = subscriptions.NewRepository(bridge.DB.Database, string(bridge.ID))
|
||||
s.clients = make(map[arr.ContentType]arrclient.Client)
|
||||
for _, contentType := range arr.SupportedContentTypes() {
|
||||
client, ok, err := s.Config.Content.Client(contentType)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if ok {
|
||||
s.clients[contentType] = client
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *ArrtrixConnector) Start(context.Context) error {
|
||||
|
|
@ -107,3 +124,12 @@ func (c *ArrtrixClient) HandleMatrixMessage(context.Context, *bridgev2.MatrixMes
|
|||
func (c *ArrtrixClient) GenerateTransactionID(userID id.UserID, roomID id.RoomID, eventType event.Type) networkid.RawTransactionID {
|
||||
return networkid.RawTransactionID("")
|
||||
}
|
||||
|
||||
func (s *ArrtrixConnector) ContentClient(contentType arr.ContentType) (arrclient.Client, bool) {
|
||||
client, ok := s.clients[contentType]
|
||||
return client, ok
|
||||
}
|
||||
|
||||
func (s *ArrtrixConnector) Subscriptions() *subscriptions.Repository {
|
||||
return s.subscriptions
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,23 @@
|
|||
# No network-specific config is required yet.
|
||||
#
|
||||
content:
|
||||
movies:
|
||||
# Radarr connection for movie management commands.
|
||||
url: ""
|
||||
api_key: ""
|
||||
root_folder_path: ""
|
||||
quality_profile_id: 0
|
||||
minimum_availability: released
|
||||
search_on_add: true
|
||||
|
||||
series:
|
||||
# Sonarr connection for series management commands.
|
||||
url: ""
|
||||
api_key: ""
|
||||
root_folder_path: ""
|
||||
quality_profile_id: 0
|
||||
language_profile_id: 0
|
||||
season_folder: true
|
||||
series_type: standard
|
||||
search_on_add: true
|
||||
|
||||
# Arr-stack webhooks are exposed automatically on the fixed built-in path:
|
||||
# POST /_arrtrix/webhook
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue