Scanning artists and albums too

This commit is contained in:
Deluan
2016-02-28 13:50:05 -05:00
parent bccfeec2d3
commit 14e52576a7
11 changed files with 209 additions and 51 deletions
+29 -7
View File
@@ -1,12 +1,34 @@
package models
type Album struct {
Id string
Name string
Artist *Artist
Id string
Name string
ArtistId string
CoverArtPath string
Year int
Compilation bool
Rating int
Year int
Compilation bool
Rating int
MediaFiles map[string]bool
}
func (a *Album) AdMediaFiles(mfs ...*MediaFile) {
for _, mf := range mfs {
a.MediaFiles[mf.Id] = true
}
}
func (a *Album) AddMediaFiles(mfs ...interface{}) {
if a.MediaFiles == nil {
a.MediaFiles = make(map[string]bool)
}
for _, v := range mfs {
switch v := v.(type) {
case *MediaFile:
a.MediaFiles[v.Id] = true
case map[string]bool:
for k, _ := range v {
a.MediaFiles[k] = true
}
}
}
}
+19 -2
View File
@@ -6,8 +6,9 @@ import (
)
type Artist struct {
Id string
Name string
Id string
Name string
Albums map[string]bool
}
func NoArticle(name string) string {
@@ -19,4 +20,20 @@ func NoArticle(name string) string {
}
}
return name
}
func (a *Artist) AddAlbums(albums ...interface{}) {
if a.Albums == nil {
a.Albums = make(map[string]bool)
}
for _, v := range albums {
switch v := v.(type) {
case *Album:
a.Albums[v.Id] = true
case map[string]bool:
for k, _ := range v {
a.Albums[k] = true
}
}
}
}