internal

package
v0.0.0-...-e5ec5ea Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainTitle     = "main"
	OfficialTitle = "official"
	SynTitle      = "syn"
	ShortTitle    = "short"
)
View Source
const AnidbImageThumb = "https://cdn-us.anidb.net/images/65/%s.jpg-thumb.jpg"
View Source
const AnidbSeriesUrl = "https://anidb.net/anime/%s"
View Source
const AnidbTitles string = "./animetitles.xml"
View Source
const MasterFile string = "./anime-list-master.xml"
View Source
const NumResults string = "4"

Number of TVDB search results to request

View Source
const TmdbRemoteType int64 = 12
View Source
const TodoFile string = "./anime-list-todo.xml"
View Source
const TvdbApiURL string = "https://api4.thetvdb.com/v4"
View Source
const TvdbSeriesUrl string = "https://thetvdb.com/series/%s"

Variables

View Source
var Keys = &KeyMap{
	Commit: key.NewBinding(
		key.WithKeys("enter", "c"),
		key.WithHelp("󰌑/c", "commit"),
	),
	Next: key.NewBinding(
		key.WithKeys("space"),
		key.WithHelp("󱁐", "skip"),
	),
	PrevPage: key.NewBinding(
		key.WithKeys("left", "h"),
	),
	NextPage: key.NewBinding(
		key.WithKeys("right", "l"),
		key.WithHelp("h/l ←/→", "page"),
	),
	Edit: key.NewBinding(
		key.WithKeys("e"),
		key.WithHelp("e", "edit"),
	),
	Lookup: key.NewBinding(
		key.WithKeys("i"),
		key.WithHelp("i", "lookup id"),
	),
	Search: key.NewBinding(
		key.WithKeys("s"),
		key.WithHelp("s", "search tvdb"),
	),
	Open: key.NewBinding(
		key.WithKeys("o"),
		key.WithHelp("o", "browser"),
	),
	Help: key.NewBinding(
		key.WithKeys("?", "ctrl+/"),
		key.WithHelp("?", "toggle help"),
	),
	Lang: key.NewBinding(
		key.WithKeys("f"),
		key.WithHelp("f", "langs"),
	),
	Quit: key.NewBinding(
		key.WithKeys("ctrl+q", "esc", "ctrl+c"),
		key.WithHelp("ctrl+q/esc", "quit"),
	),
}

Functions

func Iso639_3

func Iso639_3(l string) string

Maps the language codes used by AniDB to 3 letter language codes (for TVDB API)

Types

type APIError

type APIError struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Data    string `json:"data,omitempty"`
}

func (*APIError) Error

func (e *APIError) Error() string

type AnidbData

type AnidbData struct {
	Id string
	// Transliterated unique key for AniDB
	MainTitle Title
	// The official title in language matching main title
	OfficialTitle Title
	// All other translations and short/synonym titles
	Titles []Title
}

func (*AnidbData) Display

func (d *AnidbData) Display() string

func (*AnidbData) GetThumb

func (d *AnidbData) GetThumb() (url string)

func (*AnidbData) Url

func (d *AnidbData) Url() (url string)

type AnimeTitles

type AnimeTitles struct {
	// contains filtered or unexported fields
}

func LoadTitles

func LoadTitles(path string) (*AnimeTitles, error)

func (*AnimeTitles) ByID

func (p *AnimeTitles) ByID(id string) (*AnidbData, error)

type Data

type Data interface {
	Display() string
	Url() string
}

func ToData

func ToData[T Data](in []T) []Data

TODO: think of something better than all this jank?

type ErrMsg

type ErrMsg struct {
	Err error
}

type ImageTransmittedMsg

type ImageTransmittedMsg struct {
	// contains filtered or unexported fields
}

type KeyMap

type KeyMap struct {
	Commit   key.Binding
	Next     key.Binding
	NextPage key.Binding
	PrevPage key.Binding
	Lookup   key.Binding
	Search   key.Binding
	Edit     key.Binding
	Lang     key.Binding
	Open     key.Binding
	Quit     key.Binding
	Help     key.Binding
}

KeyMap implements help.KeyMap from the help bubble

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

type LangFilter

type LangFilter uint8
const (
	LangJa  LangFilter = 1 << 0 // 1 0b001
	LangKo  LangFilter = 1 << 1 // 2 0b010
	LangZh  LangFilter = 1 << 2 // 4 0b100
	LangAll LangFilter = LangJa | LangKo | LangZh
)

func (LangFilter) Cycle

func (f LangFilter) Cycle() LangFilter

func (LangFilter) Matches

func (f LangFilter) Matches(lang string) bool

Matches returns true if the language is selected in the filter

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel() Model

func (Model) Init

func (m Model) Init() tea.Cmd

func (*Model) SaveState

func (m *Model) SaveState() error

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() tea.View

type Option

type Option func(*Pane)

func WithPages

func WithPages() Option

type Pane

type Pane struct {
	// contains filtered or unexported fields
}

Pane wraps a viewport to display 1 or more sets of Data

func New

func New(opts ...Option) Pane

func (*Pane) Clear

func (m *Pane) Clear()

func (Pane) Data

func (m Pane) Data() Data

Data returns the currently displayed series Data or nil if none

func (Pane) Init

func (m Pane) Init() tea.Cmd

func (Pane) OpenBrowser

func (m Pane) OpenBrowser() tea.Msg

Open the series site in a browser as a tea.Cmd

func (*Pane) SetData

func (m *Pane) SetData(d ...Data)

