diff --git a/src/i18n/en_US.jsonc b/src/i18n/en_US.jsonc index 9b4e1652..6f09a2fc 100644 --- a/src/i18n/en_US.jsonc +++ b/src/i18n/en_US.jsonc @@ -154,6 +154,7 @@ "term.videoExtras": "Video Extras", "term.top": "Top", "term.version": "Version", + "term.noVideos": "No videos found.", // Home "home.title": "Home", diff --git a/src/renderer/index.js b/src/renderer/index.js index 66e5c23d..c2aee7ac 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -1094,7 +1094,7 @@ const app = new Vue({ let playlistId = response.id this.playlists.loadingState = (!transient) ? 0 : 1 this.showingPlaylist = response - if (!response.relationships.tracks.next) { + if (!response.relationships?.tracks?.next) { this.playlists.loadingState = 1 return } diff --git a/src/renderer/views/components/mediaitem-square.ejs b/src/renderer/views/components/mediaitem-square.ejs index 6bf861d9..4248f1b7 100644 --- a/src/renderer/views/components/mediaitem-square.ejs +++ b/src/renderer/views/components/mediaitem-square.ejs @@ -144,13 +144,15 @@ }, async isInLibrary() { if (this.item.type && !this.item.type.includes("library")) { - var params = { - "fields[playlists]": "inLibrary", - "fields[albums]": "inLibrary", - "relate": "library", + let params = { + relate:"library", + "fields":"inLibrary", "extend": this.revisedRandId() } - var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params); + let kind = this.item.type ?? this.item.attributes.playParams.kind + let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; + if (truekind == "musicVideos") {truekind = "music-videos"} + let res = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/?ids[${truekind}]=${this.item.attributes.playParams.id ?? this.item.id}`,params); res = res.data.data[0] this.addedToLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false } else { @@ -158,21 +160,20 @@ } }, async removeFromLibrary(id) { - var params = { - "fields[playlists]": "inLibrary", - "fields[songs]": "inLibrary", - "fields[albums]": "inLibrary", - "relate": "library", - "extend": this.revisedRandId() - } - var id = this.item.id ?? this.item.attributes.playParams.id - var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params); + let params = { + relate:"library", + "fields":"inLibrary", + "extend": this.revisedRandId() + } + let kind = this.item.type ?? this.item.attributes.playParams.kind + let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; + if (truekind == "musicVideos") {truekind = "music-videos"} + let res = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/?ids[${truekind}]=${this.item.attributes.playParams.id ?? this.item.id}`,params); res= res.data.data[0] if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) { id = res.relationships.library.data[0].id } - let kind = this.item.attributes.playParams.kind ?? this.item.type ?? ''; - var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; + app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{}, { fetchOptions: { diff --git a/src/renderer/views/pages/library-videos.ejs b/src/renderer/views/pages/library-videos.ejs index a1b8d6fa..6c9e458d 100644 --- a/src/renderer/views/pages/library-videos.ejs +++ b/src/renderer/views/pages/library-videos.ejs @@ -6,8 +6,13 @@
- - + +
@@ -19,12 +24,14 @@ data: function(){ return { videos: [], + loaded: false } }, mounted() { this.$nextTick(async function () { if (this.$data.videos == null || this.$data.videos.length == 0) this.$data.videos = (await this.$root.mk.api.v3.music('/v1/me/library/music-videos')).data?.data ?? [] + this.$data.loaded = true }) } })