From 7de713ef7f7da816e24e8d64ff599fdccdc82e36 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Mon, 28 Feb 2022 18:57:30 -0800 Subject: [PATCH] added lcdArtworkSize directive --- src/renderer/index.js | 394 +++++++++++++++++++++--------------------- 1 file changed, 199 insertions(+), 195 deletions(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index e0057fb7..386c41b9 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -136,7 +136,7 @@ const app = new Vue({ sorting: "name", sortOrder: "asc", listing: [], - meta: {total: 0, progress: 0}, + meta: { total: 0, progress: 0 }, search: "", displayListing: [], downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library @@ -152,7 +152,7 @@ const app = new Vue({ sorting: ["dateAdded", "name"], // [0] = recentlyadded page, [1] = albums page sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page listing: [], - meta: {total: 0, progress: 0}, + meta: { total: 0, progress: 0 }, search: "", displayListing: [], downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library @@ -168,7 +168,7 @@ const app = new Vue({ sorting: ["dateAdded", "name"], // [0] = recentlyadded page, [1] = albums page sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page listing: [], - meta: {total: 0, progress: 0}, + meta: { total: 0, progress: 0 }, search: "", displayListing: [], downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library @@ -222,7 +222,7 @@ const app = new Vue({ "attributes": { "name": "Cider User", "handle": "CiderUser", - "artwork": {"url": "./assets/logocut.png"} + "artwork": { "url": "./assets/logocut.png" } } }, menuOpened: false, @@ -302,7 +302,7 @@ const app = new Vue({ }, methods: { songLinkShare(amUrl) { - notyf.open({type: "info", message: app.getLz('term.song.link.generate')}) + notyf.open({ type: "info", message: app.getLz('term.song.link.generate') }) let self = this httpRequest = new XMLHttpRequest(); httpRequest.open('GET', `https://api.song.link/v1-alpha.1/links?url=${amUrl}&userCountry=US`, true); @@ -397,7 +397,7 @@ const app = new Vue({ }, async showSocialListeningTo() { let contentIds = Object.keys(app.socialBadges.badgeMap) - app.showCollection({data: this.socialBadges.mediaItems}, "Friends Listening To", "albums") + app.showCollection({ data: this.socialBadges.mediaItems }, "Friends Listening To", "albums") if (this.socialBadges.mediaItemDLState == 1 || this.socialBadges.mediaItemDLState == 2) { return } @@ -526,7 +526,7 @@ const app = new Vue({ self.selectedMediaItems[i].kind = "albums" let res = await self.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/albums/${self.selectedMediaItems[i].id}/tracks`); let ids = res.data.data.map(function (i) { - return {id: i.id, type: i.type} + return { id: i.id, type: i.type } }) pl_items = pl_items.concat(ids) } else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") { @@ -539,7 +539,7 @@ const app = new Vue({ self.selectedMediaItems[i].kind = "library-albums" let res = await self.mk.api.v3.music(`/v1/me/library/albums/${self.selectedMediaItems[i].id}/tracks`); let ids = res.data.data.map(function (i) { - return {id: i.id, type: i.type} + return { id: i.id, type: i.type } }) pl_items = pl_items.concat(ids) } else { @@ -566,7 +566,7 @@ const app = new Vue({ self.selectedMediaItems[i].kind = "albums" let res = await self.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/albums/${self.selectedMediaItems[i].id}/tracks`); let ids = res.data.data.map(function (i) { - return {id: i.id, type: i.type} + return { id: i.id, type: i.type } }) pl_items = pl_items.concat(ids) } else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") { @@ -579,7 +579,7 @@ const app = new Vue({ self.selectedMediaItems[i].kind = "library-albums" let res = await self.mk.api.v3.music(`/v1/me/library/albums/${self.selectedMediaItems[i].id}/tracks`); let ids = res.data.data.map(function (i) { - return {id: i.id, type: i.type} + return { id: i.id, type: i.type } }) pl_items = pl_items.concat(ids) } else { @@ -593,13 +593,13 @@ const app = new Vue({ this.modals.addToPlaylist = false await app.mk.api.v3.music( `/v1/me/library/playlists/${playlist_id}/tracks`, {}, { - fetchOptions: { - method: "POST", - body: JSON.stringify({ - data: pl_items - }) - } + fetchOptions: { + method: "POST", + body: JSON.stringify({ + data: pl_items + }) } + } ).then(() => { if (this.page == 'playlist_' + this.showingPlaylist.id) { this.getPlaylistFromID(this.showingPlaylist.id, true) @@ -654,7 +654,7 @@ const app = new Vue({ "attributes": { "name": "Cider User", "handle": "CiderUser", - "artwork": {"url": "./assets/logocut.png"} + "artwork": { "url": "./assets/logocut.png" } } } } @@ -710,7 +710,7 @@ const app = new Vue({ let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; app.mk.setQueue({ [truekind]: [lastItem.attributes.playParams.id], - parameters: {l: app.mklang} + parameters: { l: app.mklang } }) app.mk.mute() setTimeout(() => { @@ -729,7 +729,7 @@ const app = new Vue({ for (id of ids) { if (!(i == 0 && ids[0] == lastItem.attributes.playParams.id)) { try { - app.mk.playLater({songs: [id]}) + app.mk.playLater({ songs: [id] }) } catch (err) { } } @@ -751,14 +751,14 @@ const app = new Vue({ } break; case "history": - let history = await app.mk.api.v3.music(`/v1/me/recent/played/tracks`, {l: app.mklang}) + let history = await app.mk.api.v3.music(`/v1/me/recent/played/tracks`, { l: app.mklang }) if (history.data.data.length > 0) { let lastItem = history.data.data[0] let kind = lastItem.attributes.playParams.kind; let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; app.mk.setQueue({ [truekind]: [lastItem.attributes.playParams.id], - parameters: {l: app.mklang} + parameters: { l: app.mklang } }) app.mk.mute() setTimeout(() => { @@ -790,12 +790,12 @@ const app = new Vue({ //CiderAudio.audioNodes.gainNode.gain.value = (Math.min(Math.pow(10, (replaygain.gain / 20)), (1 / replaygain.peak))) CiderAudio.audioNodes.gainNode.gain.value = replaygain.gain } catch (e) { - } + } }) ipcRenderer.on('play', function (_event, mode, id) { if (mode !== 'url') { - self.mk.setQueue({[mode]: id, parameters: {l: self.mklang}}).then(() => { + self.mk.setQueue({ [mode]: id, parameters: { l: self.mklang } }).then(() => { app.mk.play() }) @@ -919,14 +919,14 @@ const app = new Vue({ try { const infoResponse = await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json")) this.chrome.appliedTheme.info = await infoResponse.json() - }catch(e){ - e=null + } catch (e) { + e = null console.warn("failed to get theme.json") this.chrome.appliedTheme.info = {} } - if(!onlyPrefs) { + if (!onlyPrefs) { document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}` document.querySelectorAll(`[id*='less']`).forEach(el => { el.remove() @@ -935,10 +935,10 @@ const app = new Vue({ } }, getThemeDirective(directive = "") { - if(typeof this.chrome.appliedTheme.info.directives != "object") { + if (typeof this.chrome.appliedTheme.info.directives != "object") { return "" } - if(this.chrome.appliedTheme.info.directives[directive]) { + if (this.chrome.appliedTheme.info.directives[directive]) { return this.chrome.appliedTheme.info.directives[directive].value } else { return "" @@ -961,7 +961,7 @@ const app = new Vue({ classes.simplebg = true } - if(this.getThemeDirective('windowLayout') == 'twopanel') { + if (this.getThemeDirective('windowLayout') == 'twopanel') { classes.twopanel = true } return classes @@ -1043,12 +1043,12 @@ const app = new Vue({ this.newPlaylist() } }, - { - name: app.getLz('term.createNewPlaylistFolder'), - action: () => { - this.newPlaylistFolder() - } + { + name: app.getLz('term.createNewPlaylistFolder'), + action: () => { + this.newPlaylistFolder() } + } ] } this.showMenuPanel(menu, event) @@ -1057,13 +1057,13 @@ const app = new Vue({ let self = this this.mk.api.v3.music( `/v1/me/library/playlist-folders/${id}`, {}, { - fetchOptions: { - method: "PATCH", - body: JSON.stringify({ - attributes: {name: name} - }) - } + fetchOptions: { + method: "PATCH", + body: JSON.stringify({ + attributes: { name: name } + }) } + } ).then(res => { self.refreshPlaylists() }) @@ -1072,13 +1072,13 @@ const app = new Vue({ let self = this this.mk.api.v3.music( `/v1/me/library/playlists/${id}`, {}, { - fetchOptions: { - method: "PATCH", - body: JSON.stringify({ - attributes: {name: name} - }) - } + fetchOptions: { + method: "PATCH", + body: JSON.stringify({ + attributes: { name: name } + }) } + } ).then(res => { self.refreshPlaylists() }) @@ -1103,9 +1103,9 @@ const app = new Vue({ fetchOptions: { method: "POST", body: JSON.stringify({ - "attributes": {"name": name}, + "attributes": { "name": name }, "relationships": { - "tracks": {"data": tracks}, + "tracks": { "data": tracks }, } }) } @@ -1155,7 +1155,7 @@ const app = new Vue({ app.appRoute("collection-list") }, async showArtistView(artist, title, view) { - let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artist}/view/${view}?l=${this.mklang}`, {}, {includeResponseMeta: !0})).data + let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artist}/view/${view}?l=${this.mklang}`, {}, { includeResponseMeta: !0 })).data console.log(response) await this.showCollection(response, title, "artists") }, @@ -1273,7 +1273,7 @@ const app = new Vue({ "limit[artists:top-songs]": 20, "art[url]": "f", l: this.mklang - }, {includeResponseMeta: !0}) + }, { includeResponseMeta: !0 }) console.log(artistData.data.data[0]) this.artistPage.data = artistData.data.data[0] this.page = "artist-page" @@ -1371,7 +1371,7 @@ const app = new Vue({ if (format === 'long') { const longFormat = [] - + // Seconds if (datetime.getSeconds() !== 0) { longFormat.push(`${datetime.getSeconds()} ${app.getLz('term.time.seconds')}`) @@ -1379,17 +1379,17 @@ const app = new Vue({ // Minutes if (time >= 60) { - longFormat.push(`${datetime.getMinutes()} ${app.getLz('term.time.minute', options = {count: datetime.getMinutes()})}`) + longFormat.push(`${datetime.getMinutes()} ${app.getLz('term.time.minute', options = { count: datetime.getMinutes() })}`) } // Hours if (time >= 3600) { - longFormat.push(`${datetime.getHours()} ${app.getLz('term.time.hour', options = {count: datetime.getHours()})}`) + longFormat.push(`${datetime.getHours()} ${app.getLz('term.time.hour', options = { count: datetime.getHours() })}`) } // Days if (time >= 86400) { - longFormat.push(`${day} ${app.getLz('term.time.day', options = {count: day})}`) + longFormat.push(`${day} ${app.getLz('term.time.day', options = { count: day })}`) } returnTime = longFormat.reverse().join(', ') } @@ -1431,7 +1431,7 @@ const app = new Vue({ kind: page, id: id, attributes: { - playParams: {kind: page, id: id, isLibrary: isLibrary} + playParams: { kind: page, id: id, isLibrary: isLibrary } } }) }, @@ -1536,7 +1536,7 @@ const app = new Vue({ let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind, (app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], - {"include[songs]": "albums,artists", l: app.mklang}); + { "include[songs]": "albums,artists", l: app.mklang }); app.searchAndNavigate(u.data.data[0], target) } catch (e) { app.searchAndNavigate(app.mk.nowPlayingItem, target) @@ -1640,7 +1640,7 @@ const app = new Vue({ } if (labelId != "") { app.showingPlaylist = [] - await app.getTypeFromID("recordLabel", labelId, false, {views: 'top-releases,latest-releases,top-artists'}); + await app.getTypeFromID("recordLabel", labelId, false, { views: 'top-releases,latest-releases,top-artists' }); app.page = "recordLabel_" + labelId; } @@ -1678,75 +1678,75 @@ const app = new Vue({ console.log(kind, id, isLibrary) app.mk.stop().then(() => { if (kind.includes("artist")) { - app.mk.setStationQueue({artist: 'a-' + id}).then(() => { + app.mk.setStationQueue({ artist: 'a-' + id }).then(() => { app.mk.play() }) } - // else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){ - // /* Randomize array in-place using Durstenfeld shuffle algorithm */ - // function shuffleArray(array) { - // for (var i = array.length - 1; i > 0; i--) { - // var j = Math.floor(Math.random() * (i + 1)); - // var temp = array[i]; - // array[i] = array[j]; - // array[j] = temp; - // } - // } - // app.mk.clearQueue().then(function () { { - // app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () { - // app.mk.play().then(function (){ - // app.mk.clearQueue().then(function (){ - // var playlistId = id - // const params = { - // include: "tracks", - // platform: "web", - // "include[library-playlists]": "catalog,tracks", - // "fields[playlists]": "curatorName,playlistType,name,artwork,url", - // "include[library-songs]": "catalog,artists,albums", - // "fields[catalog]": "artistUrl,albumUrl", - // "fields[songs]": "artistUrl,albumUrl" - // } - // var playlistId = '' + // else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){ + // /* Randomize array in-place using Durstenfeld shuffle algorithm */ + // function shuffleArray(array) { + // for (var i = array.length - 1; i > 0; i--) { + // var j = Math.floor(Math.random() * (i + 1)); + // var temp = array[i]; + // array[i] = array[j]; + // array[j] = temp; + // } + // } + // app.mk.clearQueue().then(function () { { + // app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () { + // app.mk.play().then(function (){ + // app.mk.clearQueue().then(function (){ + // var playlistId = id + // const params = { + // include: "tracks", + // platform: "web", + // "include[library-playlists]": "catalog,tracks", + // "fields[playlists]": "curatorName,playlistType,name,artwork,url", + // "include[library-songs]": "catalog,artists,albums", + // "fields[catalog]": "artistUrl,albumUrl", + // "fields[songs]": "artistUrl,albumUrl" + // } + // var playlistId = '' - // try { - // function getPlaylist(id, params, isLibrary){ - // if (isLibrary){ - // return app.mk.api.library.playlist(id, params) - // } else { return app.mk.api.playlist(id, params)} - // } - // getPlaylist(id, params, isLibrary).then(res => { - // let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); - // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} - // app.mk.queue.append(query) - // if (!res.relationships.tracks.next) { - // return - // } else { - // getPlaylistTracks(res.relationships.tracks.next) - // } + // try { + // function getPlaylist(id, params, isLibrary){ + // if (isLibrary){ + // return app.mk.api.library.playlist(id, params) + // } else { return app.mk.api.playlist(id, params)} + // } + // getPlaylist(id, params, isLibrary).then(res => { + // let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); + // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} + // app.mk.queue.append(query) + // if (!res.relationships.tracks.next) { + // return + // } else { + // getPlaylistTracks(res.relationships.tracks.next) + // } - // function getPlaylistTracks(next) { - // app.apiCall(app.musicBaseUrl + next, res => { - // if (res.id != playlistId) { - // return - // } - // let query = res.data.map(item => new MusicKit.MediaItem(item)) - // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} - // app.mk.queue.append(query) + // function getPlaylistTracks(next) { + // app.apiCall(app.musicBaseUrl + next, res => { + // if (res.id != playlistId) { + // return + // } + // let query = res.data.map(item => new MusicKit.MediaItem(item)) + // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} + // app.mk.queue.append(query) - // if (res.next) { - // getPlaylistTracks(res.next) - // } - // }) - // } - // }) - // } catch (e) {} + // if (res.next) { + // getPlaylistTracks(res.next) + // } + // }) + // } + // }) + // } catch (e) {} - // }) - // }) - // }) - // } - // }) + // }) + // }) + // }) + // } + // }) // } else { app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '') @@ -1788,7 +1788,7 @@ const app = new Vue({ let self = this let prefs = this.cfg.libraryPrefs.songs let albumAdded = self.library?.albums?.listing?.map(function (i) { - return {[i.id]: i.attributes?.dateAdded} + return { [i.id]: i.attributes?.dateAdded } }) let startTime = new Date().getTime() @@ -1859,9 +1859,9 @@ const app = new Vue({ sortSongs() } }, - getAlbumSort() { - this.library.albums.sortOrder[1] = this.cfg.libraryPrefs.albums.sortOrder; - this.library.albums.sorting[1] = this.cfg.libraryPrefs.albums.sort; + getAlbumSort() { + this.library.albums.sortOrder[1] = this.cfg.libraryPrefs.albums.sortOrder; + this.library.albums.sorting[1] = this.cfg.libraryPrefs.albums.sort; }, // make a copy of searchLibrarySongs except use Albums instead of Songs searchLibraryAlbums(index) { @@ -2233,7 +2233,7 @@ const app = new Vue({ } if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") { console.log(`downloading next chunk - ${library.length - } albums so far`) + } albums so far`) downloadChunk() } else { self.library.albums.listing = library @@ -2340,7 +2340,7 @@ const app = new Vue({ } if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") { console.log(`downloading next chunk - ${library.length - } artists so far`) + } artists so far`) downloadChunk() } else { self.library.artists.listing = library @@ -2357,20 +2357,20 @@ const app = new Vue({ getTotalTime() { try { if (app.showingPlaylist.relationships.tracks.data.length > 0) { - const timeInSeconds = Math.round([].concat(...app.showingPlaylist.relationships.tracks.data).reduce((a, {attributes: {durationInMillis}}) => a + durationInMillis, 0) / 1000); - return `${app.showingPlaylist.relationships.tracks.data.length} ${app.getLz('term.track', options = {count: app.showingPlaylist.relationships.tracks.data.length})}, ${this.convertTime(timeInSeconds, 'long')}` + const timeInSeconds = Math.round([].concat(...app.showingPlaylist.relationships.tracks.data).reduce((a, { attributes: { durationInMillis } }) => a + durationInMillis, 0) / 1000); + return `${app.showingPlaylist.relationships.tracks.data.length} ${app.getLz('term.track', options = { count: app.showingPlaylist.relationships.tracks.data.length })}, ${this.convertTime(timeInSeconds, 'long')}` } else return "" } catch (err) { return "" } }, async getLibrarySongs() { - let response = await this.mkapi("songs", true, "", {limit: 100, l: this.mklang}, {includeResponseMeta: !0}) + let response = await this.mkapi("songs", true, "", { limit: 100, l: this.mklang }, { includeResponseMeta: !0 }) this.library.songs.listing = response.data.data this.library.songs.meta = response.data.meta }, async getLibraryAlbums() { - let response = await this.mkapi("albums", true, "", {limit: 100, l: this.mklang}, {includeResponseMeta: !0}) + let response = await this.mkapi("albums", true, "", { limit: 100, l: this.mklang }, { includeResponseMeta: !0 }) this.library.albums.listing = response.data.data this.library.albums.meta = response.data.meta }, @@ -2476,13 +2476,13 @@ const app = new Vue({ let self = this this.mk.api.v3.music( "/v1/me/library/playlist-folders/", {}, { - fetchOptions: { - method: "POST", - body: JSON.stringify({ - attributes: {name: name} - }) - } + fetchOptions: { + method: "POST", + body: JSON.stringify({ + attributes: { name: name } + }) } + } ).then((res) => { let playlist = (res.data.data[0]) self.playlists.listing.push({ @@ -2841,15 +2841,15 @@ const app = new Vue({ line: "lrcInstrumental" }); } - preLrc.push({startTime: start, endTime: end, line: element.textContent}); + preLrc.push({ startTime: start, endTime: end, line: element.textContent }); endTimes.push(end); } // first line dot if (preLrc.length > 0) - preLrc.unshift({startTime: 0, endTime: preLrc[0].startTime, line: "lrcInstrumental"}); + preLrc.unshift({ startTime: 0, endTime: preLrc[0].startTime, line: "lrcInstrumental" }); } else { for (element of lyricsLines) { - preLrc.push({startTime: 9999999, endTime: 9999999, line: element.textContent}); + preLrc.push({ startTime: 9999999, endTime: 9999999, line: element.textContent }); } } this.lyrics = preLrc; @@ -2917,17 +2917,17 @@ const app = new Vue({ console.log(id, truekind, isLibrary) try { if (truekind.includes("artist")) { - app.mk.setStationQueue({artist: 'a-' + id}).then(() => { + app.mk.setStationQueue({ artist: 'a-' + id }).then(() => { app.mk.play() }) } else if (truekind == "radioStations") { - this.mk.setStationQueue({url: raurl}).then(function (queue) { + this.mk.setStationQueue({ url: raurl }).then(function (queue) { MusicKit.getInstance().play() }); } else { this.mk.setQueue({ [truekind]: [id], - parameters: {l: this.mklang} + parameters: { l: this.mklang } }).then(function (queue) { MusicKit.getInstance().play() }) @@ -2968,7 +2968,7 @@ const app = new Vue({ if (item) { app.mk.setQueue({ [item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id, - parameters: {l: app.mklang} + parameters: { l: app.mklang } }).then(function () { app.mk.play().then(() => { if (app.mk.shuffleMode == 1) { @@ -3025,7 +3025,7 @@ const app = new Vue({ for (let kind in itemsToPlay) { let ids = itemsToPlay[kind] if (ids.length > 0) { - app.mk.playLater({[kind + "s"]: itemsToPlay[kind]}) + app.mk.playLater({ [kind + "s"]: itemsToPlay[kind] }) } } }) @@ -3046,22 +3046,22 @@ const app = new Vue({ let ids = itemsToPlay[kind] if (ids.length > 0) { if (app.mk.queue._itemIDs.length > 0) { - app.mk.playLater({[kind + "s"]: itemsToPlay[kind]}).then(function () { - ind += 1; - console.log(ind, Object.keys(itemsToPlay).length) - if (ind >= Object.keys(itemsToPlay).length) { - app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id)) - } + app.mk.playLater({ [kind + "s"]: itemsToPlay[kind] }).then(function () { + ind += 1; + console.log(ind, Object.keys(itemsToPlay).length) + if (ind >= Object.keys(itemsToPlay).length) { + app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id)) } + } ) } else { - app.mk.setQueue({[kind + "s"]: itemsToPlay[kind]}).then(function () { - ind += 1; - console.log(ind, Object.keys(itemsToPlay).length) - if (ind >= Object.keys(itemsToPlay).length) { - app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id)) - } + app.mk.setQueue({ [kind + "s"]: itemsToPlay[kind] }).then(function () { + ind += 1; + console.log(ind, Object.keys(itemsToPlay).length) + if (ind >= Object.keys(itemsToPlay).length) { + app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id)) } + } ) } } @@ -3074,7 +3074,7 @@ const app = new Vue({ if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) { app.mk.setQueue({ [item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id, - parameters: {l: app.mklang} + parameters: { l: app.mklang } }).then(function () { app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function () { if ((app.showingPlaylist && app.showingPlaylist.id == id)) { @@ -3114,7 +3114,7 @@ const app = new Vue({ } else { this.mk.setQueue({ [truekind]: [id], - parameters: {l: this.mklang} + parameters: { l: this.mklang } }).then(function (queue) { if (item && ((queue._itemIDs[childIndex] != item.id))) { childIndex = queue._itemIDs.indexOf(item.id) @@ -3226,7 +3226,7 @@ const app = new Vue({ with: ["serverBubbles", "lyricSnippet"], "art[url]": "f", "art[social-profiles:url]": "c" - }, {includeResponseMeta: !0}).then(function (results) { + }, { includeResponseMeta: !0 }).then(function (results) { results.data.results["meta"] = results.data.meta self.search.resultsSocial = results.data.results }) @@ -3246,7 +3246,7 @@ const app = new Vue({ return type.type == this }, type) if (index == -1) { - types.push({type: type, id: [id]}) + types.push({ type: type, id: [id] }) } else { types[index].id.push(id) } @@ -3367,9 +3367,13 @@ const app = new Vue({ }, async getCurrentArtURL() { try { + let artworkSize = 50 + if (app.getThemeDirective("lcdArtworkSize") != "") { + artworkSize = app.getThemeDirective("lcdArtworkSize") + } this.currentArtUrl = ''; if (app.mk.nowPlayingItem != null && app.mk.nowPlayingItem.attributes != null && app.mk.nowPlayingItem.attributes.artwork != null && app.mk.nowPlayingItem.attributes.artwork.url != null && app.mk.nowPlayingItem.attributes.artwork.url != '') { - this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50); + this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ?? '').replace('{w}', artworkSize).replace('{h}', artworkSize); try { document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); } catch (e) { @@ -3378,7 +3382,7 @@ const app = new Vue({ let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`); data = data.data.data[0]; if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { - this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50); + this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', artworkSize).replace('{h}', artworkSize); ipcRenderer.send('updateRPCImage', this.currentArtUrl ?? ''); try { document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); @@ -3430,10 +3434,10 @@ const app = new Vue({ }, quickPlay(query) { let self = this - MusicKit.getInstance().api.search(query, {limit: 2, types: 'songs'}).then(function (data) { + MusicKit.getInstance().api.search(query, { limit: 2, types: 'songs' }).then(function (data) { MusicKit.getInstance().setQueue({ song: data["songs"]['data'][0]["id"], - parameters: {l: app.mklang} + parameters: { l: app.mklang } }).then(function (queue) { MusicKit.getInstance().play() setTimeout(() => { @@ -3611,7 +3615,7 @@ const app = new Vue({ let data_type = this.mk.nowPlayingItem.playParams.kind let item_id = this.mk.nowPlayingItem.attributes.playParams.id ?? this.mk.nowPlayingItem.id let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary ?? false - let params = {"fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "t": "1"} + let params = { "fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "t": "1" } app.selectedMediaItems = [] app.select_selectMediaItem(item_id, data_type, 0, '12344', isLibrary) let useMenu = "normal" @@ -3630,36 +3634,36 @@ const app = new Vue({ app.love(app.mk.nowPlayingItem) } }, - { - "icon": "./assets/feather/heart.svg", - "id": "unlove", - "active": true, - "name": app.getLz('action.unlove'), - "hidden": true, - "action": function () { - app.unlove(app.mk.nowPlayingItem) - } - }, - { - "icon": "./assets/feather/thumbs-down.svg", - "id": "dislike", - "name": app.getLz('action.dislike'), - "hidden": false, - "disabled": true, - "action": function () { - app.dislike(app.mk.nowPlayingItem) - } - }, - { - "icon": "./assets/feather/thumbs-down.svg", - "id": "undo_dislike", - "name": app.getLz('action.undoDislike'), - "active": true, - "hidden": true, - "action": function () { - app.unlove(app.mk.nowPlayingItem) - } - }, + { + "icon": "./assets/feather/heart.svg", + "id": "unlove", + "active": true, + "name": app.getLz('action.unlove'), + "hidden": true, + "action": function () { + app.unlove(app.mk.nowPlayingItem) + } + }, + { + "icon": "./assets/feather/thumbs-down.svg", + "id": "dislike", + "name": app.getLz('action.dislike'), + "hidden": false, + "disabled": true, + "action": function () { + app.dislike(app.mk.nowPlayingItem) + } + }, + { + "icon": "./assets/feather/thumbs-down.svg", + "id": "undo_dislike", + "name": app.getLz('action.undoDislike'), + "active": true, + "hidden": true, + "action": function () { + app.unlove(app.mk.nowPlayingItem) + } + }, ], items: [ { @@ -3691,7 +3695,7 @@ const app = new Vue({ "icon": "./assets/feather/radio.svg", "name": app.getLz('action.startRadio'), "action": function () { - app.mk.setStationQueue({song: app.mk.nowPlayingItem.id}).then(() => { + app.mk.setStationQueue({ song: app.mk.nowPlayingItem.id }).then(() => { app.mk.play() app.selectedMediaItems = [] }) @@ -4008,7 +4012,7 @@ const app = new Vue({ Vue.component('animated-number', { template: "