diff --git a/src/app/Nav.vue b/src/app/Nav.vue index f7005ff..e033011 100644 --- a/src/app/Nav.vue +++ b/src/app/Nav.vue @@ -38,6 +38,10 @@ Starred + + Radio + + diff --git a/src/library/radio/RadioStations.vue b/src/library/radio/RadioStations.vue new file mode 100644 index 0000000..75b1c3c --- /dev/null +++ b/src/library/radio/RadioStations.vue @@ -0,0 +1,66 @@ + + diff --git a/src/shared/api.ts b/src/shared/api.ts index 4b8ecc8..4214282 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -52,6 +52,13 @@ export interface SearchResult { tracks: Track[] } +export interface RadioStation { + id: string + title: string + description: string + url: string +} + export class API { readonly http: AxiosInstance; readonly get: (path: string, params?: any) => Promise; @@ -274,6 +281,48 @@ export class API { } } + async getRadioStations(): Promise { + const response = await this.get('rest/getInternetRadioStations') + return (response?.internetRadioStations?.internetRadioStation || []) + .map(this.normalizeRadioStation, this) + } + + async addRadioStation(title: string, url: string): Promise { + const params = { + name: title, + streamUrl: url, + } + return this + .get('rest/createInternetRadioStation', params) + .then(this.normalizeRadioStation) + } + + async updateRadioStation(item: RadioStation): Promise { + const params = { + id: item.id, + name: item.title, + streamUrl: item.url, + } + return this + .get('rest/updateInternetRadioStation', params) + .then(this.normalizeRadioStation) + } + + async deleteRadioStation(id: string): Promise { + return this.get('rest/deleteInternetRadioStation', { id }) + } + + private normalizeRadioStation(item: any): Track & RadioStation { + return { + id: `radio-${item.id}`, + title: item.name, + description: item.homePageUrl, + url: item.streamUrl, + duration: 0, + starred: false, + } + } + private normalizeTrack(item: any): Track { return { id: item.id, diff --git a/src/shared/components/Icon.vue b/src/shared/components/Icon.vue index b68ab0e..b3f6a54 100644 --- a/src/shared/components/Icon.vue +++ b/src/shared/components/Icon.vue @@ -5,6 +5,7 @@ import Vue from 'vue' import { BIcon, + BIconBroadcast, BIconCardText, BIconChevronCompactRight, BIconMusicNoteList, @@ -28,6 +29,7 @@ export default Vue.extend({ components: { BIcon, + BIconBroadcast, BIconCardText, BIconChevronCompactRight, BIconMusicNoteList, diff --git a/src/shared/router.ts b/src/shared/router.ts index 3fb1292..f7771b4 100644 --- a/src/shared/router.ts +++ b/src/shared/router.ts @@ -10,6 +10,7 @@ import RandomSongs from '@/playlist/RandomSongs.vue' import GenreDetails from '@/library/genre/GenreDetails.vue' import GenreLibrary from '@/library/genre/GenreLibrary.vue' import Starred from '@/library/starred/Starred.vue' +import RadioStations from '@/library/radio/RadioStations.vue' import Playlist from '@/playlist/Playlist.vue' import PlaylistList from '@/playlist/PlaylistList.vue' import SearchResult from '@/search/SearchResult.vue' @@ -78,6 +79,11 @@ export function setupRouter(auth: AuthService) { path: '/starred', component: Starred, }, + { + name: 'radio', + path: '/radio', + component: RadioStations, + }, { name: 'playlists', path: '/playlists',