Files
gronod 2d5763d6c6 feat: slim tool responses, drop lyrics search, rename module (1.0.11)
Item-shaped results now omit empty fields and drop low-value metadata
(overview, lyrics, file_path, creation_date, premiere_date, bitrate);
absent numeric fields drop the key instead of emitting "". Player
sessions report hh:mm:ss times only; playlists drop overview/date_created.
The lyrics_or_description search parameter is removed, along with the
unused DTO fields, and upstream Fields requests are slimmed to match.
Module path renamed to git.i3omb.com/gronod/emby-mcp.
2026-09-21 23:54:07 +01:00

47 lines
1.2 KiB
Go

package emby
import (
"context"
"git.i3omb.com/gronod/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
}