func (*Pane) SetErr

func (m *Pane) SetErr(e error)

func (*Pane) SetHeight

func (m *Pane) SetHeight(h int)

func (*Pane) SetWidth

func (m *Pane) SetWidth(w int)

func (Pane) Update

func (m Pane) Update(msg tea.Msg) (Pane, tea.Cmd)

func (*Pane) UpdateViewport

func (m *Pane) UpdateViewport()

UpdateViewport refreshes the display of data content in this pane

func (Pane) View

func (m Pane) View() string

type Poster

type Poster struct {
	Width, Height int
	// contains filtered or unexported fields
}

func NewPoster

func NewPoster() Poster

func (Poster) DeleteImage

func (m Poster) DeleteImage()

DeleteImage frees the associated image from the terminal

func (Poster) DisplayImage

func (m Poster) DisplayImage(url string) tea.Cmd

func (Poster) Init

func (m Poster) Init() tea.Cmd

func (Poster) Update

func (m Poster) Update(msg tea.Msg) (Poster, tea.Cmd)

func (Poster) View

func (m Poster) View() string

type RemoteId

type RemoteId struct {
	Id         string `json:"id"`
	SourceName string `json:"sourceName"`
	// numeric code for each remote source type (e.g. Twitter, TMDB, etc)
	Type int64 `json:"type"`
}

type SearchResult

type SearchResult struct {
	Status string      `json:"status"`
	Data   []*TvdbData `json:"data"`
}

Automatically generated with https://github.com/bashtian/jsonutils

type State

type State int
const (
	Normal State = iota
	Loading
	SearchingAdb
	SearchingTvdb
)

type Styles

type Styles struct {

	// Doc  lg.Style
	Pane lg.Style
	Body lg.Style

	Heading lg.Style
	Title   lg.Style
	Label   lg.Style
	Page    lg.Style

	Filter lg.Style
	Error  lg.Style
	Info   lg.Style
}
var DefaultStyles Styles = Styles{

	Pane: lg.NewStyle().
		Border(lg.RoundedBorder()).
		BorderForeground(lg.Color("245")).
		Padding(1, 1, 0),

	Heading: lg.NewStyle().
		Bold(true).
		PaddingBottom(1).
		Foreground(lg.Magenta),

	Title: lg.NewStyle().
		Bold(true).
		Foreground(lg.BrightYellow),

	Label: lg.NewStyle().
		MarginRight(2).
		Bold(true).
		Foreground(lg.Color("245")),

	Filter: lg.NewStyle().
		Bold(true).
		Padding(0, 1).
		AlignHorizontal(lg.Center).
		Foreground(lg.BrightCyan),

	Info: lg.NewStyle().
		Italic(true).
		Padding(0, 1).
		AlignHorizontal(lg.Left).
		Foreground(lg.White),

	Error: lg.NewStyle().
		Italic(true).
		Padding(0, 1).
		AlignHorizontal(lg.Left).
		Foreground(lg.Red).
		Faint(true),

	Page: lg.NewStyle().Foreground(lg.BrightMagenta).SetString("•"),

	Body: lg.NewStyle().Foreground(lg.NoColor{}),
}

type Title

type Title struct {
	Type  string
	Lang  string
	Value string
}

type TodoIDs

type TodoIDs struct {
	// contains filtered or unexported fields
}

func LoadTodo

func LoadTodo(path string) (*TodoIDs, error)

func (*TodoIDs) Len

func (t *TodoIDs) Len() int

func (*TodoIDs) Pop

func (t *TodoIDs) Pop() (id string, ok bool)

func (*TodoIDs) SaveState

func (t *TodoIDs) SaveState() error

type TvdbClient

type TvdbClient struct {
	*req.Client
	// contains filtered or unexported fields
}

func NewTvdbClient

func NewTvdbClient() *TvdbClient

NewTvdbClient create a TVDB client. Example from https://req.cool/docs/examples/build-sdk-quickly-with-req

func (*TvdbClient) LoginWithKey

func (c *TvdbClient) LoginWithKey(key string) *TvdbClient

func (*TvdbClient) Search

func (c *TvdbClient) Search(query, lang string) ([]*TvdbData, error)

type TvdbData

type TvdbData struct {
	// Numeric id
	Id string `json:"tvdb_id"`
	// Slug is used for direct URL
	Slug         string `json:"slug"`
	Type         string `json:"type"`
	Name         string `json:"name"`
	Status       string `json:"status"`
	FirstAirTime string `json:"first_air_time"`
	Year         string `json:"year"`
	Language     string `json:"primary_language"`
	Country      string `json:"country"`
	Director     string `json:"director"`
	Overview     string `json:"overview"`
	Network      string `json:"network"`
	ImageURL     string `json:"image_url"`
	Thumbnail    string `json:"thumbnail"`
	Overviews    struct {
		Eng string `json:"eng"`
		Jpn string `json:"jpn"`
	}
	Translations struct {
		Eng string `json:"eng"`
		Jpn string `json:"jpn"`
	}
	Aliases   []string   `json:"aliases"`
	Genres    []string   `json:"genres"`
	Studios   []string   `json:"studios"`
	Companies []string   `json:"companies"`
	RemoteIds []RemoteId `json:"remote_ids"`
	// filled later with image data
	ImagePlaceholder string
}

func (*TvdbData) Display

func (d *TvdbData) Display() string

func (*TvdbData) GetThumb

func (d *TvdbData) GetThumb() (url string)

func (*TvdbData) Url

func (d *TvdbData) Url() (url string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL