internal

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LinkPriorities = []string{
	"sharepoint.com",
	"wixmp.com",
	"dropbox.com",
	"wetransfer.com",
	"gogoanime.com",
}

LinkPriorities defines the order of priority for link domains

Functions

func AddAnimeToList added in v1.1.7

func AddAnimeToList(animeID int, status string, token string) error

AddAnimeToList adds an anime to a specified list (CURRENT, PLANNING, PAUSED, DROPPED)

func AddAnimeToWatchingList

func AddAnimeToWatchingList(animeID int, token string) error

Function to add an anime to the watching list

func ChangeToken added in v0.0.6

func ChangeToken(config *CurdConfig, user *User)

func CheckAndDownloadFiles added in v0.0.7

func CheckAndDownloadFiles(storagePath string, filesToCheck []string) error

func ClearLogFile

func ClearLogFile(logFile string) error

ClearLogFile removes all contents from the specified log file

func ClearScreen

func ClearScreen()

ClearScreen clears the terminal screen and saves the state

func ConvertSecondsToMinutes

func ConvertSecondsToMinutes(seconds int) int

func CurdOut added in v0.0.5

func CurdOut(data interface{})

func DiscordPresence

func DiscordPresence(anime Anime, IsPaused bool, currentPosition int, totalDuration int, clientId string) error

func DiscordPresenceWithForce added in v1.1.7

func DiscordPresenceWithForce(anime Anime, IsPaused bool, currentPosition int, totalDuration int, clientId string, forceUpdate bool) error

func EditConfig

func EditConfig(configFilePath string)

func EpisodesList

func EpisodesList(showID, mode string) ([]string, error)

episodesList performs the API call and fetches the episodes list

func ExitCurd

func ExitCurd(err error)

func ExitMPV added in v1.1.0

func ExitMPV(ipcSocketPath string) error

func FetchFillerEpisodes added in v1.0.8

func FetchFillerEpisodes(malID int) ([]int, error)

func FindKeyByValue

func FindKeyByValue(m map[string]string, value string) (string, error)

FindKeyByValue searches for a key associated with a given value in a map[string]string

func FindSequelInAnimeList added in v1.1.7

func FindSequelInAnimeList(list AnimeList, sequelID int) (string, bool)

FindSequelInAnimeList searches for a sequel in the user's anime list and returns its status

func FormatTime added in v1.0.4

func FormatTime(seconds int) string

func GetAndParseAniSkipData

func GetAndParseAniSkipData(animeMalId int, episode int, timePrecision int, anime *Anime) error

GetAndParseAniSkipData fetches and parses skip times for a given anime ID and episode

func GetAniSkipData

func GetAniSkipData(animeMalId int, episode int) (string, error)

GetAniSkipData fetches skip times data for a given anime ID and episode

func GetAnilistUserID

func GetAnilistUserID(token string) (int, string, error)

Function to get AniList user ID and username

func GetAnimeIDAndImage

func GetAnimeIDAndImage(anilistMediaID int) (int, string, error)

This function retrieves the MAL ID and cover image URL for an anime from AniList

func GetAnimeMalID

func GetAnimeMalID(anilistMediaID int) (int, error)

Function to get MAL ID using AniList media ID

func GetAnimeMap

func GetAnimeMap(animeList AnimeList) map[string]string

GetAnimeMap takes an AnimeList and returns a map with media.id as key and media.title.english as value.

func GetAnimeMapPreview added in v0.0.7

func GetAnimeMapPreview(animeList AnimeList) map[string]RofiSelectPreview

GetAnimeMapPreview takes an AnimeList and returns a map with media.id as key and media.title.english as value.

func GetAnimeName

func GetAnimeName(anime Anime) string

Function to get the anime name (English or Romaji) from an Anime struct

func GetEpisodeData

func GetEpisodeData(animeID int, episodeNo int, anime *Anime) error

GetEpisodeData fetches episode data for a given anime ID and episode number

func GetEpisodeURL

func GetEpisodeURL(config CurdConfig, id string, epNo int) ([]string, error)

Get anime episode url respective to given config If the link is found, it returns a list of links. Otherwise, it returns an error.

Parameters: - config: Configuration of the anime search. - id: Allanime id of the anime to search for. - epNo: Anime episode number to get links for.

Returns: - []string: a list of links for specified episode. - error: an error if the episode is not found or if there is an issue during the search.

func GetGlobalLogFile added in v1.0.9

func GetGlobalLogFile() string

