Documentation ¶
Index ¶
- Constants
- Variables
- func GetGenres[G GenresOrGenreNames](ms *Storage, ctx context.Context, kind string, all bool, columns ...string) ([]G, error)
- type ActorCast
- type Album
- type AlbumArtist
- type Book
- type BookValues
- type Cast
- type Details
- type DirectorCast
- type Episode
- type Film
- type Genre
- type GenreCharacteristics
- type GenreDescription
- type GenresOrGenreNames
- type Group
- type GroupedArtists
- type Keyword
- type KeywordStorage
- func (ks *KeywordStorage) AddKeyword(ctx context.Context, keyword string, mediaID uuid.UUID) (err error)
- func (ks *KeywordStorage) CastVote(ctx context.Context, k Keyword) error
- func (ks *KeywordStorage) GetAll(ctx context.Context) (keywords []Keyword, err error)
- func (ks *KeywordStorage) GetKeyword(ctx context.Context, keyword string, mediaID uuid.UUID) (k Keyword, err error)
- func (ks *KeywordStorage) GetKeywordByID(ctx context.Context, id int32) (k Keyword, err error)
- func (ks *KeywordStorage) GetKeywords(ctx context.Context, mediaID uuid.UUID) (keywords []Keyword, err error)
- func (ks *KeywordStorage) RemoveVote(ctx context.Context, k Keyword) error
- type KeywordStorer
- type Media
- type MediaObject
- type PeopleStorage
- func (ps *PeopleStorage) CreateGroup(ctx context.Context, group *Group) (*uuid.UUID, error)
- func (ps *PeopleStorage) CreatePerson(ctx context.Context, person *Person) (*uuid.UUID, error)
- func (p *PeopleStorage) GetArtistsByName(ctx context.Context, name string) (persons []Person, groups []Group, err error)
- func (p *PeopleStorage) GetGroup(ctx context.Context, id int32) (Group, error)
- func (p *PeopleStorage) GetGroupName(ctx context.Context, id int32) (Group, error)
- func (p *PeopleStorage) GetID(ctx context.Context, name, kind string) (id uuid.UUID, err error)
- func (p *PeopleStorage) GetPerson(ctx context.Context, id int64) (Person, error)
- func (p *PeopleStorage) GetPersonNames(ctx context.Context, id int32) (Person, error)
- func (p *PeopleStorage) GetStudio(ctx context.Context, id int32) (*Studio, error)
- type Person
- type PersonPhotos
- type Season
- type SharedMetadata
- type SimplifiedMedia
- type Storage
- func (ms *Storage) Add(ctx context.Context, props *Media) (mediaID *uuid.UUID, err error)
- func (ms *Storage) AddBook(ctx context.Context, book *Book, publisher *Studio) error
- func (ms *Storage) AddCast(ctx context.Context, mediaID uuid.UUID, actors, directors []Person) (castID int64, err error)
- func (ms *Storage) AddCreators(ctx context.Context, id uuid.UUID, creators []Person) error
- func (ms *Storage) AddFilm(ctx context.Context, film *Film) error
- func (ms *Storage) Delete(ctx context.Context, mediaID uuid.UUID) error
- func (ms *Storage) Get(ctx context.Context, id uuid.UUID) (media *Media, err error)
- func (ms *Storage) GetAlbumTrackIDs(ctx context.Context, albumID uuid.UUID) (dest []*uuid.UUID, err error)
- func (ms *Storage) GetAlbumTracks(ctx context.Context, albumID uuid.UUID) ([]Track, error)
- func (ms *Storage) GetAll() ([]*interface{}, error)
- func (ms *Storage) GetCast(ctx context.Context, mediaID uuid.UUID) (cast Cast, err error)
- func (ms *Storage) GetDetails(ctx context.Context, mediaKind string, id uuid.UUID) (interface{}, error)
- func (ms *Storage) GetGenre(ctx context.Context, kind, lang, name string) (genre *Genre, err error)
- func (ms *Storage) GetImagePath(ctx context.Context, id uuid.UUID) (path string, err error)
- func (ms *Storage) GetKind(ctx context.Context, id uuid.UUID) (string, error)
- func (ms *Storage) GetRandom(ctx context.Context, count int, blacklistKinds ...string) (mwks map[uuid.UUID]string, err error)
- func (ms *Storage) Update(ctx context.Context, key string, value interface{}, mediaID uuid.UUID) error
- func (ms *Storage) UpdateFilm(ctx context.Context, film *Film) error
- type Storer
- type Studio
- type StudioKind
- type TVShow
- type Track
Constants ¶
const ( FilmStudio studioKind = "film" Music studioKind = "music" Game studioKind = "game" TV studioKind = "tv" Publishing studioKind = "publishing" VisualArtOther studioKind = "visual_art_other" Unknown studioKind = "unknown" )
Variables ¶
var BookKeys = []string{
"media_id", "title", "authors",
"genres", "edition", "languages",
}
Functions ¶
func GetGenres ¶
func GetGenres[G GenresOrGenreNames]( ms *Storage, ctx context.Context, kind string, all bool, columns ...string, ) ([]G, error)
GetGenres returns all genres for specified media type. parameter all specifies whether to return all genres or only top-level ones. variadic argument columns specifies which columns to return. In HTTP layer, columns are specified either in the JSON request body (as an array of strings) The name column can also be accessed with `names_only` boolean query parameter. Fetching of all genres is specified by the `all` query parameter (which does not require a value).
Types ¶
type Album ¶
type Album struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` Name string `json:"name" db:"name"` AlbumArtists []AlbumArtist `json:"album_artists" db:"album_artists"` ImagePaths pq.StringArray `json:"image_paths,omitempty"` // we make use of a junction table that utilizes the image IDs ReleaseDate time.Time `json:"release_date" db:"release_date"` Genres []Genre `json:"genres,omitempty" db:"genres"` // Studio Studio `json:"studio,omitempty" db:"studio"` Keywords []Keyword `json:"keywords,omitempty" db:"keywords"` Duration sql.NullTime `json:"duration,omitempty" db:"duration"` Tracks []Track `json:"tracks,omitempty" db:"tracks"` }
type AlbumArtist ¶
type AlbumArtist struct { ID uuid.UUID `json:"artist" db:"artist,pk,unique"` Name string `json:"name" db:"-"` // must perform a join operation to get the name ArtistType string `json:"artist_type" db:"artist_type" validate:"required,oneof=individual group"` }
junction table media.album_artists
type Book ¶
type Book struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` Title string `json:"title" db:"title"` Authors []Person `json:"author" db:"author"` Publisher Studio `json:"publisher" db:"publisher"` PublicationDate sql.NullTime `json:"publication_date" db:"publication_date"` Genres []Genre `json:"genres" db:"genres"` Keywords pq.StringArray `json:"keywords,omitempty" db:"keywords,omitempty"` Languages []string `json:"languages" db:"languages"` Pages int16 `json:"pages" db:"pages"` ISBN sql.NullString `json:"isbn,omitempty" db:"isbn,unique,omitempty"` ASIN sql.NullString `json:"asin,omitempty" db:"asin,unique,omitempty"` Cover sql.NullString `json:"cover,omitempty" db:"cover,omitempty"` Summary string `json:"summary" db:"summary"` }
type Details ¶
type Details struct { Kind string `json:"kind" db:"kind"` Data interface{} `json:"details" db:"details"` }
type DirectorCast ¶
type Episode ¶
type Episode struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` ShowID *uuid.UUID `json:"show_id" db:"show_id,pk,unique"` SeasonID *uuid.UUID `json:"season_id" db:"season_id,pk,unique"` Number uint16 `json:"number" db:"number,autoinc" validate:"required"` Title string `json:"title" db:"title"` Season uint16 `json:"season" db:"season" validate:"required"` Episode uint16 `json:"episode" db:"episode"` AirDate time.Time `json:"air_date" db:"air_date"` Duration time.Duration `json:"duration" db:"duration"` Languages []string `json:"languages" db:"languages"` Plot string `json:"plot" db:"plot"` }
type Film ¶
type Film struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` Title string `json:"title" db:"title" validate:"required"` Cast Cast `json:"cast"` // this data is stored in the people schema, so no db tag ReleaseDate sql.NullTime `json:"release_date" db:"release_date"` Duration sql.NullTime `json:"duration" db:"duration"` Synopsis sql.NullString `json:"synopsis" db:"synopsis"` }
nolint:musttag
func (*Film) GetPosterPath ¶
type Genre ¶
type Genre struct { ID int64 `json:"id" db:"id,pk,autoinc"` Kinds pq.StringArray `json:"kind" db:"kind" enum:"music,film,tv,book,game" example:"music"` Name string `json:"name" db:"name" example:"Black Metal"` Description []GenreDescription `json:"description,omitempty" db:"-"` // DescLong string `json:"desc_long" db:"desc_long"` Characteristics []string `json:"keywords" db:"-" example:"['dark', 'gloomy', 'atmospheric', 'raw', 'underproduced']"` ParentGenreID *int64 `json:"parent_genre,omitempty" db:"parent,omitempty"` Children []int64 `json:"children,omitempty" db:"children,omitempty"` }
Genre does not have a UUID due to parent-child relationships
type GenreCharacteristics ¶
type GenreCharacteristics struct { ID int64 `json:"id" db:"id,pk,autoinc"` Name string `json:"name" db:"name"` Descripion sql.NullString `json:"description,omitempty" db:"description"` }
type GenreDescription ¶
type GenresOrGenreNames ¶
type GenresOrGenreNames interface { []Genre | []string }
type Group ¶
type Group struct { Locations []places.Place `json:"locations,omitempty" db:"locations"` Active bool `json:"active,omitempty" db:"active"` Formed sql.NullTime `json:"formed,omitempty" db:"formed"` Disbanded sql.NullTime `json:"disbanded,omitempty" db:"disbanded"` Photos []string `json:"photos,omitempty" db:"photos"` Works []*uuid.UUID `json:"works,omitempty" db:"works"` Members []Person `json:"members,omitempty" db:"members"` PrimaryGenre Genre `json:"primary_genre,omitempty" db:"primary_genre_id"` SecondaryGenres []Genre `json:"genres,omitempty" db:"genres"` Kind string `json:"kind,omitempty" db:"kind"` // Orchestra, Choir, Ensemble, Collective, etc. Wikipedia *string `json:"wikipedia,omitempty" db:"wikipedia"` Bandcamp *string `json:"bandcamp,omitempty" db:"bandcamp"` Soundcloud *string `json:"soundcloud,omitempty" db:"soundcloud"` }
type GroupedArtists ¶
type KeywordStorage ¶
type KeywordStorage struct {
// contains filtered or unexported fields
}
func NewKeywordStorage ¶
func NewKeywordStorage(db *pgxpool.Pool, log *zerolog.Logger) *KeywordStorage
func (*KeywordStorage) AddKeyword ¶
func (ks *KeywordStorage) AddKeyword(ctx context.Context, keyword string, mediaID uuid.UUID) (err error)
func (*KeywordStorage) CastVote ¶
func (ks *KeywordStorage) CastVote(ctx context.Context, k Keyword) error
func (*KeywordStorage) GetAll ¶
func (ks *KeywordStorage) GetAll(ctx context.Context) (keywords []Keyword, err error)
func (*KeywordStorage) GetKeyword ¶
func (*KeywordStorage) GetKeywordByID ¶
func (*KeywordStorage) GetKeywords ¶
func (ks *KeywordStorage) GetKeywords(ctx context.Context, mediaID uuid.UUID) (keywords []Keyword, err error)
func (*KeywordStorage) RemoveVote ¶
func (ks *KeywordStorage) RemoveVote(ctx context.Context, k Keyword) error
type KeywordStorer ¶
type KeywordStorer interface { CastVote(ctx context.Context, k Keyword) error RemoveVote(ctx context.Context, k Keyword) error AddKeyword(ctx context.Context, k Keyword) error GetKeyword(ctx context.Context, mediaID uuid.UUID) (Keyword, error) GetKeywords(ctx context.Context, mediaID uuid.UUID) ([]Keyword, error) }
type Media ¶
type Media struct { ID uuid.UUID `json:"id" db:"id,pk,unique"` Title string `json:"title" db:"title"` Kind string `json:"kind" db:"kind"` Created time.Time `json:"keywords,omitempty" db:"created"` Creator sql.NullInt32 `json:"creator,omitempty" db:"creator"` Creators []Person `json:"creators,omitempty"` // no db tag, we're using a junction table Added time.Time `json:"added,omitempty" db:"added"` Modified sql.NullTime `json:"modified,omitempty" db:"modified"` }
nolint:musttag // false positive, can only annotate fields, not types
type PeopleStorage ¶
type PeopleStorage struct {
// contains filtered or unexported fields
}
func NewPeopleStorage ¶
func NewPeopleStorage(newConn *pgxpool.Pool, logger *zerolog.Logger) *PeopleStorage
func (*PeopleStorage) CreateGroup ¶ added in v0.9.19
func (ps *PeopleStorage) CreateGroup(ctx context.Context, group *Group) (*uuid.UUID, error)
func (*PeopleStorage) CreatePerson ¶ added in v0.9.19
func (ps *PeopleStorage) CreatePerson(ctx context.Context, person *Person) (*uuid.UUID, error)
func (*PeopleStorage) GetArtistsByName ¶
func (*PeopleStorage) GetGroupName ¶
func (*PeopleStorage) GetID ¶
func (p *PeopleStorage) GetID(ctx context.Context, name, kind string) (id uuid.UUID, err error)
func (*PeopleStorage) GetPersonNames ¶
type Person ¶
type Person struct { Roles pq.StringArray `json:"roles,omitempty" db:"roles" fake:"{randomstring:[actor,director,producer,writer,host,guest]}"` Works []*uuid.UUID `json:"works,omitempty" db:"works" fake:"{uuid}"` Birth sql.NullTime `json:"birth,omitempty" db:"birth"` Death sql.NullTime `json:"death,omitempty" db:"death" example:"2005-04-02T21:37:00Z"` Hometown places.Place `json:"hometown,omitempty" db:"hometown"` Residence places.Place `json:"residence,omitempty" db:"residence"` }
type PersonPhotos ¶ added in v0.9.19
type PersonPhotos struct { PersonID uuid.UUID `json:"person_id,omitempty" db:"person_id"` ImageID int64 `json:"image_id,omitempty" db:"image_id"` }
type SharedMetadata ¶ added in v0.9.19
type SharedMetadata struct {}
type SimplifiedMedia ¶
type SimplifiedMedia struct { Title string `json:"title" db:"title"` Kind string `json:"kind" db:"kind"` ImageSource string `json:"image_source" db:"source"` }
used in search
type Storage ¶
type Storage struct { Log *zerolog.Logger Ps *PeopleStorage // contains filtered or unexported fields }
func NewStorage ¶
func NewStorage(db *pgxpool.Pool, l *zerolog.Logger, ks *KeywordStorage, ps *PeopleStorage, ) *Storage
func (*Storage) Add ¶
Add is a generic method that adds an object to the media.media table. It needs to be run BEFORE the object is added to its respective table, since it needs the media ID to be generated first.
func (*Storage) AddCreators ¶
func (*Storage) Get ¶
Get scans into a complete Media struct In most cases though, all we need is an intermediate, partial instance with the UUID and Kind fields to be passed to GetDetails
func (*Storage) GetAlbumTrackIDs ¶
func (*Storage) GetAlbumTracks ¶
GetAlbumTracks retrieves the full metadata of given album's tracks based on the album ID
func (*Storage) GetDetails ¶
func (*Storage) GetImagePath ¶
func (*Storage) GetRandom ¶
func (ms *Storage) GetRandom(ctx context.Context, count int, blacklistKinds ...string) ( mwks map[uuid.UUID]string, err error, )
mwks - media IDs with their corresponding kind
type StudioKind ¶
type StudioKind interface {
// contains filtered or unexported methods
}
type TVShow ¶
type TVShow struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` Title string `json:"title" db:"title" validate:"required"` Cast Cast `json:"cast" db:"cast"` Year int `json:"year" db:"year"` Active bool `json:"active" db:"active"` Seasons []Season `json:"seasons" db:"seasons"` Studio Studio `json:"studio" db:"studio"` }
type Track ¶
type Track struct { MediaID *uuid.UUID `json:"media_id" db:"media_id,pk,unique"` Name string `json:"name" db:"name"` AlbumID *uuid.UUID `json:"album_id" db:"album"` // Artists mo.Either[[]Person, []Group] `json:"artists" db:"artists"` Duration time.Time `json:"duration" db:"duration"` Lyrics string `json:"lyrics,omitempty" db:"lyrics"` Number int16 `json:"track_number" db:"track_number"` }