Build and publish / Test and build (darwin) (push) Failing after 1m42s
Build and publish / Test and build (linux) (push) Failing after 1m53s
Build and publish / Test and build (windows) (push) Failing after 2m50s
Build and publish / Build and publish Docker image (push) Skipped
Go rewrite of the Python Emby.MCP server with tool parity (20 tools), plus a streamable-HTTP transport with per-request Emby authentication (Basic / Bearer token passthrough), a multi-arch Docker build, and a Gitea CI workflow.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package emby
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/gordon/emby-mcp/internal/textutil"
|
|
)
|
|
|
|
// User is the output shape for users (matches Python output keys).
|
|
type User struct {
|
|
UserName string `json:"user_name"`
|
|
UserID string `json:"user_id"`
|
|
}
|
|
|
|
// GetUsers lists users, optionally filtered by userID or userName.
|
|
func (c *Client) GetUsers(ctx context.Context, userID, userName string) ([]User, error) {
|
|
var list []UserDto
|
|
if userID != "" {
|
|
var u UserDto
|
|
if err := c.Get(ctx, "/Users/"+userID, nil, &u); err != nil {
|
|
return nil, err
|
|
}
|
|
list = []UserDto{u}
|
|
} else {
|
|
if err := c.Get(ctx, "/Users/Public", nil, &list); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
out := make([]User, 0, len(list))
|
|
for _, u := range list {
|
|
if userName != "" && !textutil.EqualFoldASCII(u.Name, userName) {
|
|
continue
|
|
}
|
|
out = append(out, User{UserName: u.Name, UserID: u.ID})
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// GetUser fetches a single user by ID via GET /Users/{id}.
|
|
func (c *Client) GetUser(ctx context.Context, id string) (*User, error) {
|
|
var u UserDto
|
|
if err := c.Get(ctx, "/Users/"+id, nil, &u); err != nil {
|
|
return nil, err
|
|
}
|
|
return &User{UserName: u.Name, UserID: u.ID}, nil
|
|
}
|