GetGlobalLogFile gets the global log file path

func GetMPVPausedStatus

func GetMPVPausedStatus(ipcSocketPath string) (bool, error)

func GetMPVPlaybackSpeed

func GetMPVPlaybackSpeed(ipcSocketPath string) (float64, error)

func GetNextCanonEpisode added in v1.0.8

func GetNextCanonEpisode(fillerEpisodes []int, currentEpisode int) int

GetNextCanonEpisode returns the next non-filler episode number after the current episode

func GetPercentageWatched

func GetPercentageWatched(ipcSocketPath string) (float64, error)

func GetTokenFromFile

func GetTokenFromFile(tokenPath string) (string, error)

GetTokenFromFile loads the token from the token file (supports both old text format and new JSON format)

func GetTokenFromRofi added in v0.0.6

func GetTokenFromRofi() (string, error)

func GetUserData

func GetUserData(token string, userID int) (map[string]interface{}, error)

Function to get user data from AniList

func GetUserDataPreview added in v0.0.7

func GetUserDataPreview(token string, userID int) (map[string]interface{}, error)

func GetUserInputFromRofi added in v0.0.6

func GetUserInputFromRofi(message string) (string, error)

GetUserInputFromRofi prompts the user for input using Rofi with a custom message

func HandleLastEpisodeCompletion added in v1.1.4

func HandleLastEpisodeCompletion(userCurdConfig *CurdConfig, anime *Anime, userToken string)

HandleLastEpisodeCompletion handles scoring and completion for the last episode

func HasActivePlayback added in v1.0.7

func HasActivePlayback(ipcSocketPath string) (bool, error)

func IsEpisodeFiller added in v1.0.8

func IsEpisodeFiller(fillerEpisodes []int, episodeNumber int) bool

IsEpisodeFiller checks if a given episode number is in the filler episodes list

func IsMPVRunning added in v1.0.7

func IsMPVRunning(socketPath string) bool

func LoadConfigFromFile added in v1.1.4

func LoadConfigFromFile(path string) (map[string]string, error)

LoadConfigFromFile loads config file from disk into a map (key=value format)

func LoadJSONFile

func LoadJSONFile(filePath string) (map[string]interface{}, error)

Function to load a JSON file

func LocalAddAnime

func LocalAddAnime(databaseFile string, anilistID int, allanimeID string, watchingEpisode int, watchingTime int, animeDuration int, animeName string)

Function to add an anime entry

func LocalDeleteAnime

func LocalDeleteAnime(databaseFile string, anilistID int, allanimeID string)

Function to delete an anime entry by Anilist ID and Allanime ID

func LocalUpdateAnime

func LocalUpdateAnime(databaseFile string, anilistID int, allanimeID string, watchingEpisode int, playbackTime int, animeDuration int, animeName string) error

Function to update or add a new anime entry

func Log

func Log(data interface{}) error

LogData logs the input data into a specified log file with the format [LOG] time lineNumber: logData

func LoginClient added in v1.1.2

func LoginClient(clientId string) error

func LogoutClient added in v1.1.7

func LogoutClient() error

func MPVSendCommand

func MPVSendCommand(ipcSocketPath string, command []interface{}) (interface{}, error)

func NextEpisodePromptCLI added in v1.1.4

func NextEpisodePromptCLI(userCurdConfig *CurdConfig) bool

func NextEpisodePromptContinuous added in v1.1.4

func NextEpisodePromptContinuous(userCurdConfig *CurdConfig, databaseFile string, userToken string)

NextEpisodePromptContinuous provides a continuous next episode prompt for CLI mode This runs throughout the episode duration and handles completion logic

func NextEpisodePromptRofi added in v1.1.4

func NextEpisodePromptRofi(userCurdConfig *CurdConfig) bool

Simple next episode prompt for Rofi mode - just asks if user wants to continue

func ParseAniSkipResponse

func ParseAniSkipResponse(responseText string, anime *Anime, timePrecision int) error

ParseAniSkipResponse parses the response text from the AniSkip API and updates the Anime struct

func PercentageWatched

func PercentageWatched(playbackTime int, duration int) float64
func PrioritizeLink(links []string) string

PrioritizeLink takes an array of links and returns a single link based on priority

func RateAnime

func RateAnime(token string, mediaID int) error

Function to rate an anime on AniList

func RestoreScreen

func RestoreScreen()

RestoreScreen restores the original terminal state

func RoundTime

func RoundTime(timeValue float64, precision int) float64

