more Jellyfin integration work

This commit is contained in:
Drew Weymouth
2023-11-14 09:05:02 -08:00
parent c8255517f6
commit 2867d13498
8 changed files with 416 additions and 24 deletions
+39 -17
View File
@@ -6,9 +6,12 @@ import (
"net/http"
"time"
"github.com/dweymouth/go-jellyfin"
"github.com/dweymouth/go-subsonic/subsonic"
"github.com/dweymouth/supersonic/backend/mediaprovider"
jellyfinMP "github.com/dweymouth/supersonic/backend/mediaprovider/jellyfin"
subsonicMP "github.com/dweymouth/supersonic/backend/mediaprovider/subsonic"
"github.com/dweymouth/supersonic/res"
"github.com/google/uuid"
"github.com/zalando/go-keyring"
)
@@ -159,23 +162,42 @@ func (s *ServerManager) SetServerPassword(server *ServerConfig, password string)
func (s *ServerManager) connect(connection ServerConnection, password string) (mediaprovider.Server, error) {
var cli, altCli mediaprovider.Server
cli = &subsonicMP.SubsonicServer{
Client: subsonic.Client{
Client: &http.Client{Timeout: 10 * time.Second},
BaseUrl: connection.Hostname,
User: connection.Username,
PasswordAuth: connection.LegacyAuth,
ClientName: "supersonic",
},
}
altCli = &subsonicMP.SubsonicServer{
Client: subsonic.Client{
Client: &http.Client{Timeout: 10 * time.Second},
BaseUrl: connection.AltHostname,
User: connection.Username,
PasswordAuth: connection.LegacyAuth,
ClientName: "supersonic",
},
if connection.ServerType == ServerTypeJellyfin {
cli = &jellyfinMP.JellyfinServer{
Client: jellyfin.Client{
HTTPClient: &http.Client{Timeout: 10 * time.Second},
BaseURL: connection.Hostname,
ClientName: res.AppName,
ClientVersion: res.AppVersion,
},
}
altCli = &jellyfinMP.JellyfinServer{
Client: jellyfin.Client{
HTTPClient: &http.Client{Timeout: 10 * time.Second},
BaseURL: connection.AltHostname,
ClientName: res.AppName,
ClientVersion: res.AppVersion,
},
}
} else {
cli = &subsonicMP.SubsonicServer{
Client: subsonic.Client{
Client: &http.Client{Timeout: 10 * time.Second},
BaseUrl: connection.Hostname,
User: connection.Username,
PasswordAuth: connection.LegacyAuth,
ClientName: res.AppName,
},
}
altCli = &subsonicMP.SubsonicServer{
Client: subsonic.Client{
Client: &http.Client{Timeout: 10 * time.Second},
BaseUrl: connection.AltHostname,
User: connection.Username,
PasswordAuth: connection.LegacyAuth,
ClientName: res.AppName,
},
}
}
pingChan := make(chan bool, 2) // false for primary hostname, true for alternate
pingFunc := func(delay time.Duration, cli mediaprovider.Server, val bool) {