Skip to content

🎧 Your Personal Streaming Service

Renamed Id to ID, following GoLang convention

Deluan40904b220e9d
diff --git a/api/browsing.go b/api/browsing.go
index 37d8e535c..1a4cf47bb 100644
--- a/api/browsing.go
+++ b/api/browsing.go
@@ -25,7 +25,7 @@ func (c *BrowsingController) GetMusicFolders(w http.ResponseWriter, r *http.Requ
mediaFolderList, _ := c.browser.MediaFolders()
folders := make([]responses.MusicFolder, len(mediaFolderList))
for i, f := range mediaFolderList {
- folders[i].Id = f.Id
+ folders[i].Id = f.ID
folders[i].Name = f.Name
}
response := NewEmpty()
@@ -50,7 +50,7 @@ func (c *BrowsingController) getArtistIndex(r *http.Request, ifModifiedSince tim
res.Index[i].Name = idx.Id
res.Index[i].Artists = make([]responses.Artist, len(idx.Artists))
for j, a := range idx.Artists {
- res.Index[i].Artists[j].Id = a.ArtistId
+ res.Index[i].Artists[j].Id = a.ArtistID
res.Index[i].Artists[j].Name = a.Artist
res.Index[i].Artists[j].AlbumCount = a.AlbumCount
}
@@ -87,7 +87,7 @@ func (c *BrowsingController) GetMusicDirectory(w http.ResponseWriter, r *http.Re
dir, err := c.browser.Directory(r.Context(), id)
switch {
case err == domain.ErrNotFound:
- log.Error(r, "Requested Id not found ", "id", id)
+ log.Error(r, "Requested ID not found ", "id", id)
return nil, NewError(responses.ErrorDataNotFound, "Directory not found")
case err != nil:
log.Error(err)
@@ -104,7 +104,7 @@ func (c *BrowsingController) GetArtist(w http.ResponseWriter, r *http.Request) (
dir, err := c.browser.Artist(r.Context(), id)
switch {
case err == domain.ErrNotFound:
- log.Error(r, "Requested ArtistId not found ", "id", id)
+ log.Error(r, "Requested ArtistID not found ", "id", id)
return nil, NewError(responses.ErrorDataNotFound, "Artist not found")
case err != nil:
log.Error(r, err)
@@ -121,7 +121,7 @@ func (c *BrowsingController) GetAlbum(w http.ResponseWriter, r *http.Request) (*
dir, err := c.browser.Album(r.Context(), id)
switch {
case err == domain.ErrNotFound:
- log.Error(r, "Requested Id not found ", "id", id)
+ log.Error(r, "Requested ID not found ", "id", id)
return nil, NewError(responses.ErrorDataNotFound, "Album not found")
case err != nil:
log.Error(r, err)
@@ -138,7 +138,7 @@ func (c *BrowsingController) GetSong(w http.ResponseWriter, r *http.Request) (*r
song, err := c.browser.GetSong(id)
switch {
case err == domain.ErrNotFound:
- log.Error(r, "Requested Id not found ", "id", id)
+ log.Error(r, "Requested ID not found ", "id", id)
return nil, NewError(responses.ErrorDataNotFound, "Song not found")
case err != nil:
log.Error(r, err)
diff --git a/api/media_annotation.go b/api/media_annotation.go
index 71222dfbd..cbd2b05b2 100644
--- a/api/media_annotation.go
+++ b/api/media_annotation.go
@@ -38,7 +38,7 @@ func (c *MediaAnnotationController) SetRating(w http.ResponseWriter, r *http.Req
switch {
case err == domain.ErrNotFound:
log.Error(r, err)
- return nil, NewError(responses.ErrorDataNotFound, "Id not found")
+ return nil, NewError(responses.ErrorDataNotFound, "ID not found")
case err != nil:
log.Error(r, err)
return nil, NewError(responses.ErrorGeneric, "Internal Error")
@@ -68,7 +68,7 @@ func (c *MediaAnnotationController) Star(w http.ResponseWriter, r *http.Request)
switch {
case err == domain.ErrNotFound:
log.Error(r, err)
- return nil, NewError(responses.ErrorDataNotFound, "Id not found")
+ return nil, NewError(responses.ErrorDataNotFound, "ID not found")
case err != nil:
log.Error(r, err)
return nil, NewError(responses.ErrorGeneric, "Internal Error")
diff --git a/api/playlists.go b/api/playlists.go
index e8fd7d320..299d917e8 100644
--- a/api/playlists.go
+++ b/api/playlists.go
@@ -26,7 +26,7 @@ func (c *PlaylistsController) GetPlaylists(w http.ResponseWriter, r *http.Reques
}
playlists := make([]responses.Playlist, len(allPls))
for i, p := range allPls {
- playlists[i].Id = p.Id
+ playlists[i].Id = p.ID
playlists[i].Name = p.Name
playlists[i].Comment = p.Comment
playlists[i].SongCount = len(p.Tracks)
diff --git a/domain/album.go b/domain/album.go
index 9bc70e8f4..de7a10bfa 100644
--- a/domain/album.go
+++ b/domain/album.go
@@ -3,9 +3,9 @@ package domain
import "time"
type Album struct {
- Id string
+ ID string
Name string
- ArtistId string `parent:"artist"`
+ ArtistID string `parent:"artist"`
CoverArtPath string
CoverArtId string
Artist string
diff --git a/domain/artist.go b/domain/artist.go
index a2aeebcb3..eb22e59fe 100644
--- a/domain/artist.go
+++ b/domain/artist.go
@@ -1,7 +1,7 @@
package domain
type Artist struct {
- Id string
+ ID string
Name string
AlbumCount int
}
diff --git a/domain/index.go b/domain/index.go
index 57be54e38..ac2d3c77a 100644
--- a/domain/index.go
+++ b/domain/index.go
@@ -3,7 +3,7 @@ package domain
import "github.com/cloudsonic/sonic-server/utils"
type ArtistInfo struct {
- ArtistId string
+ ArtistID string
Artist string
AlbumCount int
}
diff --git a/domain/mediafile.go b/domain/mediafile.go
index ac45f2bbc..2bdb93798 100644
--- a/domain/mediafile.go
+++ b/domain/mediafile.go
@@ -6,14 +6,14 @@ import (
)
type MediaFile struct {
- Id string
+ ID string
Path string
Title string
Album string
Artist string
- ArtistId string
+ ArtistID string
AlbumArtist string
- AlbumId string `parent:"album"`
+ AlbumID string `parent:"album"`
HasCoverArt bool
TrackNumber int
DiscNumber int
diff --git a/domain/mediafolder.go b/domain/mediafolder.go
index ae8e874af..8100dce7d 100644
--- a/domain/mediafolder.go
+++ b/domain/mediafolder.go
@@ -1,7 +1,7 @@
package domain
type MediaFolder struct {
- Id string
+ ID string
Name string
Path string
}
diff --git a/domain/nowplaying.go b/domain/nowplaying.go
index c5ef26577..c0e2481ee 100644
--- a/domain/nowplaying.go
+++ b/domain/nowplaying.go
@@ -5,7 +5,7 @@ import "time"
const NowPlayingExpire = 60 * time.Minute
type NowPlayingInfo struct {
- TrackId string
+ TrackID string
Start time.Time
Username string
PlayerId int
diff --git a/domain/playlist.go b/domain/playlist.go
index 18b2cdf56..0d7bf2eac 100644
--- a/domain/playlist.go
+++ b/domain/playlist.go
@@ -1,7 +1,7 @@
package domain
type Playlist struct {
- Id string
+ ID string
Name string
Comment string
FullPath string
diff --git a/domain/properties.go b/domain/properties.go
index 8b942fb42..a632d3a71 100644
--- a/domain/properties.go
+++ b/domain/properties.go
@@ -5,7 +5,7 @@ const (
)
type Property struct {
- Id string
+ ID string
Value string
}
diff --git a/engine/browser.go b/engine/browser.go
index 36e78defe..68dc7ce2a 100644
--- a/engine/browser.go
+++ b/engine/browser.go
@@ -116,7 +116,7 @@ func (b *browser) GetSong(id string) (*Entry, error) {
func (b *browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *DirectoryInfo {
dir := &DirectoryInfo{
- Id: a.Id,
+ Id: a.ID,
Name: a.Name,
AlbumCount: a.AlbumCount,
}
@@ -131,14 +131,14 @@ func (b *browser) buildArtistDir(a *domain.Artist, albums domain.Albums) *Direct
func (b *browser) buildAlbumDir(al *domain.Album, tracks domain.MediaFiles) *DirectoryInfo {
dir := &DirectoryInfo{
- Id: al.Id,
+ Id: al.ID,
Name: al.Name,
- Parent: al.ArtistId,
+ Parent: al.ArtistID,
PlayCount: int32(al.PlayCount),
UserRating: al.Rating,
Starred: al.StarredAt,
Artist: al.Artist,
- ArtistId: al.ArtistId,
+ ArtistId: al.ArtistID,
SongCount: al.SongCount,
Duration: al.Duration,
Created: al.CreatedAt,
diff --git a/engine/common.go b/engine/common.go
index 2e617e5fa..33f9c8c84 100644
--- a/engine/common.go
+++ b/engine/common.go
@@ -45,7 +45,7 @@ type Entries []Entry
func FromArtist(ar *domain.Artist) Entry {
e := Entry{}
- e.Id = ar.Id
+ e.Id = ar.ID
e.Title = ar.Name
e.AlbumCount = ar.AlbumCount
e.IsDir = true
@@ -54,10 +54,10 @@ func FromArtist(ar *domain.Artist) Entry {
func FromAlbum(al *domain.Album) Entry {
e := Entry{}
- e.Id = al.Id
+ e.Id = al.ID
e.Title = al.Name
e.IsDir = true
- e.Parent = al.ArtistId
+ e.Parent = al.ArtistID
e.Album = al.Name
e.Year = al.Year
e.Artist = al.AlbumArtist
@@ -66,8 +66,8 @@ func FromAlbum(al *domain.Album) Entry {
e.Starred = al.StarredAt
e.PlayCount = int32(al.PlayCount)
e.Created = al.CreatedAt
- e.AlbumId = al.Id
- e.ArtistId = al.ArtistId
+ e.AlbumId = al.ID
+ e.ArtistId = al.ArtistID
e.UserRating = al.Rating
e.Duration = al.Duration
e.SongCount = al.SongCount
@@ -76,10 +76,10 @@ func FromAlbum(al *domain.Album) Entry {
func FromMediaFile(mf *domain.MediaFile) Entry {
e := Entry{}
- e.Id = mf.Id
+ e.Id = mf.ID
e.Title = mf.Title
e.IsDir = false
- e.Parent = mf.AlbumId
+ e.Parent = mf.AlbumID
e.Album = mf.Album
e.Year = mf.Year
e.Artist = mf.Artist
@@ -91,7 +91,7 @@ func FromMediaFile(mf *domain.MediaFile) Entry {
e.BitRate = mf.BitRate
e.Starred = mf.StarredAt
if mf.HasCoverArt {
- e.CoverArt = mf.Id
+ e.CoverArt = mf.ID
}
e.ContentType = mf.ContentType()
// Creates a "pseudo" path, to avoid sending absolute paths to the client
@@ -101,8 +101,8 @@ func FromMediaFile(mf *domain.MediaFile) Entry {
e.PlayCount = int32(mf.PlayCount)
e.DiscNumber = mf.DiscNumber
e.Created = mf.CreatedAt
- e.AlbumId = mf.AlbumId
- e.ArtistId = mf.ArtistId
+ e.AlbumId = mf.AlbumID
+ e.ArtistId = mf.ArtistID
e.Type = "music" // TODO Hardcoded for now
e.UserRating = mf.Rating
return e
diff --git a/engine/cover_test.go b/engine/cover_test.go
index 8124dba84..cc7c0aa9e 100644
--- a/engine/cover_test.go
+++ b/engine/cover_test.go
@@ -32,7 +32,7 @@ func TestCover(t *testing.T) {
})
})
Convey("When id is found", func() {
- mockMediaFileRepo.SetData(`[{"Id":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
+ mockMediaFileRepo.SetData(`[{"ID":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
err := cover.Get("2", 0, out)
Convey("Then it should return the cover from the file", func() {
@@ -41,7 +41,7 @@ func TestCover(t *testing.T) {
})
})
Convey("When there is an error accessing the database", func() {
- mockMediaFileRepo.SetData(`[{"Id":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
+ mockMediaFileRepo.SetData(`[{"ID":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
mockMediaFileRepo.SetError(true)
err := cover.Get("2", 0, out)
@@ -50,7 +50,7 @@ func TestCover(t *testing.T) {
})
})
Convey("When id is found but file is not present", func() {
- mockMediaFileRepo.SetData(`[{"Id":"2","HasCoverArt":true,"Path":"tests/fixtures/NOT_FOUND.mp3"}]`, 1)
+ mockMediaFileRepo.SetData(`[{"ID":"2","HasCoverArt":true,"Path":"tests/fixtures/NOT_FOUND.mp3"}]`, 1)
err := cover.Get("2", 0, out)
Convey("Then it should return DatNotFound error", func() {
@@ -58,7 +58,7 @@ func TestCover(t *testing.T) {
})
})
Convey("When specifying a size", func() {
- mockMediaFileRepo.SetData(`[{"Id":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
+ mockMediaFileRepo.SetData(`[{"ID":"2","HasCoverArt":true,"Path":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
err := cover.Get("2", 100, out)
Convey("Then image returned should be 100x100", func() {
@@ -71,7 +71,7 @@ func TestCover(t *testing.T) {
})
})
Convey("When id is for an album", func() {
- mockAlbumRepo.SetData(`[{"Id":"1","CoverArtPath":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
+ mockAlbumRepo.SetData(`[{"ID":"1","CoverArtPath":"tests/fixtures/01 Invisible (RED) Edit Version.mp3"}]`, 1)
err := cover.Get("al-1", 0, out)
Convey("Then it should return the cover for the album", func() {
diff --git a/engine/list_generator.go b/engine/list_generator.go
index df4ad1d26..196b8d83a 100644
--- a/engine/list_generator.go
+++ b/engine/list_generator.go
@@ -138,7 +138,7 @@ func (g *listGenerator) GetNowPlaying() (Entries, error) {
}
entries := make(Entries, len(npInfo))
for i, np := range npInfo {
- mf, err := g.mfRepository.Get(np.TrackId)
+ mf, err := g.mfRepository.Get(np.TrackID)
if err != nil {
return nil, err
}
diff --git a/engine/playlists.go b/engine/playlists.go
index 4cbbd07b5..0b345dc02 100644
--- a/engine/playlists.go
+++ b/engine/playlists.go
@@ -67,7 +67,7 @@ func (p *playlists) Update(playlistId string, name *string, idsToAdd []string, i
}
if name != nil {
pl.Name = *name
- err := p.itunes.RenamePlaylist(pl.Id, pl.Name)
+ err := p.itunes.RenamePlaylist(pl.ID, pl.Name)
if err != nil {
return err
}
@@ -78,7 +78,7 @@ func (p *playlists) Update(playlistId string, name *string, idsToAdd []string, i
pl.Tracks, pl.Tracks[len(pl.Tracks)-1] = append(pl.Tracks[:i], pl.Tracks[i+1:]...), ""
}
pl.Tracks = append(pl.Tracks, idsToAdd...)
- err := p.itunes.UpdatePlaylist(pl.Id, pl.Tracks)
+ err := p.itunes.UpdatePlaylist(pl.ID, pl.Tracks)
if err != nil {
return err
}
@@ -94,7 +94,7 @@ func (p *playlists) Get(id string) (*PlaylistInfo, error) {
}
pinfo := &PlaylistInfo{
- Id: pl.Id,
+ Id: pl.ID,
Name: pl.Name,
SongCount: len(pl.Tracks),
Duration: pl.Duration,
diff --git a/engine/ratings.go b/engine/ratings.go
index 76913ae0f..e069f07b1 100644
--- a/engine/ratings.go
+++ b/engine/ratings.go
@@ -33,7 +33,7 @@ func (r ratings) SetRating(ctx context.Context, id string, rating int) error {
mfs, _ := r.mfRepo.FindByAlbum(id)
if len(mfs) > 0 {
log.Debug(ctx, "Set Rating", "value", rating, "album", mfs[0].Album)
- if err := r.itunes.SetAlbumRating(mfs[0].Id, rating); err != nil {
+ if err := r.itunes.SetAlbumRating(mfs[0].ID, rating); err != nil {
return err
}
}
@@ -46,7 +46,7 @@ func (r ratings) SetRating(ctx context.Context, id string, rating int) error {
}
if mf != nil {
log.Debug(ctx, "Set Rating", "value", rating, "song", mf.Title)
- if err := r.itunes.SetTrackRating(mf.Id, rating); err != nil {
+ if err := r.itunes.SetTrackRating(mf.ID, rating); err != nil {
return err
}
return nil
@@ -61,7 +61,7 @@ func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
mfs, _ := r.mfRepo.FindByAlbum(id)
if len(mfs) > 0 {
log.Debug(ctx, "Set Star", "value", star, "album", mfs[0].Album)
- if err := r.itunes.SetAlbumLoved(mfs[0].Id, star); err != nil {
+ if err := r.itunes.SetAlbumLoved(mfs[0].ID, star); err != nil {
return err
}
}
@@ -74,7 +74,7 @@ func (r ratings) SetStar(ctx context.Context, star bool, ids ...string) error {
}
if mf != nil {
log.Debug(ctx, "Set Star", "value", star, "song", mf.Title)
- if err := r.itunes.SetTrackLoved(mf.Id, star); err != nil {
+ if err := r.itunes.SetTrackLoved(mf.ID, star); err != nil {
return err
}
continue
diff --git a/engine/scrobbler.go b/engine/scrobbler.go
index d6b199f01..72dcc54c4 100644
--- a/engine/scrobbler.go
+++ b/engine/scrobbler.go
@@ -38,14 +38,14 @@ func (s *scrobbler) detectSkipped(ctx context.Context, playerId int, trackId str
return
case 1:
np, _ := s.npRepo.Tail(playerId)
- if np.TrackId != trackId {
+ if np.TrackID != trackId {
return
}
s.npRepo.Dequeue(playerId)
default:
prev, _ := s.npRepo.Dequeue(playerId)
for {
- if prev.TrackId == trackId {
+ if prev.TrackID == trackId {
break
}
np, err := s.npRepo.Dequeue(playerId)
@@ -54,15 +54,15 @@ func (s *scrobbler) detectSkipped(ctx context.Context, playerId int, trackId str
}
diff := np.Start.Sub(prev.Start)
if diff < minSkipped || diff > maxSkipped {
- log.Debug(ctx, fmt.Sprintf("-- Playtime for track %s was %v. Not skipping.", prev.TrackId, diff))
+ log.Debug(ctx, fmt.Sprintf("-- Playtime for track %s was %v. Not skipping.", prev.TrackID, diff))
prev = np
continue
}
- err = s.itunes.MarkAsSkipped(prev.TrackId, prev.Start.Add(1*time.Minute))
+ err = s.itunes.MarkAsSkipped(prev.TrackID, prev.Start.Add(1*time.Minute))
if err != nil {
- log.Warn(ctx, "Error skipping track", "id", prev.TrackId)
+ log.Warn(ctx, "Error skipping track", "id", prev.TrackID)
} else {
- log.Debug(ctx, "-- Skipped track "+prev.TrackId)
+ log.Debug(ctx, "-- Skipped track "+prev.TrackID)
}
}
}
@@ -77,7 +77,7 @@ func (s *scrobbler) Register(ctx context.Context, playerId int, trackId string,
}
if mf == nil {
- return nil, errors.New(fmt.Sprintf(`Id "%s" not found`, trackId))
+ return nil, errors.New(fmt.Sprintf(`ID "%s" not found`, trackId))
}
if err := s.itunes.MarkAsPlayed(trackId, playTime); err != nil {
@@ -93,9 +93,9 @@ func (s *scrobbler) NowPlaying(ctx context.Context, playerId int, playerName, tr
}
if mf == nil {
- return nil, errors.New(fmt.Sprintf(`Id "%s" not found`, trackId))
+ return nil, errors.New(fmt.Sprintf(`ID "%s" not found`, trackId))
}
- info := &domain.NowPlayingInfo{TrackId: trackId, Username: username, Start: time.Now(), PlayerId: playerId, PlayerName: playerName}
+ info := &domain.NowPlayingInfo{TrackID: trackId, Username: username, Start: time.Now(), PlayerId: playerId, PlayerName: playerName}
return mf, s.npRepo.Enqueue(info)
}
diff --git a/engine/scrobbler_test.go b/engine/scrobbler_test.go
index 4c456e958..f2d4ae9dd 100644
--- a/engine/scrobbler_test.go
+++ b/engine/scrobbler_test.go
@@ -23,7 +23,7 @@ func TestScrobbler(t *testing.T) {
scrobbler := engine.NewScrobbler(itCtrl, mfRepo, npRepo)
Convey("Given a DB with one song", t, func() {
- mfRepo.SetData(`[{"Id":"2","Title":"Hands Of Time"}]`, 1)
+ mfRepo.SetData(`[{"ID":"2","Title":"Hands Of Time"}]`, 1)
Convey("When I scrobble an existing song", func() {
now := time.Now()
@@ -63,7 +63,7 @@ func TestScrobbler(t *testing.T) {
Convey("And it saves the song as the one current playing", func() {
info, _ := npRepo.Head(1)
- So(info.TrackId, ShouldEqual, "2")
+ So(info.TrackID, ShouldEqual, "2")
// Commenting out time sensitive test, due to flakiness
// So(info.Start, ShouldHappenBefore, time.Now())
So(info.Username, ShouldEqual, "deluan")
@@ -95,7 +95,7 @@ func TestSkipping(t *testing.T) {
scrobbler := engine.NewScrobbler(itCtrl, mfRepo, npRepo)
Convey("Given a DB with three songs", t, func() {
- mfRepo.SetData(`[{"Id":"1","Title":"Femme Fatale"},{"Id":"2","Title":"Here She Comes Now"},{"Id":"3","Title":"Lady Godiva's Operation"}]`, 3)
+ mfRepo.SetData(`[{"ID":"1","Title":"Femme Fatale"},{"ID":"2","Title":"Here She Comes Now"},{"ID":"3","Title":"Lady Godiva's Operation"}]`, 3)
itCtrl.skipped = make(map[string]time.Time)
npRepo.ClearAll()
Convey("When I skip 2 songs", func() {
@@ -109,7 +109,7 @@ func TestSkipping(t *testing.T) {
np, err := npRepo.GetAll()
So(err, ShouldBeNil)
So(np, ShouldHaveLength, 1)
- So(np[0].TrackId, ShouldEqual, "2")
+ So(np[0].TrackID, ShouldEqual, "2")
})
})
Convey("When I play one song", func() {
@@ -120,7 +120,7 @@ func TestSkipping(t *testing.T) {
scrobbler.NowPlaying(nil, 1, "DSub", "2", "deluan")
Convey("Then the first song should be marked as skipped", func() {
mf, err := scrobbler.Register(nil, 1, "2", aPointInTime.Add(3*time.Minute))
- So(mf.Id, ShouldEqual, "2")
+ So(mf.ID, ShouldEqual, "2")
So(itCtrl.skipped, ShouldContainKey, "1")
So(err, ShouldBeNil)
})
@@ -130,7 +130,7 @@ func TestSkipping(t *testing.T) {
scrobbler.NowPlaying(nil, 1, "DSub", "2", "deluan")
Convey("Then the first song should be marked as skipped", func() {
mf, err := scrobbler.Register(nil, 1, "2", aPointInTime.Add(3*time.Minute))
- So(mf.Id, ShouldEqual, "2")
+ So(mf.ID, ShouldEqual, "2")
So(itCtrl.skipped, ShouldBeEmpty)
So(err, ShouldBeNil)
})
@@ -140,7 +140,7 @@ func TestSkipping(t *testing.T) {
scrobbler.NowPlaying(nil, 1, "DSub", "2", "deluan")
Convey("Then the first song should be marked as skipped", func() {
mf, err := scrobbler.Register(nil, 1, "2", aPointInTime.Add(3*time.Minute))
- So(mf.Id, ShouldEqual, "2")
+ So(mf.ID, ShouldEqual, "2")
So(itCtrl.skipped, ShouldBeEmpty)
So(err, ShouldBeNil)
})
@@ -148,7 +148,7 @@ func TestSkipping(t *testing.T) {
Convey("And I scrobble it before starting to play the other song", func() {
mf, err := scrobbler.Register(nil, 1, "1", time.Now())
Convey("Then the first song should NOT marked as skipped", func() {
- So(mf.Id, ShouldEqual, "1")
+ So(mf.ID, ShouldEqual, "1")
So(itCtrl.skipped, ShouldBeEmpty)
So(err, ShouldBeNil)
})
@@ -163,7 +163,7 @@ func TestSkipping(t *testing.T) {
Convey("Then the NowPlaying song should be the last one", func() {
np, _ := npRepo.GetAll()
So(np, ShouldHaveLength, 1)
- So(np[0].TrackId, ShouldEqual, "2")
+ So(np[0].TrackID, ShouldEqual, "2")
})
})
})
diff --git a/engine/search.go b/engine/search.go
index 25af58d3d..a91f93ce5 100644
--- a/engine/search.go
+++ b/engine/search.go
@@ -62,15 +62,15 @@ func (s *search) ClearAll() error {
}
func (s *search) IndexArtist(ar *domain.Artist) error {
- return s.idxArtist.Index(ar.Id, sanitize.Accents(strings.ToLower(ar.Name)))
+ return s.idxArtist.Index(ar.ID, sanitize.Accents(strings.ToLower(ar.Name)))
}
func (s *search) IndexAlbum(al *domain.Album) error {
- return s.idxAlbum.Index(al.Id, sanitize.Accents(strings.ToLower(al.Name)))
+ return s.idxAlbum.Index(al.ID, sanitize.Accents(strings.ToLower(al.Name)))
}
func (s *search) IndexMediaFile(mf *domain.MediaFile) error {
- return s.idxSong.Index(mf.Id, sanitize.Accents(strings.ToLower(mf.Title)))
+ return s.idxSong.Index(mf.ID, sanitize.Accents(strings.ToLower(mf.Title)))
}
func (s *search) RemoveArtist(ids ...string) error {
@@ -153,7 +153,7 @@ func criticalError(ctx context.Context, kind, id string, err error) bool {
case err != nil:
return true
case err == domain.ErrNotFound:
- log.Warn(ctx, kind+"Id not in DB. Need a reindex?", "id", id)
+ log.Warn(ctx, kind+"ID not in DB. Need a reindex?", "id", id)
}
return false
}
diff --git a/persistence/ledis/album_repository.go b/persistence/ledis/album_repository.go
index 55d54dd95..8e8ab4693 100644
--- a/persistence/ledis/album_repository.go
+++ b/persistence/ledis/album_repository.go
@@ -18,10 +18,10 @@ func NewAlbumRepository() domain.AlbumRepository {
}
func (r *albumRepository) Put(m *domain.Album) error {
- if m.Id == "" {
- return errors.New("album Id is not set")
+ if m.ID == "" {
+ return errors.New("album ID is not set")
}
- return r.saveOrUpdate(m.Id, m)
+ return r.saveOrUpdate(m.ID, m)
}
func (r *albumRepository) Get(id string) (*domain.Album, error) {
@@ -60,7 +60,7 @@ func (r *albumRepository) GetAllIds() ([]string, error) {
func (r *albumRepository) PurgeInactive(active domain.Albums) ([]string, error) {
return r.purgeInactive(active, func(e interface{}) string {
- return e.(domain.Album).Id
+ return e.(domain.Album).ID
})
}
diff --git a/persistence/ledis/artist_repository.go b/persistence/ledis/artist_repository.go
index 378ed0e7e..1e38ee6bf 100644
--- a/persistence/ledis/artist_repository.go
+++ b/persistence/ledis/artist_repository.go
@@ -17,10 +17,10 @@ func NewArtistRepository() domain.ArtistRepository {
}
func (r *artistRepository) Put(m *domain.Artist) error {
- if m.Id == "" {
- return errors.New("artist Id is not set")
+ if m.ID == "" {
+ return errors.New("artist ID is not set")
}
- return r.saveOrUpdate(m.Id, m)
+ return r.saveOrUpdate(m.ID, m)
}
func (r *artistRepository) Get(id string) (*domain.Artist, error) {
@@ -31,7 +31,7 @@ func (r *artistRepository) Get(id string) (*domain.Artist, error) {
func (r *artistRepository) PurgeInactive(active domain.Artists) ([]string, error) {
return r.purgeInactive(active, func(e interface{}) string {
- return e.(domain.Artist).Id
+ return e.(domain.Artist).ID
})
}
diff --git a/persistence/ledis/checksum_repository.go b/persistence/ledis/checksum_repository.go
index 31570be25..54862701d 100644
--- a/persistence/ledis/checksum_repository.go
+++ b/persistence/ledis/checksum_repository.go
@@ -37,7 +37,7 @@ func (r *checkSumRepository) loadData() {
func (r *checkSumRepository) Put(id, sum string) error {
if id == "" {
- return errors.New("Id is required")
+ return errors.New("ID is required")
}
_, err := Db().HSet(checkSumKeyName, []byte(id), []byte(sum))
return err
diff --git a/persistence/ledis/index_repository.go b/persistence/ledis/index_repository.go
index 0aba67698..fc99ea0c3 100644
--- a/persistence/ledis/index_repository.go
+++ b/persistence/ledis/index_repository.go
@@ -19,7 +19,7 @@ func NewArtistIndexRepository() domain.ArtistIndexRepository {
func (r *artistIndexRepository) Put(m *domain.ArtistIndex) error {
if m.Id == "" {
- return errors.New("index Id is not set")
+ return errors.New("index ID is not set")
}
sort.Sort(m.Artists)
return r.saveOrUpdate(m.Id, m)
diff --git a/persistence/ledis/index_repository_test.go b/persistence/ledis/index_repository_test.go
index ac166d274..7c79314ad 100644
--- a/persistence/ledis/index_repository_test.go
+++ b/persistence/ledis/index_repository_test.go
@@ -24,7 +24,7 @@ func TestIndexRepository(t *testing.T) {
So(s, shouldBeEqual, i)
})
- Convey("It should be able to check for existence of an Id", func() {
+ Convey("It should be able to check for existence of an ID", func() {
i := &domain.ArtistIndex{Id: "123"}
repo.Put(i)
@@ -35,7 +35,7 @@ func TestIndexRepository(t *testing.T) {
s, _ = repo.Exists("NOT_FOUND")
So(s, ShouldBeFalse)
})
- Convey("Method Put() should return error if Id is not set", func() {
+ Convey("Method Put() should return error if ID is not set", func() {
i := &domain.ArtistIndex{}
err := repo.Put(i)
diff --git a/persistence/ledis/ledis_repository_test.go b/persistence/ledis/ledis_repository_test.go
index b11c46329..d6a20eb1c 100644
--- a/persistence/ledis/ledis_repository_test.go
+++ b/persistence/ledis/ledis_repository_test.go
@@ -91,7 +91,7 @@ func TestBaseRepository(t *testing.T) {
Convey("When I call NewId with a name", func() {
Id := repo.newId("a name")
- Convey("Then it should return a new Id", func() {
+ Convey("Then it should return a new ID", func() {
So(Id, ShouldNotBeEmpty)
})
})
@@ -100,7 +100,7 @@ func TestBaseRepository(t *testing.T) {
FirstId := repo.newId("a name")
SecondId := repo.newId("a name")
- Convey("Then it should return the same Id each time", func() {
+ Convey("Then it should return the same ID each time", func() {
So(FirstId, ShouldEqual, SecondId)
})
@@ -163,7 +163,7 @@ func TestBaseRepository(t *testing.T) {
entity := &TestEntity{Id: "111", Name: "One Name", ParentId: "AAA"}
repo.saveOrUpdate(entity.Id, entity)
- Convey("When I save an entity with a different Id", func() {
+ Convey("When I save an entity with a different ID", func() {
newEntity := &TestEntity{Id: "222", Name: "Another Name", ParentId: "AAA"}
repo.saveOrUpdate(newEntity.Id, newEntity)
@@ -174,7 +174,7 @@ func TestBaseRepository(t *testing.T) {
})
- Convey("When I save an entity with the same Id", func() {
+ Convey("When I save an entity with the same ID", func() {
newEntity := &TestEntity{Id: "111", Name: "New Name", ParentId: "AAA"}
repo.saveOrUpdate(newEntity.Id, newEntity)
diff --git a/persistence/ledis/mediafile_repository.go b/persistence/ledis/mediafile_repository.go
index 8d48181c6..6f5257f45 100644
--- a/persistence/ledis/mediafile_repository.go
+++ b/persistence/ledis/mediafile_repository.go
@@ -19,10 +19,10 @@ func NewMediaFileRepository() domain.MediaFileRepository {
}
func (r *mediaFileRepository) Put(m *domain.MediaFile) error {
- if m.Id == "" {
- return errors.New("mediaFile Id is not set")
+ if m.ID == "" {
+ return errors.New("mediaFile ID is not set")
}
- return r.saveOrUpdate(m.Id, m)
+ return r.saveOrUpdate(m.ID, m)
}
func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
@@ -31,7 +31,7 @@ func (r *mediaFileRepository) Get(id string) (*domain.MediaFile, error) {
return nil, err
}
mf := m.(*domain.MediaFile)
- if mf.Id != id {
+ if mf.ID != id {
return nil, nil
}
return mf, nil
@@ -69,7 +69,7 @@ func (r *mediaFileRepository) GetAllIds() ([]string, error) {
func (r *mediaFileRepository) PurgeInactive(active domain.MediaFiles) ([]string, error) {
return r.purgeInactive(active, func(e interface{}) string {
- return e.(domain.MediaFile).Id
+ return e.(domain.MediaFile).ID
})
}
diff --git a/persistence/ledis/mediafolders_repository.go b/persistence/ledis/mediafolders_repository.go
index 81b5dc384..e4958da93 100644
--- a/persistence/ledis/mediafolders_repository.go
+++ b/persistence/ledis/mediafolders_repository.go
@@ -14,7 +14,7 @@ func NewMediaFolderRepository() domain.MediaFolderRepository {
}
func (*mediaFolderRepository) GetAll() (domain.MediaFolders, error) {
- mediaFolder := domain.MediaFolder{Id: "0", Name: "iTunes Library", Path: conf.Sonic.MusicFolder}
+ mediaFolder := domain.MediaFolder{ID: "0", Name: "iTunes Library", Path: conf.Sonic.MusicFolder}
result := make(domain.MediaFolders, 1)
result[0] = mediaFolder
return result, nil
diff --git a/persistence/ledis/playlist_repository.go b/persistence/ledis/playlist_repository.go
index f56ebb0c5..2329847b7 100644
--- a/persistence/ledis/playlist_repository.go
+++ b/persistence/ledis/playlist_repository.go
@@ -17,10 +17,10 @@ func NewPlaylistRepository() domain.PlaylistRepository {
}
func (r *playlistRepository) Put(m *domain.Playlist) error {
- if m.Id == "" {
- return errors.New("playlist Id is not set")
+ if m.ID == "" {
+ return errors.New("playlist ID is not set")
}
- return r.saveOrUpdate(m.Id, m)
+ return r.saveOrUpdate(m.ID, m)
}
func (r *playlistRepository) Get(id string) (*domain.Playlist, error) {
@@ -41,7 +41,7 @@ func (r *playlistRepository) GetAll(options domain.QueryOptions) (domain.Playlis
func (r *playlistRepository) PurgeInactive(active domain.Playlists) ([]string, error) {
return r.purgeInactive(active, func(e interface{}) string {
- return e.(domain.Playlist).Id
+ return e.(domain.Playlist).ID
})
}
diff --git a/persistence/ledis/property_repository.go b/persistence/ledis/property_repository.go
index 4f5f05d3b..ac10f0c05 100644
--- a/persistence/ledis/property_repository.go
+++ b/persistence/ledis/property_repository.go
@@ -17,11 +17,11 @@ func NewPropertyRepository() domain.PropertyRepository {
}
func (r *propertyRepository) Put(id string, value string) error {
- m := &domain.Property{Id: id, Value: value}
- if m.Id == "" {
- return errors.New("Id is required")
+ m := &domain.Property{ID: id, Value: value}
+ if m.ID == "" {
+ return errors.New("ID is required")
}
- return r.saveOrUpdate(m.Id, m)
+ return r.saveOrUpdate(m.ID, m)
}
func (r *propertyRepository) Get(id string) (string, error) {
diff --git a/persistence/mock_album_repo.go b/persistence/mock_album_repo.go
index 6cb151913..a012978ff 100644
--- a/persistence/mock_album_repo.go
+++ b/persistence/mock_album_repo.go
@@ -32,7 +32,7 @@ func (m *MockAlbum) SetData(j string, size int) {
fmt.Println("ERROR: ", err)
}
for _, a := range m.all {
- m.data[a.Id] = &a
+ m.data[a.ID] = &a
}
}
@@ -66,7 +66,7 @@ func (m *MockAlbum) FindByArtist(artistId string) (domain.Albums, error) {
var res = make(domain.Albums, len(m.data))
i := 0
for _, a := range m.data {
- if a.ArtistId == artistId {
+ if a.ArtistID == artistId {
res[i] = *a
i++
}
diff --git a/persistence/mock_artist_repo.go b/persistence/mock_artist_repo.go
index 54fdd59c9..7906c3af7 100644
--- a/persistence/mock_artist_repo.go
+++ b/persistence/mock_artist_repo.go
@@ -30,7 +30,7 @@ func (m *MockArtist) SetData(j string, size int) {
fmt.Println("ERROR: ", err)
}
for _, a := range l {
- m.data[a.Id] = &a
+ m.data[a.ID] = &a
}
}
diff --git a/persistence/mock_mediafile_repo.go b/persistence/mock_mediafile_repo.go
index ea64f2621..167274e83 100644
--- a/persistence/mock_mediafile_repo.go
+++ b/persistence/mock_mediafile_repo.go
@@ -30,7 +30,7 @@ func (m *MockMediaFile) SetData(j string, size int) {
fmt.Println("ERROR: ", err)
}
for _, a := range l {
- m.data[a.Id] = a
+ m.data[a.ID] = a
}
}
@@ -59,7 +59,7 @@ func (m *MockMediaFile) FindByAlbum(artistId string) (domain.MediaFiles, error)
var res = make(domain.MediaFiles, len(m.data))
i := 0
for _, a := range m.data {
- if a.AlbumId == artistId {
+ if a.AlbumID == artistId {
res[i] = a
i++
}
diff --git a/scanner/importer.go b/scanner/importer.go
index 35de10318..6f79be537 100644
--- a/scanner/importer.go
+++ b/scanner/importer.go
@@ -184,7 +184,7 @@ func (i *Importer) importMediaFiles() (domain.MediaFiles, int) {
continue
}
if mf.Starred {
- original, err := i.mfRepo.Get(mf.Id)
+ original, err := i.mfRepo.Get(mf.ID)
if err != nil || !original.Starred {
mf.StarredAt = mf.UpdatedAt
} else {
@@ -216,7 +216,7 @@ func (i *Importer) importAlbums() (domain.Albums, int) {
continue
}
if al.Starred {
- original, err := i.albumRepo.Get(al.Id)
+ original, err := i.albumRepo.Get(al.ID)
if err != nil || !original.Starred {
al.StarredAt = al.UpdatedAt
} else {
@@ -294,7 +294,7 @@ func (i *Importer) collectIndex(ig utils.IndexGroups, a *domain.Artist, artistIn
artists = make(tempIndex)
artistIndex[group] = artists
}
- artists[indexName] = domain.ArtistInfo{ArtistId: a.Id, Artist: a.Name, AlbumCount: a.AlbumCount}
+ artists[indexName] = domain.ArtistInfo{ArtistID: a.ID, Artist: a.Name, AlbumCount: a.AlbumCount}
}
func (i *Importer) findGroup(ig utils.IndexGroups, name string) string {
diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.go
index 857985c1c..870ff6fa3 100644
--- a/scanner/itunes_scanner.go
+++ b/scanner/itunes_scanner.go
@@ -77,11 +77,11 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
mf := s.collectMediaFiles(&t)
s.collectAlbums(&t, mf, ar)
- songsPerAlbum[mf.AlbumId]++
- if albumsPerArtist[mf.ArtistId] == nil {
- albumsPerArtist[mf.ArtistId] = make(map[string]bool)
+ songsPerAlbum[mf.AlbumID]++
+ if albumsPerArtist[mf.ArtistID] == nil {
+ albumsPerArtist[mf.ArtistID] = make(map[string]bool)
}
- albumsPerArtist[mf.ArtistId][mf.AlbumId] = true
+ albumsPerArtist[mf.ArtistID][mf.AlbumID] = true
}
i++
if i%1000 == 0 {
@@ -174,18 +174,18 @@ func (s *ItunesScanner) skipPlaylist(p *itl.Playlist, ignFolders bool, ignPatter
func (s *ItunesScanner) collectPlaylists(p *itl.Playlist, fullPath string) {
pl := &domain.Playlist{}
- pl.Id = p.PlaylistPersistentID
+ pl.ID = p.PlaylistPersistentID
pl.Name = unescape(p.Name)
pl.FullPath = fullPath
pl.Tracks = make([]string, 0, len(p.PlaylistItems))
for _, item := range p.PlaylistItems {
if mf, found := s.pmediaFiles[item.TrackID]; found {
- pl.Tracks = append(pl.Tracks, mf.Id)
+ pl.Tracks = append(pl.Tracks, mf.ID)
pl.Duration += mf.Duration
}
}
if len(pl.Tracks) > 0 {
- s.playlists[pl.Id] = pl
+ s.playlists[pl.ID] = pl
}
}
@@ -233,10 +233,10 @@ func (s *ItunesScanner) calcCheckSum(t *itl.Track) string {
func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {
mf := &domain.MediaFile{}
- mf.Id = t.PersistentID
+ mf.ID = t.PersistentID
mf.Album = unescape(t.Album)
- mf.AlbumId = albumId(t)
- mf.ArtistId = artistId(t)
+ mf.AlbumID = albumId(t)
+ mf.ArtistID = artistId(t)
mf.Title = unescape(t.Name)
mf.Artist = unescape(t.Artist)
if mf.Album == "" {
@@ -274,7 +274,7 @@ func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {
mf.HasCoverArt = hasCoverArt(path)
}
- s.mediaFiles[mf.Id] = mf
+ s.mediaFiles[mf.ID] = mf
s.pmediaFiles[t.TrackID] = mf
return mf
@@ -288,8 +288,8 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *do
}
al := s.albums[id]
- al.Id = id
- al.ArtistId = ar.Id
+ al.ID = id
+ al.ArtistID = ar.ID
al.Name = mf.Album
al.Year = t.Year
al.Compilation = t.Compilation
@@ -308,7 +308,7 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *do
al.Duration += mf.Duration
if mf.HasCoverArt {
- al.CoverArtId = mf.Id
+ al.CoverArtId = mf.ID
al.CoverArtPath = mf.Path
}
@@ -333,7 +333,7 @@ func (s *ItunesScanner) collectArtists(t *itl.Track) *domain.Artist {
s.artists[id] = &domain.Artist{}
}
ar := s.artists[id]
- ar.Id = id
+ ar.ID = id
ar.Name = unescape(realArtistName(t))
if ar.Name == "" {
ar.Name = "[Unknown Artist]"