RoundTime rounds a time value to the specified precision

func SaveConfigToFile added in v1.1.4

func SaveConfigToFile(path string, configMap map[string]string) error

SaveConfigToFile saves updated config map to file in key=value format

func SearchAnimeAnilistPreview added in v0.0.7

func SearchAnimeAnilistPreview(query, token string) (map[string]RofiSelectPreview, error)

SearchAnimeAnilist sends the query to AniList and returns a map of title to ID

func SearchAnimeByTitle

func SearchAnimeByTitle(jsonData map[string]interface{}, searchTitle string) []map[string]interface{}

Function to search for an anime by title in user data

func SeekMPV

func SeekMPV(ipcSocketPath string, time int) (interface{}, error)

func SendSkipTimesToMPV added in v1.1.0

func SendSkipTimesToMPV(anime *Anime) error

Function to send OP and ED timings to MPV

func SetGlobalAnime added in v1.0.9

func SetGlobalAnime(anime *Anime)

SetGlobalAnime sets the global anime reference

func SetGlobalConfig added in v0.0.5

func SetGlobalConfig(config *CurdConfig)

func SetGlobalLogFile added in v1.0.9

func SetGlobalLogFile(logFile string)

SetGlobalLogFile sets the global log file path

func SetupCurd

func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAnimes *[]Anime)

func SetupMPVEventListening added in v1.1.7

func SetupMPVEventListening(ipcSocketPath string) error

SetupMPVEventListening configures MPV to send property change notifications

func StartCurd

func StartCurd(userCurdConfig *CurdConfig, anime *Anime) string

func StartMPVEventListener added in v1.1.7

func StartMPVEventListener(ipcSocketPath string, eventCallback func(string, interface{})) error

StartMPVEventListener starts a dedicated goroutine to listen for MPV events

func StartNextEpisode added in v1.1.2

func StartNextEpisode(anime *Anime, userCurdConfig *CurdConfig, databaseFile string, userToken string)

StartNextEpisode handles the logic for starting the next episode It updates the episode number, resets necessary flags, and handles database updates

func StartVideo

func StartVideo(link string, args []string, title string, anime *Anime) (string, error)

func UpdateAnimeEntry added in v0.0.9

func UpdateAnimeEntry(userCurdConfig *CurdConfig, user *User)

func UpdateAnimeProgress

func UpdateAnimeProgress(token string, mediaID, progress int) error

Function to update anime progress

func UpdateAnimeStatus added in v0.0.9

func UpdateAnimeStatus(token string, mediaID int, status string) error

func UpdateCurd

func UpdateCurd(repo, fileName string) error

func WatchUntracked added in v1.0.2

func WatchUntracked(userCurdConfig *CurdConfig)

func WriteTokenToFile

func WriteTokenToFile(token string, filePath string) error

CreateOrWriteTokenFile creates the token file if it doesn't exist and writes the token to it

Types

type AniListAnime

type AniListAnime struct {
	ID    int `json:"id"`
	Title struct {
		Romaji  string `json:"romaji"`
		English string `json:"english"`
		Native  string `json:"native"`
	} `json:"title"`
	CoverImage struct {
		Large string `json:"large"`
	} `json:"coverImage"`
}

AniListAnime is the struct for the API response

type AnilistToken added in v1.1.5

type AnilistToken struct {
	AccessToken  string    `json:"access_token"`
	TokenType    string    `json:"token_type"`
	ExpiresIn    int       `json:"expires_in"`
	RefreshToken string    `json:"refresh_token"`
	ExpiresAt    time.Time `json:"expires_at"`
}

AnilistToken represents the OAuth token response from Anilist

type Anime

type Anime struct {
	Title          AnimeTitle `json:"title"`
	Ep             Episode    `json:"ep"`
	CoverImage     string     `json:"url"`            // Assuming this field corresponds to the cover image URL
	TotalEpisodes  int        `json:"total_episodes"` // If provided by the API
	MalId          int        `json:"mal_id"`
	AnilistId      int        `json:"anilist_id"` // Assuming you have an Anilist ID in your struct
	Rewatching     bool
	AllanimeId     string // Can be populated as necessary
	FillerEpisodes []int
	IsAiring       bool
}

func FindAnimeByAnilistIDInAnimes

func FindAnimeByAnilistIDInAnimes(animes []Anime, anilistID int) (*Anime, error)

FindAnimeByAnilistIDInAnimes searches for an anime by its AniList ID in a slice of Anime

func GetAnimeDataByID

