2016-02-26 07:32:31 +01:00
|
|
|
package scanner
|
|
|
|
|
|
|
|
import (
|
2016-03-04 22:42:09 +01:00
|
|
|
"crypto/md5"
|
|
|
|
"fmt"
|
2016-03-15 16:04:17 +01:00
|
|
|
"html"
|
|
|
|
"mime"
|
2016-02-26 07:32:31 +01:00
|
|
|
"net/url"
|
|
|
|
"os"
|
2016-03-03 05:51:26 +01:00
|
|
|
"path/filepath"
|
2016-03-15 16:04:17 +01:00
|
|
|
"regexp"
|
2016-03-03 06:07:10 +01:00
|
|
|
"strconv"
|
2016-03-03 06:46:23 +01:00
|
|
|
"strings"
|
2016-03-07 03:32:31 +01:00
|
|
|
"time"
|
2016-03-08 20:18:17 +01:00
|
|
|
|
2017-04-01 15:47:14 +02:00
|
|
|
"github.com/cloudsonic/sonic-server/conf"
|
|
|
|
"github.com/cloudsonic/sonic-server/domain"
|
2020-01-09 02:45:07 +01:00
|
|
|
"github.com/cloudsonic/sonic-server/log"
|
2017-04-01 15:51:25 +02:00
|
|
|
"github.com/dhowden/itl"
|
2016-03-08 20:18:17 +01:00
|
|
|
"github.com/dhowden/tag"
|
2016-02-26 07:32:31 +01:00
|
|
|
)
|
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
type ItunesScanner struct {
|
2016-03-07 03:32:31 +01:00
|
|
|
mediaFiles map[string]*domain.MediaFile
|
|
|
|
albums map[string]*domain.Album
|
|
|
|
artists map[string]*domain.Artist
|
2016-03-09 19:51:17 +01:00
|
|
|
playlists map[string]*domain.Playlist
|
2016-03-10 01:48:43 +01:00
|
|
|
pplaylists map[string]plsRelation
|
2016-03-23 16:43:20 +01:00
|
|
|
pmediaFiles map[int]*domain.MediaFile
|
2016-03-07 03:32:31 +01:00
|
|
|
lastModifiedSince time.Time
|
2016-03-15 16:04:17 +01:00
|
|
|
checksumRepo CheckSumRepository
|
|
|
|
newSums map[string]string
|
2016-03-04 22:42:09 +01:00
|
|
|
}
|
2016-02-26 07:32:31 +01:00
|
|
|
|
2016-03-15 16:04:17 +01:00
|
|
|
func NewItunesScanner(checksumRepo CheckSumRepository) *ItunesScanner {
|
|
|
|
return &ItunesScanner{checksumRepo: checksumRepo}
|
|
|
|
}
|
|
|
|
|
|
|
|
type CheckSumRepository interface {
|
|
|
|
Put(id, sum string) error
|
|
|
|
Get(id string) (string, error)
|
|
|
|
SetData(newSums map[string]string) error
|
2016-03-11 05:19:13 +01:00
|
|
|
}
|
|
|
|
|
2016-03-10 01:48:43 +01:00
|
|
|
type plsRelation struct {
|
|
|
|
pID string
|
|
|
|
parentPID string
|
|
|
|
name string
|
|
|
|
}
|
|
|
|
|
2016-03-07 03:32:31 +01:00
|
|
|
func (s *ItunesScanner) ScanLibrary(lastModifiedSince time.Time, path string) (int, error) {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Debug("Checking for updates", "lastModifiedSince", lastModifiedSince, "library", path)
|
2016-02-26 07:32:31 +01:00
|
|
|
xml, _ := os.Open(path)
|
2016-03-04 22:42:09 +01:00
|
|
|
l, err := itl.ReadFromXML(xml)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Debug("Loaded tracks", "total", len(l.Tracks))
|
2016-03-04 22:42:09 +01:00
|
|
|
|
2016-03-07 03:32:31 +01:00
|
|
|
s.lastModifiedSince = lastModifiedSince
|
2016-03-04 22:42:09 +01:00
|
|
|
s.mediaFiles = make(map[string]*domain.MediaFile)
|
|
|
|
s.albums = make(map[string]*domain.Album)
|
|
|
|
s.artists = make(map[string]*domain.Artist)
|
2016-03-09 19:51:17 +01:00
|
|
|
s.playlists = make(map[string]*domain.Playlist)
|
2016-03-10 01:48:43 +01:00
|
|
|
s.pplaylists = make(map[string]plsRelation)
|
2016-03-23 16:43:20 +01:00
|
|
|
s.pmediaFiles = make(map[int]*domain.MediaFile)
|
2016-03-15 16:04:17 +01:00
|
|
|
s.newSums = make(map[string]string)
|
2016-03-28 02:13:00 +02:00
|
|
|
songsPerAlbum := make(map[string]int)
|
|
|
|
albumsPerArtist := make(map[string]map[string]bool)
|
2016-02-26 07:32:31 +01:00
|
|
|
|
|
|
|
i := 0
|
2016-03-04 22:42:09 +01:00
|
|
|
for _, t := range l.Tracks {
|
2016-03-10 15:13:23 +01:00
|
|
|
if !s.skipTrack(&t) {
|
2016-03-18 16:33:50 +01:00
|
|
|
s.calcCheckSum(&t)
|
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
ar := s.collectArtists(&t)
|
|
|
|
mf := s.collectMediaFiles(&t)
|
|
|
|
s.collectAlbums(&t, mf, ar)
|
2016-03-28 02:13:00 +02:00
|
|
|
|
|
|
|
songsPerAlbum[mf.AlbumId]++
|
|
|
|
if albumsPerArtist[mf.ArtistId] == nil {
|
|
|
|
albumsPerArtist[mf.ArtistId] = make(map[string]bool)
|
|
|
|
}
|
|
|
|
albumsPerArtist[mf.ArtistId][mf.AlbumId] = true
|
2016-03-05 04:50:04 +01:00
|
|
|
}
|
|
|
|
i++
|
|
|
|
if i%1000 == 0 {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Debug(fmt.Sprintf("Processed %d tracks", i), "artists", len(s.artists), "albums", len(s.albums), "songs", len(s.mediaFiles))
|
2016-02-26 07:32:31 +01:00
|
|
|
}
|
|
|
|
}
|
2016-03-09 19:51:17 +01:00
|
|
|
|
2016-03-28 02:13:00 +02:00
|
|
|
for albumId, count := range songsPerAlbum {
|
|
|
|
s.albums[albumId].SongCount = count
|
|
|
|
}
|
|
|
|
|
|
|
|
for artistId, albums := range albumsPerArtist {
|
|
|
|
s.artists[artistId].AlbumCount = len(albums)
|
|
|
|
}
|
|
|
|
|
2016-03-15 16:04:17 +01:00
|
|
|
if err := s.checksumRepo.SetData(s.newSums); err != nil {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Error("Error saving checksums", err)
|
2016-03-15 16:04:17 +01:00
|
|
|
} else {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Debug("Saved checksums", "total", len(s.newSums))
|
2016-03-15 16:04:17 +01:00
|
|
|
}
|
|
|
|
|
2017-04-01 15:47:14 +02:00
|
|
|
ignFolders := conf.Sonic.PlsIgnoreFolders
|
|
|
|
ignPatterns := strings.Split(conf.Sonic.PlsIgnoredPatterns, ";")
|
2016-03-09 19:51:17 +01:00
|
|
|
for _, p := range l.Playlists {
|
2016-03-10 01:48:43 +01:00
|
|
|
rel := plsRelation{pID: p.PlaylistPersistentID, parentPID: p.ParentPersistentID, name: unescape(p.Name)}
|
|
|
|
s.pplaylists[p.PlaylistPersistentID] = rel
|
|
|
|
fullPath := s.fullPath(p.PlaylistPersistentID)
|
|
|
|
|
|
|
|
if s.skipPlaylist(&p, ignFolders, ignPatterns, fullPath) {
|
2016-03-10 01:06:50 +01:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2016-03-10 01:48:43 +01:00
|
|
|
s.collectPlaylists(&p, fullPath)
|
2016-03-09 19:51:17 +01:00
|
|
|
}
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Debug("Processed playlists", "total", len(l.Playlists))
|
2016-03-09 19:51:17 +01:00
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
return len(l.Tracks), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ItunesScanner) MediaFiles() map[string]*domain.MediaFile {
|
|
|
|
return s.mediaFiles
|
|
|
|
}
|
|
|
|
func (s *ItunesScanner) Albums() map[string]*domain.Album {
|
|
|
|
return s.albums
|
|
|
|
}
|
|
|
|
func (s *ItunesScanner) Artists() map[string]*domain.Artist {
|
|
|
|
return s.artists
|
|
|
|
}
|
2016-03-09 19:51:17 +01:00
|
|
|
func (s *ItunesScanner) Playlists() map[string]*domain.Playlist {
|
|
|
|
return s.playlists
|
|
|
|
}
|
|
|
|
|
2016-03-10 15:13:23 +01:00
|
|
|
func (s *ItunesScanner) skipTrack(t *itl.Track) bool {
|
2020-01-11 07:38:40 +01:00
|
|
|
if t.Podcast {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if conf.Sonic.DevDisableFileCheck {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasPrefix(t.Location, "file://") {
|
2016-03-10 15:13:23 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
ext := filepath.Ext(t.Location)
|
|
|
|
m := mime.TypeByExtension(ext)
|
|
|
|
|
|
|
|
return !strings.HasPrefix(m, "audio/")
|
|
|
|
}
|
|
|
|
|
2016-03-10 01:48:43 +01:00
|
|
|
func (s *ItunesScanner) skipPlaylist(p *itl.Playlist, ignFolders bool, ignPatterns []string, fullPath string) bool {
|
2016-03-10 15:13:23 +01:00
|
|
|
// Skip all "special" iTunes playlists, and also ignored patterns
|
2016-03-14 03:11:44 +01:00
|
|
|
if p.Master || p.Music || p.Audiobooks || p.Movies || p.TVShows || p.Podcasts || p.ITunesU || (ignFolders && p.Folder) {
|
2016-03-10 01:48:43 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, p := range ignPatterns {
|
2020-01-06 21:17:44 +01:00
|
|
|
if p == "" {
|
|
|
|
continue
|
|
|
|
}
|
2016-03-10 01:48:43 +01:00
|
|
|
m, _ := regexp.MatchString(p, fullPath)
|
|
|
|
if m {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ItunesScanner) collectPlaylists(p *itl.Playlist, fullPath string) {
|
2016-03-09 19:51:17 +01:00
|
|
|
pl := &domain.Playlist{}
|
2016-03-23 16:43:20 +01:00
|
|
|
pl.Id = p.PlaylistPersistentID
|
2016-03-10 01:48:43 +01:00
|
|
|
pl.Name = unescape(p.Name)
|
|
|
|
pl.FullPath = fullPath
|
2016-03-09 19:51:17 +01:00
|
|
|
pl.Tracks = make([]string, 0, len(p.PlaylistItems))
|
|
|
|
for _, item := range p.PlaylistItems {
|
2016-03-23 16:43:20 +01:00
|
|
|
if mf, found := s.pmediaFiles[item.TrackID]; found {
|
|
|
|
pl.Tracks = append(pl.Tracks, mf.Id)
|
2016-03-21 17:26:55 +01:00
|
|
|
pl.Duration += mf.Duration
|
2016-03-09 19:51:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if len(pl.Tracks) > 0 {
|
|
|
|
s.playlists[pl.Id] = pl
|
|
|
|
}
|
|
|
|
}
|
2016-03-04 22:42:09 +01:00
|
|
|
|
2016-03-10 01:48:43 +01:00
|
|
|
func (s *ItunesScanner) fullPath(pID string) string {
|
|
|
|
rel, found := s.pplaylists[pID]
|
|
|
|
if !found {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
if rel.parentPID == "" {
|
|
|
|
return rel.name
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("%s > %s", s.fullPath(rel.parentPID), rel.name)
|
|
|
|
}
|
|
|
|
|
2016-03-13 18:11:16 +01:00
|
|
|
func (s *ItunesScanner) lastChangedDate(t *itl.Track) time.Time {
|
2016-03-15 16:04:17 +01:00
|
|
|
if s.hasChanged(t) {
|
|
|
|
return time.Now()
|
|
|
|
}
|
2016-03-11 23:09:47 +01:00
|
|
|
allDates := []time.Time{t.DateModified, t.PlayDateUTC}
|
|
|
|
c := time.Time{}
|
|
|
|
for _, d := range allDates {
|
|
|
|
if c.Before(d) {
|
|
|
|
c = d
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
2016-03-15 18:17:51 +01:00
|
|
|
func (s *ItunesScanner) hasChanged(t *itl.Track) bool {
|
2016-03-23 16:43:20 +01:00
|
|
|
id := t.PersistentID
|
2016-03-15 18:17:51 +01:00
|
|
|
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 {
|
2016-03-23 16:43:20 +01:00
|
|
|
id := t.PersistentID
|
2016-03-15 18:17:51 +01:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
func (s *ItunesScanner) collectMediaFiles(t *itl.Track) *domain.MediaFile {
|
|
|
|
mf := &domain.MediaFile{}
|
2016-03-23 16:43:20 +01:00
|
|
|
mf.Id = t.PersistentID
|
2016-03-04 22:42:09 +01:00
|
|
|
mf.Album = unescape(t.Album)
|
|
|
|
mf.AlbumId = albumId(t)
|
2016-03-21 14:50:46 +01:00
|
|
|
mf.ArtistId = artistId(t)
|
2016-03-04 22:42:09 +01:00
|
|
|
mf.Title = unescape(t.Name)
|
|
|
|
mf.Artist = unescape(t.Artist)
|
2016-03-23 17:00:40 +01:00
|
|
|
if mf.Album == "" {
|
|
|
|
mf.Album = "[Unknown Album]"
|
|
|
|
}
|
|
|
|
if mf.Artist == "" {
|
|
|
|
mf.Artist = "[Unknown Artist]"
|
|
|
|
}
|
2016-03-04 22:42:09 +01:00
|
|
|
mf.AlbumArtist = unescape(t.AlbumArtist)
|
|
|
|
mf.Genre = unescape(t.Genre)
|
|
|
|
mf.Compilation = t.Compilation
|
|
|
|
mf.Starred = t.Loved
|
2016-03-21 15:24:40 +01:00
|
|
|
mf.Rating = t.Rating / 20
|
2016-03-04 23:01:14 +01:00
|
|
|
mf.PlayCount = t.PlayCount
|
|
|
|
mf.PlayDate = t.PlayDateUTC
|
2016-03-04 22:42:09 +01:00
|
|
|
mf.Year = t.Year
|
|
|
|
mf.TrackNumber = t.TrackNumber
|
|
|
|
mf.DiscNumber = t.DiscNumber
|
|
|
|
if t.Size > 0 {
|
|
|
|
mf.Size = strconv.Itoa(t.Size)
|
|
|
|
}
|
|
|
|
if t.TotalTime > 0 {
|
|
|
|
mf.Duration = t.TotalTime / 1000
|
|
|
|
}
|
|
|
|
mf.BitRate = t.BitRate
|
|
|
|
|
2016-03-12 17:28:59 +01:00
|
|
|
path := extractPath(t.Location)
|
2016-03-04 22:42:09 +01:00
|
|
|
mf.Path = path
|
|
|
|
mf.Suffix = strings.TrimPrefix(filepath.Ext(path), ".")
|
2016-03-07 03:32:31 +01:00
|
|
|
|
2016-03-07 15:24:35 +01:00
|
|
|
mf.CreatedAt = t.DateAdded
|
2016-03-13 18:11:16 +01:00
|
|
|
mf.UpdatedAt = s.lastChangedDate(t)
|
2016-03-07 15:24:35 +01:00
|
|
|
|
2020-01-11 07:38:40 +01:00
|
|
|
if mf.UpdatedAt.After(s.lastModifiedSince) && !conf.Sonic.DevDisableFileCheck {
|
2016-03-07 03:32:31 +01:00
|
|
|
mf.HasCoverArt = hasCoverArt(path)
|
|
|
|
}
|
2016-03-04 22:42:09 +01:00
|
|
|
|
|
|
|
s.mediaFiles[mf.Id] = mf
|
2016-03-23 16:43:20 +01:00
|
|
|
s.pmediaFiles[t.TrackID] = mf
|
2016-03-04 22:42:09 +01:00
|
|
|
|
|
|
|
return mf
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ItunesScanner) collectAlbums(t *itl.Track, mf *domain.MediaFile, ar *domain.Artist) *domain.Album {
|
|
|
|
id := albumId(t)
|
|
|
|
_, found := s.albums[id]
|
|
|
|
if !found {
|
|
|
|
s.albums[id] = &domain.Album{}
|
|
|
|
}
|
|
|
|
|
|
|
|
al := s.albums[id]
|
|
|
|
al.Id = id
|
|
|
|
al.ArtistId = ar.Id
|
|
|
|
al.Name = mf.Album
|
|
|
|
al.Year = t.Year
|
|
|
|
al.Compilation = t.Compilation
|
|
|
|
al.Starred = t.AlbumLoved
|
2016-03-21 15:24:40 +01:00
|
|
|
al.Rating = t.AlbumRating / 20
|
2016-03-04 23:01:14 +01:00
|
|
|
al.PlayCount += t.PlayCount
|
2016-03-04 22:42:09 +01:00
|
|
|
al.Genre = mf.Genre
|
|
|
|
al.Artist = mf.Artist
|
2016-03-04 23:35:13 +01:00
|
|
|
al.AlbumArtist = ar.Name
|
2016-03-23 17:00:40 +01:00
|
|
|
if al.Name == "" {
|
|
|
|
al.Name = "[Unknown Album]"
|
|
|
|
}
|
|
|
|
if al.Artist == "" {
|
|
|
|
al.Artist = "[Unknown Artist]"
|
|
|
|
}
|
2016-03-22 02:14:04 +01:00
|
|
|
al.Duration += mf.Duration
|
2016-03-04 22:42:09 +01:00
|
|
|
|
|
|
|
if mf.HasCoverArt {
|
|
|
|
al.CoverArtId = mf.Id
|
2016-03-30 16:01:37 +02:00
|
|
|
al.CoverArtPath = mf.Path
|
2016-03-04 22:42:09 +01:00
|
|
|
}
|
|
|
|
|
2016-03-04 23:01:14 +01:00
|
|
|
if al.PlayDate.IsZero() || t.PlayDateUTC.After(al.PlayDate) {
|
|
|
|
al.PlayDate = t.PlayDateUTC
|
|
|
|
}
|
2016-03-04 22:42:09 +01:00
|
|
|
if al.CreatedAt.IsZero() || t.DateAdded.Before(al.CreatedAt) {
|
|
|
|
al.CreatedAt = t.DateAdded
|
|
|
|
}
|
2016-03-13 18:11:16 +01:00
|
|
|
trackUpdate := s.lastChangedDate(t)
|
2016-03-11 23:09:47 +01:00
|
|
|
if al.UpdatedAt.IsZero() || trackUpdate.After(al.UpdatedAt) {
|
|
|
|
al.UpdatedAt = trackUpdate
|
2016-03-04 22:42:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return al
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *ItunesScanner) collectArtists(t *itl.Track) *domain.Artist {
|
|
|
|
id := artistId(t)
|
|
|
|
_, found := s.artists[id]
|
|
|
|
if !found {
|
|
|
|
s.artists[id] = &domain.Artist{}
|
|
|
|
}
|
|
|
|
ar := s.artists[id]
|
|
|
|
ar.Id = id
|
|
|
|
ar.Name = unescape(realArtistName(t))
|
2016-03-23 17:00:40 +01:00
|
|
|
if ar.Name == "" {
|
|
|
|
ar.Name = "[Unknown Artist]"
|
|
|
|
}
|
2016-03-04 22:42:09 +01:00
|
|
|
|
|
|
|
return ar
|
|
|
|
}
|
|
|
|
|
|
|
|
func albumId(t *itl.Track) string {
|
2016-03-06 17:55:17 +01:00
|
|
|
s := strings.ToLower(fmt.Sprintf("%s\\%s", realArtistName(t), t.Album))
|
2016-03-04 22:42:09 +01:00
|
|
|
return fmt.Sprintf("%x", md5.Sum([]byte(s)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func artistId(t *itl.Track) string {
|
2016-03-06 17:55:17 +01:00
|
|
|
return fmt.Sprintf("%x", md5.Sum([]byte(strings.ToLower(realArtistName(t)))))
|
2016-03-04 22:42:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func hasCoverArt(path string) bool {
|
2016-03-05 04:29:29 +01:00
|
|
|
defer func() {
|
|
|
|
if r := recover(); r != nil {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Error("Panic reading tag", "path", path, "error", r)
|
2016-03-05 04:29:29 +01:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
if _, err := os.Stat(path); err == nil {
|
|
|
|
f, err := os.Open(path)
|
|
|
|
if err != nil {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Warn("Error opening file", "path", path, err)
|
2016-03-04 22:42:09 +01:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
m, err := tag.ReadFrom(f)
|
|
|
|
if err != nil {
|
2020-01-09 02:45:07 +01:00
|
|
|
log.Warn("Error reading tag from file", "path", path, err)
|
2016-03-05 01:49:51 +01:00
|
|
|
return false
|
2016-03-04 22:42:09 +01:00
|
|
|
}
|
|
|
|
return m.Picture() != nil
|
|
|
|
}
|
2020-01-09 02:45:07 +01:00
|
|
|
//log.Warn("File not found", "path", path)
|
2016-03-04 22:42:09 +01:00
|
|
|
return false
|
2016-02-26 07:32:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-03 06:07:10 +01:00
|
|
|
func unescape(str string) string {
|
2016-03-09 02:54:50 +01:00
|
|
|
return html.UnescapeString(str)
|
2016-03-02 00:19:57 +01:00
|
|
|
}
|
|
|
|
|
2016-03-12 17:28:59 +01:00
|
|
|
func extractPath(loc string) string {
|
|
|
|
path := strings.Replace(loc, "+", "%2B", -1)
|
|
|
|
path, _ = url.QueryUnescape(path)
|
|
|
|
path = html.UnescapeString(path)
|
|
|
|
return strings.TrimPrefix(path, "file://")
|
|
|
|
}
|
|
|
|
|
2016-03-04 22:42:09 +01:00
|
|
|
func realArtistName(t *itl.Track) string {
|
|
|
|
switch {
|
|
|
|
case t.Compilation:
|
|
|
|
return "Various Artists"
|
|
|
|
case t.AlbumArtist != "":
|
|
|
|
return t.AlbumArtist
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.Artist
|
|
|
|
}
|
|
|
|
|
2016-03-02 19:18:39 +01:00
|
|
|
var _ Scanner = (*ItunesScanner)(nil)
|