Documentation
¶
Overview ¶
Package catalog manages the internal metadata of the catalog of music the user has submitted listens for. This includes artists, releases (album, single, ep, etc), and tracks, as well as ingesting listens submitted both via the API(s) and other methods.
Index ¶
- Constants
- func AssociateAlbum(ctx context.Context, d db.DB, opts AssociateAlbumOpts) (*models.Album, error)
- func AssociateArtists(ctx context.Context, d db.DB, opts AssociateArtistsOpts) ([]*models.Artist, error)
- func AssociateTrack(ctx context.Context, d db.DB, opts AssociateTrackOpts) (*models.Track, error)
- func CompressAndSaveImage(ctx context.Context, filename string, size ImageSize, body io.Reader) error
- func DeleteImage(filename uuid.UUID) error
- func DownloadAndCacheImage(ctx context.Context, id uuid.UUID, url string, size ImageSize) error
- func GetImageSize(size ImageSize) int
- func ParseArtists(artist string, title string, addlSeparators []*regexp.Regexp) []string
- func PruneOrphanedImages(ctx context.Context, store db.DB) error
- func SourceImageDir() string
- func SubmitListen(ctx context.Context, store db.DB, opts SubmitListenOpts) error
- func ValidateImageURL(url string) error
- type ArtistMbidMap
- type AssociateAlbumOpts
- type AssociateArtistsOpts
- type AssociateTrackOpts
- type GetListensOpts
- type ImageSize
- type SaveListenOpts
- type SubmitListenOpts
Constants ¶
const (
ImageSourceUserUpload = "User Upload"
)
Variables ¶
This section is empty.
Functions ¶
func AssociateAlbum ¶
func AssociateArtists ¶
func AssociateTrack ¶
func CompressAndSaveImage ¶
func CompressAndSaveImage(ctx context.Context, filename string, size ImageSize, body io.Reader) error
Compresses an image to the specified size, then saves it to the correct cache folder.
func DeleteImage ¶
func DownloadAndCacheImage ¶
DownloadAndCacheImage downloads an image from the given URL, then calls CompressAndSaveImage.
func GetImageSize ¶
func ParseArtists ¶
ParseArtists extracts all contributing artist names from the artist and title strings
func PruneOrphanedImages ¶
Finds any images in all image_cache folders and deletes them if they are not associated with an album or artist.
func SourceImageDir ¶
func SourceImageDir() string
func SubmitListen ¶
func ValidateImageURL ¶
ValidateImageURL checks if the URL points to a valid image by performing a HEAD request.
Types ¶
type ArtistMbidMap ¶
type AssociateAlbumOpts ¶
type AssociateArtistsOpts ¶
type AssociateArtistsOpts struct {
ArtistMbzIDs []uuid.UUID
ArtistNames []string
ArtistMbidMap []ArtistMbidMap
ArtistName string
TrackTitle string
Mbzc mbz.MusicBrainzCaller
SkipCacheImage bool
}
type AssociateTrackOpts ¶
type GetListensOpts ¶
type ImageSize ¶
type ImageSize string
func ImageSourceSize ¶
func ImageSourceSize() (size ImageSize)
func ParseImageSize ¶
type SaveListenOpts ¶
type SubmitListenOpts ¶
type SubmitListenOpts struct {
// When true, skips registering the listen and only associates or creates the
// artist, release, release group, and track in DB
SkipSaveListen bool
// When true, skips caching the images and only stores the image url in the db
SkipCacheImage bool
MbzCaller mbz.MusicBrainzCaller
ArtistNames []string
Artist string
ArtistMbzIDs []uuid.UUID
ArtistMbidMappings []ArtistMbidMap
TrackTitle string
RecordingMbzID uuid.UUID
Duration int32 // in seconds
ReleaseTitle string
ReleaseMbzID uuid.UUID
ReleaseGroupMbzID uuid.UUID
Time time.Time
UserID int32
Client string
IsNowPlaying bool
// When true, checks for existing listens within +/- 60s window for the same track
DeduplicateFuzzy bool
// Optional: Direct URL to image to use if no other image is found
ImageURL string
}