More track info
This commit is contained in:
@@ -58,6 +58,10 @@ func (c *GetMusicDirectoryController) Get() {
|
|||||||
dir.Child[i].Artist = mf.AlbumArtist
|
dir.Child[i].Artist = mf.AlbumArtist
|
||||||
dir.Child[i].Genre = mf.Genre
|
dir.Child[i].Genre = mf.Genre
|
||||||
dir.Child[i].Track = mf.Track
|
dir.Child[i].Track = mf.Track
|
||||||
|
dir.Child[i].Duration = mf.Duration
|
||||||
|
dir.Child[i].Size = mf.Size
|
||||||
|
dir.Child[i].Suffix = mf.Suffix
|
||||||
|
dir.Child[i].BitRate = mf.BitRate
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
beego.Info("Id", id, "not found")
|
beego.Info("Id", id, "not found")
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ type MediaFile struct {
|
|||||||
AlbumId string `parent:"album"`
|
AlbumId string `parent:"album"`
|
||||||
Track int
|
Track int
|
||||||
Year int
|
Year int
|
||||||
|
Size string
|
||||||
|
Suffix string
|
||||||
|
Duration int
|
||||||
|
BitRate int
|
||||||
Genre string
|
Genre string
|
||||||
Compilation bool
|
Compilation bool
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ItunesScanner struct{}
|
type ItunesScanner struct{}
|
||||||
@@ -26,8 +28,17 @@ func (s *ItunesScanner) LoadFolder(path string) []Track {
|
|||||||
mediaFiles[i].Compilation = t.Compilation
|
mediaFiles[i].Compilation = t.Compilation
|
||||||
mediaFiles[i].Year = t.Year
|
mediaFiles[i].Year = t.Year
|
||||||
mediaFiles[i].TrackNumber = t.TrackNumber
|
mediaFiles[i].TrackNumber = t.TrackNumber
|
||||||
|
if t.Size > 0 {
|
||||||
|
mediaFiles[i].Size = strconv.Itoa(t.Size)
|
||||||
|
}
|
||||||
|
if t.TotalTime > 0 {
|
||||||
|
mediaFiles[i].Duration = t.TotalTime / 1000
|
||||||
|
}
|
||||||
|
mediaFiles[i].BitRate = t.BitRate
|
||||||
path, _ = url.QueryUnescape(t.Location)
|
path, _ = url.QueryUnescape(t.Location)
|
||||||
mediaFiles[i].Path = strings.TrimPrefix(path, "file://")
|
path = strings.TrimPrefix(path, "file://")
|
||||||
|
mediaFiles[i].Path = path
|
||||||
|
mediaFiles[i].Suffix = strings.TrimPrefix(filepath.Ext(path), ".")
|
||||||
mediaFiles[i].CreatedAt = t.DateAdded
|
mediaFiles[i].CreatedAt = t.DateAdded
|
||||||
mediaFiles[i].UpdatedAt = t.DateModified
|
mediaFiles[i].UpdatedAt = t.DateModified
|
||||||
i++
|
i++
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ func parseTrack(t *Track) (*domain.MediaFile, *domain.Album, *domain.Artist) {
|
|||||||
Track: t.TrackNumber,
|
Track: t.TrackNumber,
|
||||||
Genre: t.Genre,
|
Genre: t.Genre,
|
||||||
Year: t.Year,
|
Year: t.Year,
|
||||||
|
Size: t.Size,
|
||||||
|
Suffix: t.Suffix,
|
||||||
|
Duration: t.Duration,
|
||||||
|
BitRate: t.BitRate,
|
||||||
}
|
}
|
||||||
|
|
||||||
album := &domain.Album{
|
album := &domain.Album{
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ type Track struct {
|
|||||||
Genre string
|
Genre string
|
||||||
TrackNumber int
|
TrackNumber int
|
||||||
Year int
|
Year int
|
||||||
|
Size string
|
||||||
|
Suffix string
|
||||||
|
Duration int
|
||||||
|
BitRate int
|
||||||
Compilation bool
|
Compilation bool
|
||||||
CreatedAt time.Time
|
CreatedAt time.Time
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
|
|||||||
Reference in New Issue
Block a user