2020-11-02 00:53:08 +00:00
|
|
|
package jfapi
|
2020-07-29 21:11:28 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"compress/gzip"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
2020-09-16 15:55:04 +00:00
|
|
|
"strings"
|
2020-07-29 21:11:28 +00:00
|
|
|
"time"
|
2020-11-02 00:53:08 +00:00
|
|
|
|
|
|
|
"github.com/hrfee/jfa-go/common"
|
2020-07-29 21:11:28 +00:00
|
|
|
)
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
type serverInfo struct {
|
2020-07-29 21:11:28 +00:00
|
|
|
LocalAddress string `json:"LocalAddress"`
|
|
|
|
Name string `json:"ServerName"`
|
|
|
|
Version string `json:"Version"`
|
2020-11-02 00:53:08 +00:00
|
|
|
OS string `json:"OperatingSystem"`
|
|
|
|
ID string `json:"Id"`
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// Jellyfin represents a running Jellyfin instance.
|
2020-07-29 21:11:28 +00:00
|
|
|
type Jellyfin struct {
|
2020-11-02 00:53:08 +00:00
|
|
|
Server string
|
|
|
|
client string
|
|
|
|
version string
|
|
|
|
device string
|
|
|
|
deviceID string
|
|
|
|
useragent string
|
|
|
|
auth string
|
|
|
|
header map[string]string
|
|
|
|
ServerInfo serverInfo
|
|
|
|
Username string
|
|
|
|
password string
|
|
|
|
Authenticated bool
|
|
|
|
AccessToken string
|
|
|
|
userID string
|
|
|
|
httpClient *http.Client
|
|
|
|
loginParams map[string]string
|
|
|
|
userCache []map[string]interface{}
|
|
|
|
CacheExpiry time.Time
|
|
|
|
cacheLength int
|
|
|
|
noFail bool
|
2020-12-18 15:44:19 +00:00
|
|
|
Hyphens bool
|
2020-11-02 00:53:08 +00:00
|
|
|
timeoutHandler common.TimeoutHandler
|
2020-08-01 20:20:02 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// NewJellyfin returns a new Jellyfin object.
|
2020-11-02 23:26:46 +00:00
|
|
|
func NewJellyfin(server, client, version, device, deviceID string, timeoutHandler common.TimeoutHandler, cacheTimeout int) (*Jellyfin, error) {
|
2020-08-30 19:44:10 +00:00
|
|
|
jf := &Jellyfin{}
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.Server = server
|
2020-07-29 21:11:28 +00:00
|
|
|
jf.client = client
|
|
|
|
jf.version = version
|
|
|
|
jf.device = device
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.deviceID = deviceID
|
2020-07-29 21:11:28 +00:00
|
|
|
jf.useragent = fmt.Sprintf("%s/%s", client, version)
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.timeoutHandler = timeoutHandler
|
2020-11-29 18:01:10 +00:00
|
|
|
jf.auth = fmt.Sprintf("MediaBrowser Client=\"%s\", Device=\"%s\", DeviceId=\"%s\", Version=\"%s\"", client, device, deviceID, version)
|
2020-07-29 21:11:28 +00:00
|
|
|
jf.header = map[string]string{
|
|
|
|
"Accept": "application/json",
|
|
|
|
"Content-type": "application/json; charset=UTF-8",
|
|
|
|
"X-Application": jf.useragent,
|
|
|
|
"Accept-Charset": "UTF-8,*",
|
|
|
|
"Accept-Encoding": "gzip",
|
|
|
|
"User-Agent": jf.useragent,
|
|
|
|
"X-Emby-Authorization": jf.auth,
|
|
|
|
}
|
2020-08-01 20:20:02 +00:00
|
|
|
jf.httpClient = &http.Client{
|
2020-07-29 21:11:28 +00:00
|
|
|
Timeout: 10 * time.Second,
|
|
|
|
}
|
2020-11-02 00:53:08 +00:00
|
|
|
infoURL := fmt.Sprintf("%s/System/Info/Public", server)
|
|
|
|
req, _ := http.NewRequest("GET", infoURL, nil)
|
2020-07-29 21:11:28 +00:00
|
|
|
resp, err := jf.httpClient.Do(req)
|
2020-11-02 00:53:08 +00:00
|
|
|
defer jf.timeoutHandler()
|
2020-07-29 21:11:28 +00:00
|
|
|
if err == nil {
|
|
|
|
data, _ := ioutil.ReadAll(resp.Body)
|
2020-11-02 00:53:08 +00:00
|
|
|
json.Unmarshal(data, &jf.ServerInfo)
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
2020-11-02 23:26:46 +00:00
|
|
|
jf.cacheLength = cacheTimeout
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.CacheExpiry = time.Now()
|
2020-08-30 19:44:10 +00:00
|
|
|
return jf, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// Authenticate attempts to authenticate using a username & password
|
|
|
|
func (jf *Jellyfin) Authenticate(username, password string) (map[string]interface{}, int, error) {
|
|
|
|
jf.Username = username
|
2020-07-29 21:11:28 +00:00
|
|
|
jf.password = password
|
|
|
|
jf.loginParams = map[string]string{
|
|
|
|
"Username": username,
|
|
|
|
"Pw": password,
|
2020-08-01 23:05:35 +00:00
|
|
|
"Password": password,
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
2020-08-01 23:05:35 +00:00
|
|
|
buffer := &bytes.Buffer{}
|
|
|
|
encoder := json.NewEncoder(buffer)
|
|
|
|
encoder.SetEscapeHTML(false)
|
|
|
|
err := encoder.Encode(jf.loginParams)
|
|
|
|
if err != nil {
|
|
|
|
return nil, 0, err
|
|
|
|
}
|
|
|
|
// loginParams, _ := json.Marshal(jf.loginParams)
|
2020-11-02 00:53:08 +00:00
|
|
|
url := fmt.Sprintf("%s/Users/authenticatebyname", jf.Server)
|
2020-08-01 23:05:35 +00:00
|
|
|
req, err := http.NewRequest("POST", url, buffer)
|
2020-11-02 00:53:08 +00:00
|
|
|
defer jf.timeoutHandler()
|
2020-08-01 20:20:02 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, 0, err
|
|
|
|
}
|
2020-07-29 21:11:28 +00:00
|
|
|
for name, value := range jf.header {
|
|
|
|
req.Header.Add(name, value)
|
|
|
|
}
|
|
|
|
resp, err := jf.httpClient.Do(req)
|
|
|
|
if err != nil || resp.StatusCode != 200 {
|
2020-07-31 11:48:37 +00:00
|
|
|
return nil, resp.StatusCode, err
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
var data io.Reader
|
|
|
|
switch resp.Header.Get("Content-Encoding") {
|
|
|
|
case "gzip":
|
|
|
|
data, _ = gzip.NewReader(resp.Body)
|
|
|
|
default:
|
|
|
|
data = resp.Body
|
|
|
|
}
|
|
|
|
var respData map[string]interface{}
|
|
|
|
json.NewDecoder(data).Decode(&respData)
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.AccessToken = respData["AccessToken"].(string)
|
2020-07-31 11:48:37 +00:00
|
|
|
user := respData["User"].(map[string]interface{})
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.userID = respData["User"].(map[string]interface{})["Id"].(string)
|
|
|
|
jf.auth = fmt.Sprintf("MediaBrowser Client=\"%s\", Device=\"%s\", DeviceId=\"%s\", Version=\"%s\", Token=\"%s\"", jf.client, jf.device, jf.deviceID, jf.version, jf.AccessToken)
|
2020-07-29 21:11:28 +00:00
|
|
|
jf.header["X-Emby-Authorization"] = jf.auth
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.Authenticated = true
|
2020-07-31 11:48:37 +00:00
|
|
|
return user, resp.StatusCode, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
func (jf *Jellyfin) get(url string, params map[string]string) (string, int, error) {
|
2020-07-29 21:11:28 +00:00
|
|
|
var req *http.Request
|
|
|
|
if params != nil {
|
|
|
|
jsonParams, _ := json.Marshal(params)
|
|
|
|
req, _ = http.NewRequest("GET", url, bytes.NewBuffer(jsonParams))
|
|
|
|
} else {
|
|
|
|
req, _ = http.NewRequest("GET", url, nil)
|
|
|
|
}
|
|
|
|
for name, value := range jf.header {
|
|
|
|
req.Header.Add(name, value)
|
|
|
|
}
|
|
|
|
resp, err := jf.httpClient.Do(req)
|
2020-11-02 00:53:08 +00:00
|
|
|
defer jf.timeoutHandler()
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || resp.StatusCode != 200 {
|
2020-11-02 00:53:08 +00:00
|
|
|
if resp.StatusCode == 401 && jf.Authenticated {
|
|
|
|
jf.Authenticated = false
|
|
|
|
_, _, authErr := jf.Authenticate(jf.Username, jf.password)
|
2020-07-29 21:11:28 +00:00
|
|
|
if authErr == nil {
|
2020-11-02 00:53:08 +00:00
|
|
|
v1, v2, v3 := jf.get(url, params)
|
2020-07-29 21:11:28 +00:00
|
|
|
return v1, v2, v3
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
return "", resp.StatusCode, err
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
var data io.Reader
|
2020-09-16 15:55:04 +00:00
|
|
|
encoding := resp.Header.Get("Content-Encoding")
|
|
|
|
switch encoding {
|
2020-07-29 21:11:28 +00:00
|
|
|
case "gzip":
|
|
|
|
data, _ = gzip.NewReader(resp.Body)
|
|
|
|
default:
|
|
|
|
data = resp.Body
|
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
buf := new(strings.Builder)
|
|
|
|
io.Copy(buf, data)
|
2020-07-29 21:11:28 +00:00
|
|
|
//var respData map[string]interface{}
|
|
|
|
//json.NewDecoder(data).Decode(&respData)
|
2020-09-16 15:55:04 +00:00
|
|
|
return buf.String(), resp.StatusCode, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
func (jf *Jellyfin) post(url string, data map[string]interface{}, response bool) (string, int, error) {
|
2020-07-29 21:11:28 +00:00
|
|
|
params, _ := json.Marshal(data)
|
|
|
|
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(params))
|
|
|
|
for name, value := range jf.header {
|
|
|
|
req.Header.Add(name, value)
|
|
|
|
}
|
|
|
|
resp, err := jf.httpClient.Do(req)
|
2020-11-02 00:53:08 +00:00
|
|
|
defer jf.timeoutHandler()
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || resp.StatusCode != 200 {
|
2020-11-02 00:53:08 +00:00
|
|
|
if resp.StatusCode == 401 && jf.Authenticated {
|
|
|
|
jf.Authenticated = false
|
|
|
|
_, _, authErr := jf.Authenticate(jf.Username, jf.password)
|
2020-07-29 21:11:28 +00:00
|
|
|
if authErr == nil {
|
2020-11-02 00:53:08 +00:00
|
|
|
v1, v2, v3 := jf.post(url, data, response)
|
2020-07-29 21:11:28 +00:00
|
|
|
return v1, v2, v3
|
|
|
|
}
|
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
return "", resp.StatusCode, err
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
if response {
|
|
|
|
defer resp.Body.Close()
|
|
|
|
var outData io.Reader
|
|
|
|
switch resp.Header.Get("Content-Encoding") {
|
|
|
|
case "gzip":
|
|
|
|
outData, _ = gzip.NewReader(resp.Body)
|
|
|
|
default:
|
|
|
|
outData = resp.Body
|
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
buf := new(strings.Builder)
|
|
|
|
io.Copy(buf, outData)
|
|
|
|
return buf.String(), resp.StatusCode, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
return "", resp.StatusCode, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// DeleteUser deletes the user corresponding to the provided ID.
|
2020-12-18 15:44:19 +00:00
|
|
|
func (jf *Jellyfin) DeleteUser(userID string) (int, error) {
|
|
|
|
url := fmt.Sprintf("%s/Users/%s", jf.Server, userID)
|
2020-09-17 22:50:07 +00:00
|
|
|
req, _ := http.NewRequest("DELETE", url, nil)
|
|
|
|
for name, value := range jf.header {
|
|
|
|
req.Header.Add(name, value)
|
|
|
|
}
|
|
|
|
resp, err := jf.httpClient.Do(req)
|
2020-11-02 00:53:08 +00:00
|
|
|
defer jf.timeoutHandler()
|
2020-09-17 22:50:07 +00:00
|
|
|
return resp.StatusCode, err
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// GetUsers returns all (visible) users on the Jellyfin instance.
|
|
|
|
func (jf *Jellyfin) GetUsers(public bool) ([]map[string]interface{}, int, error) {
|
2020-07-29 21:11:28 +00:00
|
|
|
var result []map[string]interface{}
|
2020-09-16 15:55:04 +00:00
|
|
|
var data string
|
2020-07-29 21:11:28 +00:00
|
|
|
var status int
|
|
|
|
var err error
|
2020-11-02 00:53:08 +00:00
|
|
|
if time.Now().After(jf.CacheExpiry) {
|
2020-08-16 15:08:37 +00:00
|
|
|
if public {
|
2020-11-02 00:53:08 +00:00
|
|
|
url := fmt.Sprintf("%s/users/public", jf.Server)
|
|
|
|
data, status, err = jf.get(url, nil)
|
2020-08-16 15:08:37 +00:00
|
|
|
} else {
|
2020-11-02 00:53:08 +00:00
|
|
|
url := fmt.Sprintf("%s/users", jf.Server)
|
|
|
|
data, status, err = jf.get(url, jf.loginParams)
|
2020-08-16 15:08:37 +00:00
|
|
|
}
|
|
|
|
if err != nil || status != 200 {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
2020-09-16 15:55:04 +00:00
|
|
|
json.Unmarshal([]byte(data), &result)
|
2020-08-16 15:08:37 +00:00
|
|
|
jf.userCache = result
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.CacheExpiry = time.Now().Add(time.Minute * time.Duration(jf.cacheLength))
|
2020-12-18 15:44:19 +00:00
|
|
|
if id, ok := result[0]["Id"]; ok {
|
|
|
|
if id.(string)[8] == '-' {
|
|
|
|
jf.Hyphens = true
|
|
|
|
}
|
|
|
|
}
|
2020-08-16 15:08:37 +00:00
|
|
|
return result, status, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
2020-09-16 16:36:14 +00:00
|
|
|
return jf.userCache, 200, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// UserByName returns the user corresponding to the provided username.
|
|
|
|
func (jf *Jellyfin) UserByName(username string, public bool) (map[string]interface{}, int, error) {
|
2020-09-16 18:19:04 +00:00
|
|
|
var match map[string]interface{}
|
|
|
|
find := func() (map[string]interface{}, int, error) {
|
2020-11-02 00:53:08 +00:00
|
|
|
users, status, err := jf.GetUsers(public)
|
2020-09-16 18:19:04 +00:00
|
|
|
if err != nil || status != 200 {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
for _, user := range users {
|
|
|
|
if user["Name"].(string) == username {
|
|
|
|
return user, status, err
|
|
|
|
}
|
|
|
|
}
|
2020-07-29 21:11:28 +00:00
|
|
|
return nil, status, err
|
|
|
|
}
|
2020-09-16 18:19:04 +00:00
|
|
|
match, status, err := find()
|
|
|
|
if match == nil {
|
2020-11-02 00:53:08 +00:00
|
|
|
jf.CacheExpiry = time.Now()
|
2020-09-16 18:19:04 +00:00
|
|
|
match, status, err = find()
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
2020-09-16 18:19:04 +00:00
|
|
|
return match, status, err
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// UserByID returns the user corresponding to the provided ID.
|
|
|
|
func (jf *Jellyfin) UserByID(userID string, public bool) (map[string]interface{}, int, error) {
|
|
|
|
if jf.CacheExpiry.After(time.Now()) {
|
2020-08-16 15:08:37 +00:00
|
|
|
for _, user := range jf.userCache {
|
2020-11-02 00:53:08 +00:00
|
|
|
if user["Id"].(string) == userID {
|
2020-08-16 15:08:37 +00:00
|
|
|
return user, 200, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-29 21:11:28 +00:00
|
|
|
if public {
|
2020-11-02 00:53:08 +00:00
|
|
|
users, status, err := jf.GetUsers(public)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || status != 200 {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
for _, user := range users {
|
2020-11-02 00:53:08 +00:00
|
|
|
if user["Id"].(string) == userID {
|
2020-07-29 21:11:28 +00:00
|
|
|
return user, status, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil, status, err
|
|
|
|
}
|
2020-11-02 00:53:08 +00:00
|
|
|
var result map[string]interface{}
|
|
|
|
var data string
|
|
|
|
var status int
|
|
|
|
var err error
|
|
|
|
url := fmt.Sprintf("%s/users/%s", jf.Server, userID)
|
|
|
|
data, status, err = jf.get(url, jf.loginParams)
|
|
|
|
if err != nil || status != 200 {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
json.Unmarshal([]byte(data), &result)
|
|
|
|
return result, status, nil
|
2020-07-29 21:11:28 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// NewUser creates a new user with the provided username and password.
|
|
|
|
func (jf *Jellyfin) NewUser(username, password string) (map[string]interface{}, int, error) {
|
|
|
|
url := fmt.Sprintf("%s/Users/New", jf.Server)
|
2020-07-29 21:11:28 +00:00
|
|
|
stringData := map[string]string{
|
|
|
|
"Name": username,
|
|
|
|
"Password": password,
|
|
|
|
}
|
|
|
|
data := make(map[string]interface{})
|
|
|
|
for key, value := range stringData {
|
|
|
|
data[key] = value
|
|
|
|
}
|
2020-11-02 00:53:08 +00:00
|
|
|
response, status, err := jf.post(url, data, true)
|
2020-07-29 21:11:28 +00:00
|
|
|
var recv map[string]interface{}
|
2020-09-16 15:55:04 +00:00
|
|
|
json.Unmarshal([]byte(response), &recv)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || !(status == 200 || status == 204) {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
return recv, status, nil
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// SetPolicy sets the access policy for the user corresponding to the provided ID.
|
|
|
|
func (jf *Jellyfin) SetPolicy(userID string, policy map[string]interface{}) (int, error) {
|
|
|
|
url := fmt.Sprintf("%s/Users/%s/Policy", jf.Server, userID)
|
|
|
|
_, status, err := jf.post(url, policy, false)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || status != 200 {
|
|
|
|
return status, err
|
|
|
|
}
|
|
|
|
return status, nil
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// SetConfiguration sets the configuration (part of homescreen layout) for the user corresponding to the provided ID.
|
|
|
|
func (jf *Jellyfin) SetConfiguration(userID string, configuration map[string]interface{}) (int, error) {
|
|
|
|
url := fmt.Sprintf("%s/Users/%s/Configuration", jf.Server, userID)
|
|
|
|
_, status, err := jf.post(url, configuration, false)
|
2020-07-29 21:11:28 +00:00
|
|
|
return status, err
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// GetDisplayPreferences gets the displayPreferences (part of homescreen layout) for the user corresponding to the provided ID.
|
|
|
|
func (jf *Jellyfin) GetDisplayPreferences(userID string) (map[string]interface{}, int, error) {
|
|
|
|
url := fmt.Sprintf("%s/DisplayPreferences/usersettings?userId=%s&client=emby", jf.Server, userID)
|
|
|
|
data, status, err := jf.get(url, nil)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || !(status == 204 || status == 200) {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
var displayprefs map[string]interface{}
|
2020-09-16 15:55:04 +00:00
|
|
|
err = json.Unmarshal([]byte(data), &displayprefs)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, status, err
|
|
|
|
}
|
|
|
|
return displayprefs, status, nil
|
|
|
|
}
|
|
|
|
|
2020-11-02 00:53:08 +00:00
|
|
|
// SetDisplayPreferences sets the displayPreferences (part of homescreen layout) for the user corresponding to the provided ID.
|
|
|
|
func (jf *Jellyfin) SetDisplayPreferences(userID string, displayprefs map[string]interface{}) (int, error) {
|
|
|
|
url := fmt.Sprintf("%s/DisplayPreferences/usersettings?userId=%s&client=emby", jf.Server, userID)
|
|
|
|
_, status, err := jf.post(url, displayprefs, false)
|
2020-07-29 21:11:28 +00:00
|
|
|
if err != nil || !(status == 204 || status == 200) {
|
|
|
|
return status, err
|
|
|
|
}
|
|
|
|
return status, nil
|
|
|
|
}
|