tracks

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchUpdate

func BatchUpdate(tracks []*Track, cl spotify.Client)

BatchUpdate updates the information of a list of tracks using the most efficient method

func BatchUpdateArtists

func BatchUpdateArtists(artists []*Artist, cl spotify.Client)

func TrackExists

func TrackExists(ID string) bool

TrackExists returns true if the tracks exists or false otherwise

Types

type AlbumInformationStruct

type AlbumInformationStruct struct {
	Popularity   int
	ReleaseDate  string
	TracksAmount int
	Markets      int
	ID           string
}

type Artist

type Artist struct {
	ID         uint      `gorm:"primarykey" json:"-"`
	CreatedAt  time.Time `json:"-"`
	DeletedAt  time.Time `gorm:"index" json:"-"`
	ArtistID   string    `gorm:"type:VARCHAR(30) NOT NULL UNIQUE"`
	Name       string
	Genres     GenresStruct
	Popularity int16
	Image      string
	Updated    bool
}

func GetArtistFromID

func GetArtistFromID(ID string) *Artist

GetArtistFromID

func (*Artist) Save

func (a *Artist) Save() error

Save saves the artist to DB

func (Artist) String

func (a Artist) String() string

String returns the artist ID

func (*Artist) Update

func (a *Artist) Update(cl spotify.Client)

type GenresStruct

type GenresStruct []string

func (*GenresStruct) Scan

func (sla *GenresStruct) Scan(value interface{}) error

func (GenresStruct) Value

func (sla GenresStruct) Value() (driver.Value, error)

type SpotifyInformation

type SpotifyInformation struct {
	TrackInformation TrackInformationStruct `gorm:"embedded;embeddedPrefix:track_"`
	AlbumInformation AlbumInformationStruct `gorm:"embedded;embeddedPrefix:album_"`
	TrackFeatures    TrackFeaturesStruct    `gorm:"embedded;embeddedPrefix:features_"`
	Updated          bool                   `json:"-"`
}

type Track

type Track struct {
	ID        uint           `gorm:"primarykey" json:"-"`
	CreatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
	TrackID   string         `gorm:"type:VARCHAR(30) NOT NULL UNIQUE"`

	Lyrics string

	LastUpdated time.Time `json:"-"`
	Artists     []Artist  `gorm:"many2many:track_artists;"`
	Name        string
	Information SpotifyInformation `gorm:"embedded;embeddedPrefix:information_"`
}

func GetTrackFromID

func GetTrackFromID(ID string) *Track

GetTrackFromID returns a track from database and sets its mutex

func (*Track) ArtistString

func (t *Track) ArtistString() string

ArtistString returns the artist name as a string

func (*Track) NeedUpdate

func (t *Track) NeedUpdate() bool

func (*Track) Save

func (t *Track) Save() error

Save a track to the database

func (Track) String

func (t Track) String() string

String returns the track id as a string

func (*Track) Update

func (t *Track) Update(cl spotify.Client, syncUpdateLyrics bool) error

Update a track's information

type TrackFeaturesStruct

type TrackFeaturesStruct struct {
	Acousticness     float32
	Energy           float32
	Instrumentalness float32
	Liveness         float32
	Loudness         float32
	Speechiness      float32
}

type TrackInformationStruct

type TrackInformationStruct struct {
	Image         string
	Popularity    int
	Length        int
	Markets       int
	Explicit      bool
	Key           int
	Mode          int
	Tempo         float64
	TimeSignature int
}

Directories

Path Synopsis
lyrics

Jump to

Keyboard shortcuts

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