more Jellyfin integration work
This commit is contained in:
+39
-17
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user