mirror of
https://github.com/navidrome/navidrome.git
synced 2025-05-07 13:51:10 +03:00
Cleaning up a bit
This commit is contained in:
parent
cdb40ecd3e
commit
9e72bc3c0a
@ -108,26 +108,22 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
} else if _, err := filesRegex.Groups(o.Path); err == nil {
|
} else if _, err := filesRegex.Groups(o.Path); err == nil {
|
||||||
return cds.doFiles(ret, o.Path, host)
|
return cds.doFiles(ret, o.Path, host)
|
||||||
} else if matchResults, err := artistRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := artistRegex.Groups(o.Path); err == nil {
|
||||||
log.Debug(fmt.Sprintf("Artist MATCH: %+v", matchResults))
|
|
||||||
if matchResults["ArtistAlbumTrack"] != "" {
|
if matchResults["ArtistAlbumTrack"] != "" {
|
||||||
//TODO
|
//TODO
|
||||||
log.Debug("Artist Get a track ")
|
log.Debug("Artist Get a track ")
|
||||||
} else if matchResults["ArtistAlbum"] != "" {
|
} else if matchResults["ArtistAlbum"] != "" {
|
||||||
log.Debug("Artist Get an album ")
|
|
||||||
album := matchResults["ArtistAlbum"]
|
|
||||||
|
|
||||||
albumResponse, _ := cds.ds.Album(cds.ctx).Get(album)
|
|
||||||
log.Debug(fmt.Sprintf("Album Returned: %+v for %s", albumResponse, album))
|
|
||||||
basePath := path.Join("/Music/Artists", matchResults["Artist"], matchResults["ArtistAlbum"])
|
basePath := path.Join("/Music/Artists", matchResults["Artist"], matchResults["ArtistAlbum"])
|
||||||
|
|
||||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": albumResponse.ID}})
|
//albumResponse, _ := cds.ds.Album(cds.ctx).Get(matchResults["ArtistAlbum"])
|
||||||
|
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["ArtistAlbum"]}})
|
||||||
|
|
||||||
return cds.doMediaFiles(tracks, basePath, ret, host)
|
return cds.doMediaFiles(tracks, basePath, ret, host)
|
||||||
|
|
||||||
} else if matchResults["Artist"] != "" {
|
} else if matchResults["Artist"] != "" {
|
||||||
log.Debug(fmt.Sprintf("Artist Get an Artist: %s", matchResults["Artist"]))
|
|
||||||
allAlbumsForThisArtist, _ := cds.ds.Album(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_artist_id": matchResults["Artist"]}})
|
|
||||||
basePath := path.Join("/Music/Artists", matchResults["Artist"])
|
basePath := path.Join("/Music/Artists", matchResults["Artist"])
|
||||||
|
|
||||||
|
allAlbumsForThisArtist, _ := cds.ds.Album(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_artist_id": matchResults["Artist"]}})
|
||||||
|
|
||||||
return cds.doAlbums(allAlbumsForThisArtist, basePath, ret, host)
|
return cds.doAlbums(allAlbumsForThisArtist, basePath, ret, host)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -149,18 +145,15 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
} else if matchResults, err := albumRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := albumRegex.Groups(o.Path); err == nil {
|
||||||
log.Debug("Album MATCH")
|
|
||||||
if matchResults["AlbumTrack"] != "" {
|
if matchResults["AlbumTrack"] != "" {
|
||||||
log.Debug("AlbumTrack MATCH")
|
log.Debug("TODO AlbumTrack MATCH")
|
||||||
//TODO
|
|
||||||
} else if matchResults["AlbumTitle"] != "" {
|
} else if matchResults["AlbumTitle"] != "" {
|
||||||
log.Debug("AlbumTitle MATCH")
|
|
||||||
albumResponse, _ := cds.ds.Album(cds.ctx).Get(matchResults["AlbumTitle"])
|
|
||||||
basePath := path.Join("/Music/Albums", matchResults["AlbumTitle"])
|
basePath := path.Join("/Music/Albums", matchResults["AlbumTitle"])
|
||||||
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": albumResponse.ID}})
|
|
||||||
|
tracks, _ := cds.ds.MediaFile(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{"album_id": matchResults["AlbumTitle"]}})
|
||||||
|
|
||||||
return cds.doMediaFiles(tracks, basePath, ret, host)
|
return cds.doMediaFiles(tracks, basePath, ret, host)
|
||||||
} else {
|
} else {
|
||||||
log.Debug("albumRegex else MATCH")
|
|
||||||
indexes, err := cds.ds.Album(cds.ctx).GetAllWithoutGenres()
|
indexes, err := cds.ds.Album(cds.ctx).GetAllWithoutGenres()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error retrieving Indexes: %+v", err)
|
fmt.Printf("Error retrieving Indexes: %+v", err)
|
||||||
@ -177,18 +170,14 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
}
|
}
|
||||||
} else if matchResults, err := genresRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := genresRegex.Groups(o.Path); err == nil {
|
||||||
log.Debug("Genre MATCH")
|
log.Debug("Genre MATCH")
|
||||||
if _, exists := matchResults["GenreTrack"]; exists {
|
if matchResults["GenreTrack"] != "" {
|
||||||
log.Debug("GenreTrack MATCH")
|
log.Debug("TODO GenreTrack MATCH")
|
||||||
//TODO
|
} else if matchResults["GenreArtist"] != "" {
|
||||||
} else if _, exists := matchResults["GenreArtist"]; exists {
|
log.Debug("TODO GenreArtist MATCH")
|
||||||
log.Debug("GenreArtist MATCH")
|
} else if matchResults["Genre"] != "" {
|
||||||
//TODO
|
//x, xerr := cds.ds.Album(cds.ctx).GetAll(model.QueryOptions{Filters: squirrel.Eq{}})
|
||||||
} else if genre, exists := matchResults["Genre"]; exists {
|
log.Debug("TODO Get albums for Genre X")
|
||||||
log.Debug("Genre only MATCH")
|
|
||||||
x, xerr := cds.ds.Album(cds.ctx).Get(genre)
|
|
||||||
log.Debug(fmt.Sprintf("Genre: %+v", x), xerr)
|
|
||||||
} else {
|
} else {
|
||||||
log.Debug("Genre else MATCH")
|
|
||||||
indexes, err := cds.ds.Genre(cds.ctx).GetAll()
|
indexes, err := cds.ds.Genre(cds.ctx).GetAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Error retrieving Indexes: %+v", err)
|
fmt.Printf("Error retrieving Indexes: %+v", err)
|
||||||
@ -204,16 +193,16 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
} else if matchResults, err := recentRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := recentRegex.Groups(o.Path); err == nil {
|
||||||
log.Debug("recent MATCH")
|
log.Debug("TODO recent MATCH")
|
||||||
fmt.Printf("%+v", matchResults)
|
fmt.Printf("%+v", matchResults)
|
||||||
} else if matchResults, err := playlistRegex.Groups(o.Path); err == nil {
|
} else if matchResults, err := playlistRegex.Groups(o.Path); err == nil {
|
||||||
log.Debug("Playlist MATCH")
|
log.Debug("TODO Playlist MATCH")
|
||||||
if _, exists := matchResults["PlaylistTrack"]; exists {
|
if matchResults["PlaylistTrack"] != "" {
|
||||||
log.Debug("PlaylistTrack MATCH")
|
log.Debug("TODO PlaylistTrack MATCH")
|
||||||
} else if playlist, exists := matchResults["Playlist"]; exists {
|
} else if matchResults["Playlist"] != "" {
|
||||||
log.Debug("Playlist only MATCH")
|
log.Debug("Playlist only MATCH")
|
||||||
x, xerr := cds.ds.Playlist(cds.ctx).Get(playlist)
|
x, xerr := cds.ds.Playlist(cds.ctx).Get(matchResults["Playlist"])
|
||||||
log.Debug(fmt.Sprintf("Playlist: %+v", x), xerr)
|
log.Debug(fmt.Sprintf("TODO Playlist: %+v", x), xerr)
|
||||||
} else {
|
} else {
|
||||||
log.Debug("Playlist else MATCH")
|
log.Debug("Playlist else MATCH")
|
||||||
indexes, err := cds.ds.Playlist(cds.ctx).GetAll()
|
indexes, err := cds.ds.Playlist(cds.ctx).GetAll()
|
||||||
@ -231,26 +220,6 @@ func (cds *contentDirectoryService) readContainer(o object, host string) (ret []
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
deluan
|
|
||||||
—
|
|
||||||
Today at 18:30
|
|
||||||
ds.Album(ctx).GetAll(FIlter: Eq{"albumArtistId": artistID})
|
|
||||||
Or something like that 😛
|
|
||||||
Mintsoft
|
|
||||||
—
|
|
||||||
Today at 18:30
|
|
||||||
For other examples, how do I know what the right magic string for "albumArtistId" is?
|
|
||||||
kgarner7
|
|
||||||
—
|
|
||||||
Today at 18:31
|
|
||||||
album_artist_id
|
|
||||||
Look at the model structs names
|
|
||||||
deluan
|
|
||||||
—
|
|
||||||
Today at 18:31
|
|
||||||
This is a limitation of Squirrel. It is string based. YOu have to use the name of the columns in the DB
|
|
||||||
*/
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,6 +238,7 @@ func (cds *contentDirectoryService) doMediaFiles(tracks model.MediaFiles, basePa
|
|||||||
|
|
||||||
func (cds *contentDirectoryService) doAlbum(album *model.Album, basepath string, ret []interface{}, host string) ([]interface{}, error) {
|
func (cds *contentDirectoryService) doAlbum(album *model.Album, basepath string, ret []interface{}, host string) ([]interface{}, error) {
|
||||||
log.Debug(fmt.Sprintf("TODO: doAlbum Called with : '%+v', '%s'", album, basepath))
|
log.Debug(fmt.Sprintf("TODO: doAlbum Called with : '%+v', '%s'", album, basepath))
|
||||||
|
panic("doAlbum Called!")
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user