activity

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package activity manages user activity data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidUser = errors.New("invalid user")
)

Functions

This section is empty.

Types

type Activity

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

func NewActivity

func NewActivity(config *config.Config) *Activity

func (*Activity) Close

func (a *Activity) Close()

func (*Activity) CreateEvents

func (a *Activity) CreateEvents(ctx Context, events Events) error

func (*Activity) DeleteUserEvents

func (a *Activity) DeleteUserEvents(ctx Context) error

func (*Activity) Movies

func (a *Activity) Movies(ctx Context, start, end time.Time) []Movie

func (*Activity) Open

func (a *Activity) Open() error

func (*Activity) PopularTracks

func (a *Activity) PopularTracks(ctx Context, start, end time.Time) []Track

func (*Activity) RecentMovies

func (a *Activity) RecentMovies(ctx Context) []Movie

func (*Activity) RecentReleases

func (a *Activity) RecentReleases(ctx Context) []Release

func (*Activity) RecentTracks

func (a *Activity) RecentTracks(ctx Context) []Track

func (*Activity) Releases

func (a *Activity) Releases(ctx Context, start, end time.Time) []Release

func (*Activity) Tracks

func (a *Activity) Tracks(ctx Context, start, end time.Time) []Track

func (*Activity) UserScrobble

func (a *Activity) UserScrobble(user *auth.User, s Scrobble, music *music.Music) error

Add a scrobble with an MBID that should match a track we have

type Context

type Context interface {
	Music() *music.Music
	Podcast() *podcast.Podcast
	User() *auth.User
	Video() *video.Video
}

type Episode

type Episode struct {
	Date    time.Time
	Episode podcast.Episode
}

type EpisodeEvent

type EpisodeEvent struct {
	gorm.Model
	User string    `gorm:"index:idx_episode_user" json:"-"`
	Date time.Time `gorm:"uniqueIndex:idx_episode_date"`
	EID  string
}

type Events

type Events struct {
	MovieEvents   []MovieEvent
	ReleaseEvents []ReleaseEvent
	EpisodeEvents []EpisodeEvent
	TrackEvents   []TrackEvent
}

type Movie

type Movie struct {
	Date  time.Time
	Movie video.Movie
}

type MovieEvent

type MovieEvent struct {
	gorm.Model
	User string    `gorm:"index:idx_movie_user" json:"-"`
	Date time.Time `gorm:"uniqueIndex:idx_movie_date"`
	TMID string
	IMID string
	ETag string `gorm:"-"`
}

type Playlist

type Playlist struct {
	gorm.Model
	User    string    `gorm:"index:idx_playlist_user" json:"-"`
	Title   string    // Album title, Station name, etc.
	Creator string    // Artist name, Podcast author
	Image   string    //
	Ref     string    //
	Date    time.Time `gorm:"uniqueIndex:idx_playlist_date"`
}

Listen is an album, playlist or podcast listening event.

type Release

type Release struct {
	Date    time.Time
	Release music.Release
}

type ReleaseEvent

type ReleaseEvent struct {
	gorm.Model
	User string    `gorm:"index:idx_release_user" json:"-"`
	Date time.Time `gorm:"uniqueIndex:idx_release_date"`
	RGID string
	REID string
}

type Scrobble

type Scrobble struct {
	Artist      string    `json:""` // Required
	Track       string    `json:""` // Required
	Timestamp   time.Time `json:""` // Required
	Album       string    `json:""` // Optional
	AlbumArtist string    `json:""` // Optional
	TrackNumber int       `json:""` // Optional
	Duration    int       `json:""` // Optional - Length of track in seconds
	MBID        string    `json:""` // Optional - recording (or track?) MBID
}

Scrobble is a track listening event.

Spec location: https://www.last.fm/api/show/track.scrobble not using: context, streamId, chosenByUser

func (Scrobble) PreferredArtist

func (s Scrobble) PreferredArtist() string

type Track

type Track struct {
	Date  time.Time
	Track music.Track
}

type TrackEvent

type TrackEvent struct {
	gorm.Model
	User string    `gorm:"index:idx_track_user" json:"-"`
	Date time.Time `gorm:"uniqueIndex:idx_track_date"`
	RID  string
	RGID string
	ETag string `gorm:"-"`
}

Jump to

Keyboard shortcuts

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