76 lines
2.1 KiB
Go
76 lines
2.1 KiB
Go
package cmd
|
|
|
|
import (
|
|
"encoding/json"
|
|
"os"
|
|
)
|
|
|
|
func writeJSON(v any) error {
|
|
enc := json.NewEncoder(os.Stdout)
|
|
enc.SetIndent("", " ")
|
|
return enc.Encode(v)
|
|
}
|
|
|
|
// JSON output types — lightweight structs for clean, agent-friendly output.
|
|
|
|
type jsonSeries struct {
|
|
Title string `json:"title"`
|
|
Year int `json:"year"`
|
|
Status string `json:"status"`
|
|
TvdbID int `json:"tvdb_id,omitempty"`
|
|
Network string `json:"network,omitempty"`
|
|
SeasonCount int `json:"season_count,omitempty"`
|
|
EpisodesHave int `json:"episodes_have,omitempty"`
|
|
EpisodesTotal int `json:"episodes_total,omitempty"`
|
|
NextAiring string `json:"next_airing,omitempty"`
|
|
Overview string `json:"overview,omitempty"`
|
|
Added string `json:"added,omitempty"`
|
|
}
|
|
|
|
type jsonMovie struct {
|
|
Title string `json:"title"`
|
|
Year int `json:"year"`
|
|
Status string `json:"status"`
|
|
ImdbID string `json:"imdb_id,omitempty"`
|
|
Studio string `json:"studio,omitempty"`
|
|
Runtime int `json:"runtime,omitempty"`
|
|
HasFile bool `json:"has_file"`
|
|
File string `json:"file,omitempty"`
|
|
Size int64 `json:"size_bytes,omitempty"`
|
|
Quality string `json:"quality,omitempty"`
|
|
Overview string `json:"overview,omitempty"`
|
|
Added string `json:"added,omitempty"`
|
|
}
|
|
|
|
type jsonProfile struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type jsonRootFolder struct {
|
|
ID int `json:"id"`
|
|
Path string `json:"path"`
|
|
FreeSpace int64 `json:"free_space_bytes"`
|
|
FreeHuman string `json:"free_space"`
|
|
}
|
|
|
|
type jsonAdded struct {
|
|
Status string `json:"status"`
|
|
Title string `json:"title"`
|
|
Year int `json:"year"`
|
|
TvdbID int `json:"tvdb_id,omitempty"`
|
|
ImdbID string `json:"imdb_id,omitempty"`
|
|
}
|
|
|
|
type jsonSuggestions struct {
|
|
Error string `json:"error"`
|
|
Suggestions []jsonSuggestion `json:"suggestions"`
|
|
}
|
|
|
|
type jsonSuggestion struct {
|
|
Title string `json:"title"`
|
|
Year int `json:"year"`
|
|
TvdbID int `json:"tvdb_id,omitempty"`
|
|
ImdbID string `json:"imdb_id,omitempty"`
|
|
}
|