tracker

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrInvalidStatus

type ErrInvalidStatus struct {
	Status string
}

ErrInvalidStatus is returned when an invalid status string is provided

func (*ErrInvalidStatus) Error

func (e *ErrInvalidStatus) Error() string

type Manager

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

Manager handles tracker instances and operations

func NewManager

func NewManager(cfg *config.Config, db *gorm.DB) *Manager

NewManager creates a new tracker manager

func (*Manager) DeleteFromList

func (m *Manager) DeleteFromList(ctx context.Context, mediaListID int) error

DeleteFromList removes a media from the tracker

func (*Manager) GetAniList

func (m *Manager) GetAniList() Tracker

GetAniList returns the AniList tracker

func (*Manager) GetUserLibrary

func (m *Manager) GetUserLibrary(ctx context.Context, mediaType providers.MediaType) ([]TrackedMedia, error)

GetUserLibrary retrieves the user's library from enabled trackers

func (*Manager) IsAniListAuthenticated

func (m *Manager) IsAniListAuthenticated() bool

IsAniListAuthenticated checks if AniList is authenticated

func (*Manager) IsAniListEnabled

func (m *Manager) IsAniListEnabled() bool

IsAniListEnabled checks if AniList tracking is enabled

func (*Manager) ProcessSyncQueue

func (m *Manager) ProcessSyncQueue(ctx context.Context) error

ProcessSyncQueue processes pending sync items

func (*Manager) SearchMedia

func (m *Manager) SearchMedia(ctx context.Context, query string, mediaType providers.MediaType) ([]TrackedMedia, error)

SearchMedia searches for media on enabled trackers

func (*Manager) SetAniListClient

func (m *Manager) SetAniListClient(client Tracker)

SetAniListClient sets the AniList tracker implementation

func (*Manager) UpdateProgress

func (m *Manager) UpdateProgress(ctx context.Context, mediaID string, episode int, progress float64) error

UpdateProgress updates progress on all enabled trackers

type Progress

type Progress struct {
	MediaID       string        `json:"media_id"`
	Episode       int           `json:"episode"`
	Percentage    float64       `json:"percentage"`   // 0.0 - 1.0
	TimeWatched   time.Duration `json:"time_watched"` // Seconds watched in current episode
	TotalTime     time.Duration `json:"total_time"`   // Total episode duration
	LastWatchedAt time.Time     `json:"last_watched_at"`
	Completed     bool          `json:"completed"`
}

Progress represents viewing progress for a media item

type SyncStatus

type SyncStatus struct {
	MediaID       string    `json:"media_id"`
	LocalProgress int       `json:"local_progress"`
	CloudProgress int       `json:"cloud_progress"`
	LastSyncedAt  time.Time `json:"last_synced_at"`
	NeedsSync     bool      `json:"needs_sync"`
	SyncError     string    `json:"sync_error,omitempty"`
}

SyncStatus represents the sync state of a media item

type TrackedMedia

type TrackedMedia struct {
	ServiceID     string              `json:"service_id"` // ID in tracking service (AniList, MAL, etc.)
	Title         string              `json:"title"`
	Type          providers.MediaType `json:"type"`
	Progress      int                 `json:"progress"` // Episodes watched
	TotalEpisodes int                 `json:"total_episodes"`
	Status        WatchStatus         `json:"status"`
	Score         float64             `json:"score"`
	StartDate     *time.Time          `json:"start_date,omitempty"`
	EndDate       *time.Time          `json:"end_date,omitempty"`
	Synopsis      string              `json:"synopsis"`
	PosterURL     string              `json:"poster_url"`
	UpdatedAt     time.Time           `json:"updated_at"`
	ListEntryID   int                 `json:"list_entry_id,omitempty"` // ID of the list entry (AniList MediaListEntry ID)
}

TrackedMedia represents a media item in a tracking service

type Tracker

type Tracker interface {
	// Authentication
	Authenticate(ctx context.Context) error
	IsAuthenticated() bool
	Logout() error

	// Media library
	GetUserLibrary(ctx context.Context, mediaType providers.MediaType) ([]TrackedMedia, error)
	SearchMedia(ctx context.Context, query string, mediaType providers.MediaType) ([]TrackedMedia, error)

	// Progress tracking
	UpdateProgress(ctx context.Context, mediaID string, episode int, progress float64) error
	GetProgress(ctx context.Context, mediaID string) (*Progress, error)

	// Metadata updates
	UpdateStatus(ctx context.Context, mediaID string, status WatchStatus) error
	UpdateScore(ctx context.Context, mediaID string, score float64) error
	UpdateDates(ctx context.Context, mediaID string, startDate, endDate *time.Time) error

	// Sync
	SyncHistory(ctx context.Context) error

	// Deletion (specific to services that support it)
	DeleteFromList(ctx context.Context, mediaListID int) error
}

Tracker defines the interface for progress tracking services (AniList, MyAnimeList, Trakt, etc.)

type WatchStatus

type WatchStatus string

WatchStatus represents the watching status of a media item

const (
	StatusWatching    WatchStatus = "watching"
	StatusCompleted   WatchStatus = "completed"
	StatusOnHold      WatchStatus = "on_hold"
	StatusDropped     WatchStatus = "dropped"
	StatusPlanToWatch WatchStatus = "plan_to_watch"
	StatusRewatching  WatchStatus = "rewatching"
)

func ParseWatchStatus

func ParseWatchStatus(s string) (WatchStatus, error)

ParseWatchStatus parses a string into a WatchStatus

func (WatchStatus) String

func (s WatchStatus) String() string

String returns the string representation of WatchStatus

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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