fetching from object not from source
This commit is contained in:
@@ -99,7 +99,7 @@ func compileSource(source data.Source) (data.Source, error) {
|
||||
return source, errors.New("couldn't find corresponding object source on " + sourceType.Name + " for " + source.Url)
|
||||
}
|
||||
|
||||
func Fetch(source data.Source) (data.MusicObject, error) {
|
||||
func FetchSource(source data.Source) (data.MusicObject, error) {
|
||||
// the fetch function without the post processing of the music objects
|
||||
source, err := compileSource(source)
|
||||
if err != nil {
|
||||
@@ -147,10 +147,29 @@ func Fetch(source data.Source) (data.MusicObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func FetchList(source data.Source) ([]data.MusicObject, error) {
|
||||
func Fetch(musicObject data.MusicObject) (data.MusicObject, error) {
|
||||
sources := musicObject.GetSources()
|
||||
|
||||
if len(sources) <= 0 {
|
||||
return musicObject, errors.New("didn't find a source for object")
|
||||
}
|
||||
|
||||
for _, source := range sources {
|
||||
newMusicObject, err := FetchSource(source)
|
||||
if err != nil {
|
||||
return musicObject, err
|
||||
}
|
||||
|
||||
musicObject = musicObject.Merge(newMusicObject)
|
||||
}
|
||||
|
||||
return musicObject, nil
|
||||
}
|
||||
|
||||
func FetchList(musicObject data.MusicObject) ([]data.MusicObject, error) {
|
||||
res := []data.MusicObject{}
|
||||
|
||||
musicObject, err := Fetch(source)
|
||||
musicObject, err := Fetch(musicObject)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user