func GetAnimeDataByID(id int, token string) (Anime, error)

GetAnimeDataByID retrieves detailed anime data from AniList using the anime's ID and user token

func GetGlobalAnime added in v1.0.9

func GetGlobalAnime() *Anime

GetGlobalAnime gets the global anime reference

func LocalFindAnime

func LocalFindAnime(animeList []Anime, anilistID int, allanimeID string) *Anime

Function to find an anime by either Anilist ID or Allanime ID

func LocalGetAllAnime

func LocalGetAllAnime(databaseFile string) []Anime

Function to get all anime entries from the database

type AnimeFillerListEpisode added in v1.0.8

type AnimeFillerListEpisode struct {
	EpisodeID int  `json:"mal_id"`
	IsFiller  bool `json:"filler"`
}

type AnimeList

type AnimeList struct {
	Watching   []Entry `json:"watching"`
	Completed  []Entry `json:"completed"`
	Paused     []Entry `json:"paused"`
	Dropped    []Entry `json:"dropped"`
	Planning   []Entry `json:"planning"`
	Rewatching []Entry `json:"rewatching"`
}

func ParseAnimeList

func ParseAnimeList(input map[string]interface{}) AnimeList

type AnimeTitle

type AnimeTitle struct {
	Romaji   string `json:"title_romanji"`
	English  string `json:"title"`
	Japanese string `json:"title_japanese"`
}

type CurdConfig

type CurdConfig struct {
	Player                   string   `config:"Player"`
	MpvArgs                  []string `config:MpvArgs`
	SubsLanguage             string   `config:"SubsLanguage"`
	SubOrDub                 string   `config:"SubOrDub"`
	StoragePath              string   `config:"StoragePath"`
	AnimeNameLanguage        string   `config:"AnimeNameLanguage"`
	MenuOrder                string   `config:"MenuOrder"`
	PercentageToMarkComplete int      `config:"PercentageToMarkComplete"`
	NextEpisodePrompt        bool     `config:"NextEpisodePrompt"`
	SkipOp                   bool     `config:"SkipOp"`
	SkipEd                   bool     `config:"SkipEd"`
	SkipFiller               bool     `config:"SkipFiller"`
	ImagePreview             bool     `config:"ImagePreview"`
	SkipRecap                bool     `config:"SkipRecap"`
	RofiSelection            bool     `config:"RofiSelection"`
	CurrentCategory          bool     `config:"CurrentCategory"`
	ScoreOnCompletion        bool     `config:"ScoreOnCompletion"`
	SaveMpvSpeed             bool     `config:"SaveMpvSpeed"`
	AddMissingOptions        bool     `config:"AddMissingOptions"`
	AlternateScreen          bool     `config:"AlternateScreen"`
	DiscordPresence          bool     `config:"DiscordPresence"`
	DiscordClientId          string   `config:"DiscordClientId"`
}

CurdConfig struct with field names that match the config keys

func GetGlobalConfig added in v0.0.5

func GetGlobalConfig() *CurdConfig

func LoadConfig

func LoadConfig(configPath string) (CurdConfig, error)

LoadConfig reads or creates the config file, adds missing fields, and returns the populated CurdConfig struct

func PopulateConfig added in v1.1.4

func PopulateConfig(configMap map[string]string) CurdConfig

PopulateConfig populates the CurdConfig struct from a map

type Entry

type Entry struct {
	Media      Media   `json:"media"`
	Progress   int     `json:"progress"`
	Score      float64 `json:"score"`
	Status     string  `json:"status"`
	CoverImage string  `json:"coverImage"`
}

func FindAnimeByAnilistID

func FindAnimeByAnilistID(list AnimeList, idStr string) (*Entry, error)

FindAnimeByID searches for an anime by its ID in the AnimeList

type Episode

type Episode struct {
	Title          AnimeTitle   `json:"title"`
	Number         int          `json:"number"`
	SkipTimes      SkipTimes    `json:"skip_times"`
	Player         playingVideo `json:"player"`
	Resume         bool         `json:"resume"`
	Started        bool         `json:"started"`
	Duration       int          `json:"duration"`
	Links          []string     `json:"links"`
	NextEpisode    NextEpisode  `json:"next_episode"`
	IsFiller       bool         `json:"filler"`
	IsRecap        bool         `json:"recap"`
	Aired          string       `json:"aired"`
	Synopsis       string       `json:"synopsis"`
	ContinueLast   bool
	LastWasSkipped bool // used in filler check
	IsCompleted    bool
}

