🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Updated Date takes Last Played into account
Deluan71f1fab575dc
diff --git a/README.md b/README.mdindex 21c0b6bfc..0b87f55fd 100644--- a/README.md+++ b/README.md@@ -1,7 +1,7 @@GoSonic=======-[](https://travis-ci.org/deluan/gosonic)+[](https://travis-ci.org/deluan/gosonic) [](https://goreportcard.com/report/github.com/deluan/gosonic)__This is still a work in progress, and has no releases available__diff --git a/scanner/importer.go b/scanner/importer.goindex f767d1bd0..8d4587cce 100644--- a/scanner/importer.go+++ b/scanner/importer.go@@ -107,7 +107,7 @@ func (i *Importer) importLibrary() (err error) {beego.Error("Error indexing artist:", err)}if !i.lastScan.IsZero() {- beego.Debug("Updated Track:", mf.Title)+ beego.Debug("-- Updated Track:", mf.Title)}}@@ -125,7 +125,7 @@ func (i *Importer) importLibrary() (err error) {beego.Error("Error indexing artist:", err)}if !i.lastScan.IsZero() {- beego.Debug(fmt.Sprintf(`Updated Album:"%s" from "%s"`, al.Name, al.Artist))+ beego.Debug(fmt.Sprintf(`-- Updated Album:"%s" from "%s"`, al.Name, al.Artist))}}diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.goindex eba006b35..53263f29c 100644--- a/scanner/itunes_scanner.go+++ b/scanner/itunes_scanner.go@@ -157,6 +157,17 @@ func (s *ItunesScanner) fullPath(pID string) string {return fmt.Sprintf("%s > %s", s.fullPath(rel.parentPID), rel.name)}+func (s *ItunesScanner) changeDate(t *itl.Track) time.Time {+ allDates := []time.Time{t.DateModified, t.PlayDateUTC}+ c := time.Time{}+ for _, d := range allDates {+ if c.Before(d) {+ c = d+ }+ }+ return c+}+func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {mf := &domain.MediaFile{}mf.Id = strconv.Itoa(t.TrackID)@@ -188,7 +199,7 @@ func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {mf.Suffix = strings.TrimPrefix(filepath.Ext(path), ".")mf.CreatedAt = t.DateAdded- mf.UpdatedAt = t.DateModified+ mf.UpdatedAt = s.changeDate(t)if mf.UpdatedAt.After(s.lastModifiedSince) {mf.HasCoverArt = hasCoverArt(path)@@ -229,8 +240,9 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *doif al.CreatedAt.IsZero() || t.DateAdded.Before(al.CreatedAt) {al.CreatedAt = t.DateAdded}- if al.UpdatedAt.IsZero() || t.DateModified.After(al.UpdatedAt) {- al.UpdatedAt = t.DateModified+ trackUpdate := s.changeDate(t)+ if al.UpdatedAt.IsZero() || trackUpdate.After(al.UpdatedAt) {+ al.UpdatedAt = trackUpdate}return al