Adding song and album counts

This commit is contained in:
Deluan
2016-03-27 20:13:00 -04:00
parent 167e7a1825
commit 3cc92a32bd
9 changed files with 32 additions and 7 deletions
+1 -1
View File
@@ -303,7 +303,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}
artists[indexName] = domain.ArtistInfo{ArtistId: a.Id, Artist: a.Name, AlbumCount: a.AlbumCount}
}
func (i *Importer) findGroup(ig utils.IndexGroups, name string) string {
+16
View File
@@ -64,6 +64,8 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
s.pplaylists = make(map[string]plsRelation)
s.pmediaFiles = make(map[int]*domain.MediaFile)
s.newSums = make(map[string]string)
songsPerAlbum := make(map[string]int)
albumsPerArtist := make(map[string]map[string]bool)
i := 0
for _, t := range l.Tracks {
@@ -73,6 +75,12 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
ar := s.collectArtists(&t)
mf := s.collectMediaFiles(&t)
s.collectAlbums(&t, mf, ar)
songsPerAlbum[mf.AlbumId]++
if albumsPerArtist[mf.ArtistId] == nil {
albumsPerArtist[mf.ArtistId] = make(map[string]bool)
}
albumsPerArtist[mf.ArtistId][mf.AlbumId] = true
}
i++
if i%1000 == 0 {
@@ -80,6 +88,14 @@ func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (i
}
}
for albumId, count := range songsPerAlbum {
s.albums[albumId].SongCount = count
}
for artistId, albums := range albumsPerArtist {
s.artists[artistId].AlbumCount = len(albums)
}
if err := s.checksumRepo.SetData(s.newSums); err != nil {
beego.Error("Error saving checksums:", err)
} else {