type EpisodesResponse added in v1.0.8

type EpisodesResponse struct {
	Data       []AnimeFillerListEpisode `json:"data"`
	Pagination struct {
		HasNextPage bool `json:"has_next_page"`
	} `json:"pagination"`
}

type MPVEventListener added in v1.1.7

type MPVEventListener struct {
	SocketPath        string
	LastPosition      float64
	LastPauseState    bool
	SeekDetected      bool
	PlayPauseDetected bool
	IsListening       bool
	// contains filtered or unexported fields
}

MPVEventListener represents a structure to track MPV events

func CreateMPVSeekDetector added in v1.1.7

func CreateMPVSeekDetector(ipcSocketPath string) *MPVEventListener

MPVSeekDetector provides enhanced seek detection using actual MPV events

func (*MPVEventListener) HasPlayPauseChanged added in v1.1.7

func (detector *MPVEventListener) HasPlayPauseChanged() bool

HasPlayPauseChanged checks and resets the play/pause detection flag

func (*MPVEventListener) HasSeekOccurred added in v1.1.7

func (detector *MPVEventListener) HasSeekOccurred() bool

HasSeekOccurred checks and resets the seek detection flag

func (*MPVEventListener) ProcessMPVEvent added in v1.1.7

func (detector *MPVEventListener) ProcessMPVEvent(propertyName string, data interface{})

ProcessMPVEvent processes incoming MPV events and detects seeks and play/pause changes

type Media

type Media struct {
	Duration int        `json:"duration"`
	Episodes int        `json:"episodes"`
	ID       int        `json:"id"`
	Title    AnimeTitle `json:"title"`
}

type Model

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

Model represents the application state for the selection prompt

func (Model) Init

func (m Model) Init() tea.Cmd

Init initializes the model

func (*Model) Update

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

Update handles user input and updates the model

func (Model) View

func (m Model) View() string

View renders the UI and only shows as many options as fit in the terminal

type NextEpisode added in v1.0.8

type NextEpisode struct {
	Number int
	Links  []string
}

type Page

type Page struct {
	Media []AniListAnime `json:"media"`
}

Page represents the page in AniList response

type ResponseData

type ResponseData struct {
	Page Page `json:"Page"`
}

ResponseData represents the full response structure

type RofiSelectPreview added in v0.0.7

type RofiSelectPreview struct {
	Title      string `json:"title"`
	CoverImage string `json:"coverImage"`
}

type SelectionOption

type SelectionOption struct {
	Label string
	Key   string
}

SelectionOption holds the label and the internal key

func AddNewAnime added in v0.0.3

func AddNewAnime(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAnimes *[]Anime) SelectionOption

func DynamicSelect

func DynamicSelect(options []SelectionOption) (SelectionOption, error)

DynamicSelect displays a simple selection prompt without extra features

func DynamicSelectFromSlice added in v1.1.3

func DynamicSelectFromSlice(options []SelectionOption) (SelectionOption, error)

func DynamicSelectPreview added in v0.0.7

func DynamicSelectPreview(options map[string]RofiSelectPreview, addnewoption bool) (SelectionOption, error)

func RofiSelect added in v0.0.5

func RofiSelect(options []SelectionOption, isHomeMenu bool) (SelectionOption, error)

func SearchAnime

func SearchAnime(query, mode string) ([]SelectionOption, error)

func SearchAnimeAnilist

func SearchAnimeAnilist(query, token string) ([]SelectionOption, error)

SearchAnimeAnilist sends the query to AniList and returns a map of title to ID

type SelectionOptionImage added in v1.1.4

type SelectionOptionImage struct {
	Key        string
	Label      string
	CoverImage string
}

type SequelInfo added in v1.1.7

type SequelInfo struct {
	ID         int
	Title      AnimeTitle
	CoverImage string
	Episodes   int
	Status     string // "FINISHED", "RELEASING", "NOT_YET_RELEASED"
}

SequelInfo holds information about a sequel anime

func GetAnimeSequel added in v1.1.7

func GetAnimeSequel(animeID int, token string) (*SequelInfo, error)

GetAnimeSequel fetches sequel information for a given anime from AniList

type Skip

type Skip struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

type SkipTimes

type SkipTimes struct {
	Op Skip `json:"op"`
	Ed Skip `json:"ed"`
}

type User

type User struct {
	Token     string
	Username  string
	Id        int
	AnimeList AnimeList
}

Jump to

Keyboard shortcuts

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