Skip to content

🎧 Your Personal Streaming Service

Polishing

Deluancad65f517cf6
diff --git a/main.go b/main.go
index 02a3efd0d..afcace0b1 100644
--- a/main.go
+++ b/main.go
@@ -13,6 +13,6 @@ func main() {
if beego.BConfig.RunMode == "prod" {
beego.SetLevel(beego.LevelInformational)
}
- beego.BConfig.Log.FileLineNum = false
+ //beego.BConfig.Log.FileLineNum = false
beego.Run()
}
diff --git a/persistence/checksum_repository.go b/persistence/checksum_repository.go
index 6730188f9..5891f6437 100644
--- a/persistence/checksum_repository.go
+++ b/persistence/checksum_repository.go
@@ -32,6 +32,7 @@ func (r *checkSumRepository) loadData() {
for _, p := range pairs {
r.data[string(p.Field)] = string(p.Value)
}
+ beego.Debug("Loaded", len(r.data), "checksums")
}
func (r *checkSumRepository) Put(id, sum string) error {
diff --git a/scanner/itunes_scanner.go b/scanner/itunes_scanner.go
index 55e23fa06..5342ea1d2 100644
--- a/scanner/itunes_scanner.go
+++ b/scanner/itunes_scanner.go
@@ -47,8 +47,7 @@ type plsRelation struct {
}
func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (int, error) {
- beego.Info("Starting iTunes import from:", path)
- beego.Info("Checking for updates since", lastModifiedSince.String())
+ beego.Info("Checking for updates since", lastModifiedSince.String(), "- Library:", path)
xml, _ := os.Open(path)
l, err := itl.ReadFromXML(xml)
if err != nil {
@@ -183,7 +182,26 @@ func (s *ItunesScanner) lastChangedDate(t *itl.Track) time.Time {
return c
}
+func (s *ItunesScanner) hasChanged(t *itl.Track) bool {
+ id := strconv.Itoa(t.TrackID)
+ oldSum, _ := s.checksumRepo.Get(id)
+ newSum := s.newSums[id]
+ return oldSum != newSum
+}
+
+// Calc sum of stats fields (whose changes are not reflected in DataModified)
+func (s *ItunesScanner) calcCheckSum(t *itl.Track) string {
+ id := strconv.Itoa(t.TrackID)
+ data := fmt.Sprint(t.DateModified, t.PlayCount, t.PlayDate, t.ArtworkCount, t.Loved, t.AlbumLoved,
+ t.Rating, t.AlbumRating, t.SkipCount, t.SkipDate)
+ sum := fmt.Sprintf("%x", md5.Sum([]byte(data)))
+ s.newSums[id] = sum
+ return sum
+}
+
func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {
+ s.calcCheckSum(t)
+
mf := &domain.MediaFile{}
mf.Id = strconv.Itoa(t.TrackID)
mf.Album = unescape(t.Album)
@@ -262,14 +280,6 @@ func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *do
return al
}
-func (s *ItunesScanner) hasChanged(t *itl.Track) bool {
- id := strconv.Itoa(t.TrackID)
- oldSum, _ := s.checksumRepo.Get(id)
- newSum := calcCheckSum(t)
- s.newSums[id] = newSum
- return oldSum != newSum
-}
-
func (s *ItunesScanner) collectArtists(t *itl.Track) *domain.Artist {
id := artistId(t)
_, found := s.artists[id]
@@ -340,12 +350,4 @@ func realArtistName(t *itl.Track) string {
return t.Artist
}
-// Calc sum of stats fields (whose changes are not reflected in DataModified)
-func calcCheckSum(t *itl.Track) string {
- data := fmt.Sprint(t.DateModified, t.PlayCount, t.PlayDate, t.ArtworkCount, t.Loved, t.AlbumLoved,
- t.Rating, t.AlbumRating, t.SkipCount, t.SkipDate)
- return fmt.Sprintf("%x", md5.Sum([]byte(data)))
-
-}
-
var _ Scanner = (*ItunesScanner)(nil)