diff --git a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt index f125e1d97..c8c4fa974 100644 --- a/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt +++ b/application/webserver/src/main/java/org/videolan/vlc/webserver/RemoteAccessRouting.kt @@ -517,6 +517,25 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { val gson = Gson() call.respondText(gson.toJson(result)) } + // Get a genre details + get("/genre") { + verifyLogin(settings) + if (!settings.serveAudios(appContext)) { + call.respond(HttpStatusCode.Forbidden) + return@get + } + val id = call.request.queryParameters["id"]?.toLong() ?: 0L + + val genre = appContext.getFromMl { getGenre(id) } + + val list = ArrayList() + genre.tracks.forEach { track -> + list.add(track.toPlayQueueItem()) + } + val result= RemoteAccessServer.AlbumResult(list, genre.title) + val gson = Gson() + call.respondText(gson.toJson(result)) + } // Get an playlist details get("/playlist") { verifyLogin(settings) @@ -860,6 +879,12 @@ fun Route.setupRouting(appContext: Context, scope: CoroutineScope) { album.tracks } } + "genre" -> { + id?.let { id -> + val genre = getGenre(id.toLong()) + genre.tracks + } + } else -> getAudio(Medialibrary.SORT_DEFAULT, false, false, false) } } diff --git a/buildsystem/network-sharing-server/src/components/MediaItem.vue b/buildsystem/network-sharing-server/src/components/MediaItem.vue index 527383430..6b34412b2 100644 --- a/buildsystem/network-sharing-server/src/components/MediaItem.vue +++ b/buildsystem/network-sharing-server/src/components/MediaItem.vue @@ -112,7 +112,7 @@ export default { return (this.mediaType == 'album' || this.mediaType == 'artist') }, isOpenable() { - return ['video-group', 'video-folder', 'artist', 'album', 'playlist'].includes(this.mediaType) + return ['video-group', 'video-folder', 'artist', 'album', 'playlist', 'genre'].includes(this.mediaType) }, getDescription() { if (this.mediaType == 'video') { @@ -123,7 +123,9 @@ export default { } }, manageClick() { - if (this.mediaType == 'playlist') { + if (this.mediaType == 'genre') { + this.$router.push({ name: 'GenreDetails', params: { genreId: this.media.id } }) + } else if (this.mediaType == 'playlist') { this.$router.push({ name: 'PlaylistDetails', params: { playlistId: this.media.id } }) } else if (this.mediaType == 'album') { this.$router.push({ name: 'AlbumDetails', params: { albumId: this.media.id } }) diff --git a/buildsystem/network-sharing-server/src/pages/GenreDetails.vue b/buildsystem/network-sharing-server/src/pages/GenreDetails.vue new file mode 100644 index 000000000..ab63440ad --- /dev/null +++ b/buildsystem/network-sharing-server/src/pages/GenreDetails.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/buildsystem/network-sharing-server/src/plugins/api.js b/buildsystem/network-sharing-server/src/plugins/api.js index cd0a01025..0922ed909 100644 --- a/buildsystem/network-sharing-server/src/plugins/api.js +++ b/buildsystem/network-sharing-server/src/plugins/api.js @@ -88,6 +88,12 @@ export const vlcApi = { albumDetails: (albumId) => { return`${API_URL}album?id=${albumId}` }, + /** + * Retrieve the genre details API URL + */ + genreDetails: (genreId) => { + return`${API_URL}genre?id=${genreId}` + }, /** * Retrieve the playlist details API URL */ diff --git a/buildsystem/network-sharing-server/src/plugins/vlcUtils.js b/buildsystem/network-sharing-server/src/plugins/vlcUtils.js index ae0becdf2..a43c3e6ed 100644 --- a/buildsystem/network-sharing-server/src/plugins/vlcUtils.js +++ b/buildsystem/network-sharing-server/src/plugins/vlcUtils.js @@ -61,6 +61,8 @@ export default { break case "album": id = route.params.albumId break + case "genre": id = route.params.genreId + break case "playlist": id = route.params.playlistId break default: id = 0 diff --git a/buildsystem/network-sharing-server/src/routes.js b/buildsystem/network-sharing-server/src/routes.js index 3aa22dc99..b1b339391 100644 --- a/buildsystem/network-sharing-server/src/routes.js +++ b/buildsystem/network-sharing-server/src/routes.js @@ -12,6 +12,7 @@ import LoginPage from './pages/LoginPage' import SslPage from './pages/SslPage' import ArtistDetails from './pages/ArtistDetails' import AlbumDetails from './pages/AlbumDetails' +import GenreDetails from './pages/GenreDetails' import PlaylistDetails from './pages/PlaylistDetails' const routes = [ @@ -33,6 +34,7 @@ const routes = [ { path: 'genres', component: AudioGenres, name: 'AudioGenres', meta: { showDisplayBar: true, isAudio: true, showResume: true, showGrouping: false } }, { path: 'artist/:artistId', component: ArtistDetails, name: 'ArtistDetails', meta: { showDisplayBar: true, isAudio: false, showResume: false, showGrouping: false, showFAB: true, playAllType: "artist", icon:"ic_no_artist" } }, { path: 'album/:albumId', component: AlbumDetails, name: 'AlbumDetails', meta: { showDisplayBar: true, isAudio: false, showResume: false, showGrouping: false, showFAB: true, playAllType: "album", icon:"ic_album" } }, + { path: 'genre/:genreId', component: GenreDetails, name: 'GenreDetails', meta: { showDisplayBar: true, isAudio: false, showResume: false, showGrouping: false, showFAB: true, playAllType: "genre", icon:"ic_genre" } }, ] }, {