added lcdArtworkSize directive

This commit is contained in:
booploops 2022-02-28 18:57:30 -08:00
parent f800dc0a0a
commit 7de713ef7f

View file

@ -136,7 +136,7 @@ const app = new Vue({
sorting: "name", sorting: "name",
sortOrder: "asc", sortOrder: "asc",
listing: [], listing: [],
meta: {total: 0, progress: 0}, meta: { total: 0, progress: 0 },
search: "", search: "",
displayListing: [], displayListing: [],
downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library 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 sorting: ["dateAdded", "name"], // [0] = recentlyadded page, [1] = albums page
sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page
listing: [], listing: [],
meta: {total: 0, progress: 0}, meta: { total: 0, progress: 0 },
search: "", search: "",
displayListing: [], displayListing: [],
downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library 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 sorting: ["dateAdded", "name"], // [0] = recentlyadded page, [1] = albums page
sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page sortOrder: ["desc", "asc"], // [0] = recentlyadded page, [1] = albums page
listing: [], listing: [],
meta: {total: 0, progress: 0}, meta: { total: 0, progress: 0 },
search: "", search: "",
displayListing: [], displayListing: [],
downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library downloadState: 0 // 0 = not started, 1 = in progress, 2 = complete, 3 = empty library
@ -222,7 +222,7 @@ const app = new Vue({
"attributes": { "attributes": {
"name": "Cider User", "name": "Cider User",
"handle": "CiderUser", "handle": "CiderUser",
"artwork": {"url": "./assets/logocut.png"} "artwork": { "url": "./assets/logocut.png" }
} }
}, },
menuOpened: false, menuOpened: false,
@ -302,7 +302,7 @@ const app = new Vue({
}, },
methods: { methods: {
songLinkShare(amUrl) { 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 let self = this
httpRequest = new XMLHttpRequest(); httpRequest = new XMLHttpRequest();
httpRequest.open('GET', `https://api.song.link/v1-alpha.1/links?url=${amUrl}&userCountry=US`, true); 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() { async showSocialListeningTo() {
let contentIds = Object.keys(app.socialBadges.badgeMap) 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) { if (this.socialBadges.mediaItemDLState == 1 || this.socialBadges.mediaItemDLState == 2) {
return return
} }
@ -526,7 +526,7 @@ const app = new Vue({
self.selectedMediaItems[i].kind = "albums" 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 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) { 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) pl_items = pl_items.concat(ids)
} else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") { } 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" self.selectedMediaItems[i].kind = "library-albums"
let res = await self.mk.api.v3.music(`/v1/me/library/albums/${self.selectedMediaItems[i].id}/tracks`); 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) { 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) pl_items = pl_items.concat(ids)
} else { } else {
@ -566,7 +566,7 @@ const app = new Vue({
self.selectedMediaItems[i].kind = "albums" 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 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) { 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) pl_items = pl_items.concat(ids)
} else if (self.selectedMediaItems[i].kind == "library-song" || self.selectedMediaItems[i].kind == "library-songs") { } 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" self.selectedMediaItems[i].kind = "library-albums"
let res = await self.mk.api.v3.music(`/v1/me/library/albums/${self.selectedMediaItems[i].id}/tracks`); 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) { 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) pl_items = pl_items.concat(ids)
} else { } else {
@ -593,13 +593,13 @@ const app = new Vue({
this.modals.addToPlaylist = false this.modals.addToPlaylist = false
await app.mk.api.v3.music( await app.mk.api.v3.music(
`/v1/me/library/playlists/${playlist_id}/tracks`, {}, { `/v1/me/library/playlists/${playlist_id}/tracks`, {}, {
fetchOptions: { fetchOptions: {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
data: pl_items data: pl_items
}) })
}
} }
}
).then(() => { ).then(() => {
if (this.page == 'playlist_' + this.showingPlaylist.id) { if (this.page == 'playlist_' + this.showingPlaylist.id) {
this.getPlaylistFromID(this.showingPlaylist.id, true) this.getPlaylistFromID(this.showingPlaylist.id, true)
@ -654,7 +654,7 @@ const app = new Vue({
"attributes": { "attributes": {
"name": "Cider User", "name": "Cider User",
"handle": "CiderUser", "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; let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
app.mk.setQueue({ app.mk.setQueue({
[truekind]: [lastItem.attributes.playParams.id], [truekind]: [lastItem.attributes.playParams.id],
parameters: {l: app.mklang} parameters: { l: app.mklang }
}) })
app.mk.mute() app.mk.mute()
setTimeout(() => { setTimeout(() => {
@ -729,7 +729,7 @@ const app = new Vue({
for (id of ids) { for (id of ids) {
if (!(i == 0 && ids[0] == lastItem.attributes.playParams.id)) { if (!(i == 0 && ids[0] == lastItem.attributes.playParams.id)) {
try { try {
app.mk.playLater({songs: [id]}) app.mk.playLater({ songs: [id] })
} catch (err) { } catch (err) {
} }
} }
@ -751,14 +751,14 @@ const app = new Vue({
} }
break; break;
case "history": 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) { if (history.data.data.length > 0) {
let lastItem = history.data.data[0] let lastItem = history.data.data[0]
let kind = lastItem.attributes.playParams.kind; let kind = lastItem.attributes.playParams.kind;
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind; let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
app.mk.setQueue({ app.mk.setQueue({
[truekind]: [lastItem.attributes.playParams.id], [truekind]: [lastItem.attributes.playParams.id],
parameters: {l: app.mklang} parameters: { l: app.mklang }
}) })
app.mk.mute() app.mk.mute()
setTimeout(() => { setTimeout(() => {
@ -795,7 +795,7 @@ const app = new Vue({
ipcRenderer.on('play', function (_event, mode, id) { ipcRenderer.on('play', function (_event, mode, id) {
if (mode !== 'url') { 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() app.mk.play()
}) })
@ -919,14 +919,14 @@ const app = new Vue({
try { try {
const infoResponse = await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json")) const infoResponse = await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json"))
this.chrome.appliedTheme.info = await infoResponse.json() this.chrome.appliedTheme.info = await infoResponse.json()
}catch(e){ } catch (e) {
e=null e = null
console.warn("failed to get theme.json") console.warn("failed to get theme.json")
this.chrome.appliedTheme.info = {} this.chrome.appliedTheme.info = {}
} }
if(!onlyPrefs) { if (!onlyPrefs) {
document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}` document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}`
document.querySelectorAll(`[id*='less']`).forEach(el => { document.querySelectorAll(`[id*='less']`).forEach(el => {
el.remove() el.remove()
@ -935,10 +935,10 @@ const app = new Vue({
} }
}, },
getThemeDirective(directive = "") { getThemeDirective(directive = "") {
if(typeof this.chrome.appliedTheme.info.directives != "object") { if (typeof this.chrome.appliedTheme.info.directives != "object") {
return "" return ""
} }
if(this.chrome.appliedTheme.info.directives[directive]) { if (this.chrome.appliedTheme.info.directives[directive]) {
return this.chrome.appliedTheme.info.directives[directive].value return this.chrome.appliedTheme.info.directives[directive].value
} else { } else {
return "" return ""
@ -961,7 +961,7 @@ const app = new Vue({
classes.simplebg = true classes.simplebg = true
} }
if(this.getThemeDirective('windowLayout') == 'twopanel') { if (this.getThemeDirective('windowLayout') == 'twopanel') {
classes.twopanel = true classes.twopanel = true
} }
return classes return classes
@ -1043,12 +1043,12 @@ const app = new Vue({
this.newPlaylist() this.newPlaylist()
} }
}, },
{ {
name: app.getLz('term.createNewPlaylistFolder'), name: app.getLz('term.createNewPlaylistFolder'),
action: () => { action: () => {
this.newPlaylistFolder() this.newPlaylistFolder()
}
} }
}
] ]
} }
this.showMenuPanel(menu, event) this.showMenuPanel(menu, event)
@ -1057,13 +1057,13 @@ const app = new Vue({
let self = this let self = this
this.mk.api.v3.music( this.mk.api.v3.music(
`/v1/me/library/playlist-folders/${id}`, {}, { `/v1/me/library/playlist-folders/${id}`, {}, {
fetchOptions: { fetchOptions: {
method: "PATCH", method: "PATCH",
body: JSON.stringify({ body: JSON.stringify({
attributes: {name: name} attributes: { name: name }
}) })
}
} }
}
).then(res => { ).then(res => {
self.refreshPlaylists() self.refreshPlaylists()
}) })
@ -1072,13 +1072,13 @@ const app = new Vue({
let self = this let self = this
this.mk.api.v3.music( this.mk.api.v3.music(
`/v1/me/library/playlists/${id}`, {}, { `/v1/me/library/playlists/${id}`, {}, {
fetchOptions: { fetchOptions: {
method: "PATCH", method: "PATCH",
body: JSON.stringify({ body: JSON.stringify({
attributes: {name: name} attributes: { name: name }
}) })
}
} }
}
).then(res => { ).then(res => {
self.refreshPlaylists() self.refreshPlaylists()
}) })
@ -1103,9 +1103,9 @@ const app = new Vue({
fetchOptions: { fetchOptions: {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
"attributes": {"name": name}, "attributes": { "name": name },
"relationships": { "relationships": {
"tracks": {"data": tracks}, "tracks": { "data": tracks },
} }
}) })
} }
@ -1155,7 +1155,7 @@ const app = new Vue({
app.appRoute("collection-list") app.appRoute("collection-list")
}, },
async showArtistView(artist, title, view) { 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) console.log(response)
await this.showCollection(response, title, "artists") await this.showCollection(response, title, "artists")
}, },
@ -1273,7 +1273,7 @@ const app = new Vue({
"limit[artists:top-songs]": 20, "limit[artists:top-songs]": 20,
"art[url]": "f", "art[url]": "f",
l: this.mklang l: this.mklang
}, {includeResponseMeta: !0}) }, { includeResponseMeta: !0 })
console.log(artistData.data.data[0]) console.log(artistData.data.data[0])
this.artistPage.data = artistData.data.data[0] this.artistPage.data = artistData.data.data[0]
this.page = "artist-page" this.page = "artist-page"
@ -1379,17 +1379,17 @@ const app = new Vue({
// Minutes // Minutes
if (time >= 60) { 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 // Hours
if (time >= 3600) { 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 // Days
if (time >= 86400) { 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(', ') returnTime = longFormat.reverse().join(', ')
} }
@ -1431,7 +1431,7 @@ const app = new Vue({
kind: page, kind: page,
id: id, id: id,
attributes: { 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, let u = await app.mkapi(app.mk.nowPlayingItem.playParams.kind,
(app.mk.nowPlayingItem.songId == -1), (app.mk.nowPlayingItem.songId == -1),
(app.mk.nowPlayingItem.songId != -1) ? app.mk.nowPlayingItem.songId : app.mk.nowPlayingItem["id"], (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) app.searchAndNavigate(u.data.data[0], target)
} catch (e) { } catch (e) {
app.searchAndNavigate(app.mk.nowPlayingItem, target) app.searchAndNavigate(app.mk.nowPlayingItem, target)
@ -1640,7 +1640,7 @@ const app = new Vue({
} }
if (labelId != "") { if (labelId != "") {
app.showingPlaylist = [] 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; app.page = "recordLabel_" + labelId;
} }
@ -1678,75 +1678,75 @@ const app = new Vue({
console.log(kind, id, isLibrary) console.log(kind, id, isLibrary)
app.mk.stop().then(() => { app.mk.stop().then(() => {
if (kind.includes("artist")) { if (kind.includes("artist")) {
app.mk.setStationQueue({artist: 'a-' + id}).then(() => { app.mk.setStationQueue({ artist: 'a-' + id }).then(() => {
app.mk.play() app.mk.play()
}) })
} }
// else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){ // else if (kind.includes("playlist") && (id.startsWith("p.") || id.startsWith("pl."))){
// /* Randomize array in-place using Durstenfeld shuffle algorithm */ // /* Randomize array in-place using Durstenfeld shuffle algorithm */
// function shuffleArray(array) { // function shuffleArray(array) {
// for (var i = array.length - 1; i > 0; i--) { // for (var i = array.length - 1; i > 0; i--) {
// var j = Math.floor(Math.random() * (i + 1)); // var j = Math.floor(Math.random() * (i + 1));
// var temp = array[i]; // var temp = array[i];
// array[i] = array[j]; // array[i] = array[j];
// array[j] = temp; // array[j] = temp;
// } // }
// } // }
// app.mk.clearQueue().then(function () { { // app.mk.clearQueue().then(function () { {
// app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () { // app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
// app.mk.play().then(function (){ // app.mk.play().then(function (){
// app.mk.clearQueue().then(function (){ // app.mk.clearQueue().then(function (){
// var playlistId = id // var playlistId = id
// const params = { // const params = {
// include: "tracks", // include: "tracks",
// platform: "web", // platform: "web",
// "include[library-playlists]": "catalog,tracks", // "include[library-playlists]": "catalog,tracks",
// "fields[playlists]": "curatorName,playlistType,name,artwork,url", // "fields[playlists]": "curatorName,playlistType,name,artwork,url",
// "include[library-songs]": "catalog,artists,albums", // "include[library-songs]": "catalog,artists,albums",
// "fields[catalog]": "artistUrl,albumUrl", // "fields[catalog]": "artistUrl,albumUrl",
// "fields[songs]": "artistUrl,albumUrl" // "fields[songs]": "artistUrl,albumUrl"
// } // }
// var playlistId = '' // var playlistId = ''
// try { // try {
// function getPlaylist(id, params, isLibrary){ // function getPlaylist(id, params, isLibrary){
// if (isLibrary){ // if (isLibrary){
// return app.mk.api.library.playlist(id, params) // return app.mk.api.library.playlist(id, params)
// } else { return app.mk.api.playlist(id, params)} // } else { return app.mk.api.playlist(id, params)}
// } // }
// getPlaylist(id, params, isLibrary).then(res => { // getPlaylist(id, params, isLibrary).then(res => {
// let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item)); // let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
// if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
// app.mk.queue.append(query) // app.mk.queue.append(query)
// if (!res.relationships.tracks.next) { // if (!res.relationships.tracks.next) {
// return // return
// } else { // } else {
// getPlaylistTracks(res.relationships.tracks.next) // getPlaylistTracks(res.relationships.tracks.next)
// } // }
// function getPlaylistTracks(next) { // function getPlaylistTracks(next) {
// app.apiCall(app.musicBaseUrl + next, res => { // app.apiCall(app.musicBaseUrl + next, res => {
// if (res.id != playlistId) { // if (res.id != playlistId) {
// return // return
// } // }
// let query = res.data.map(item => new MusicKit.MediaItem(item)) // let query = res.data.map(item => new MusicKit.MediaItem(item))
// if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')} // if (app.mk.shuffleMode == 1){shuffleArray(query); console.log('shf')}
// app.mk.queue.append(query) // app.mk.queue.append(query)
// if (res.next) { // if (res.next) {
// getPlaylistTracks(res.next) // getPlaylistTracks(res.next)
// } // }
// }) // })
// } // }
// }) // })
// } catch (e) {} // } catch (e) {}
// }) // })
// }) // })
// }) // })
// } // }
// }) // })
// } // }
else { else {
app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '') app.playMediaItemById((id), (kind), (isLibrary), item.attributes.url ?? '')
@ -1788,7 +1788,7 @@ const app = new Vue({
let self = this let self = this
let prefs = this.cfg.libraryPrefs.songs let prefs = this.cfg.libraryPrefs.songs
let albumAdded = self.library?.albums?.listing?.map(function (i) { 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() let startTime = new Date().getTime()
@ -1860,8 +1860,8 @@ const app = new Vue({
} }
}, },
getAlbumSort() { getAlbumSort() {
this.library.albums.sortOrder[1] = this.cfg.libraryPrefs.albums.sortOrder; this.library.albums.sortOrder[1] = this.cfg.libraryPrefs.albums.sortOrder;
this.library.albums.sorting[1] = this.cfg.libraryPrefs.albums.sort; this.library.albums.sorting[1] = this.cfg.libraryPrefs.albums.sort;
}, },
// make a copy of searchLibrarySongs except use Albums instead of Songs // make a copy of searchLibrarySongs except use Albums instead of Songs
searchLibraryAlbums(index) { searchLibraryAlbums(index) {
@ -2233,7 +2233,7 @@ const app = new Vue({
} }
if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") { if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") {
console.log(`downloading next chunk - ${library.length console.log(`downloading next chunk - ${library.length
} albums so far`) } albums so far`)
downloadChunk() downloadChunk()
} else { } else {
self.library.albums.listing = library self.library.albums.listing = library
@ -2340,7 +2340,7 @@ const app = new Vue({
} }
if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") { if (downloaded.meta.total > library.length || typeof downloaded.meta.next != "undefined") {
console.log(`downloading next chunk - ${library.length console.log(`downloading next chunk - ${library.length
} artists so far`) } artists so far`)
downloadChunk() downloadChunk()
} else { } else {
self.library.artists.listing = library self.library.artists.listing = library
@ -2357,20 +2357,20 @@ const app = new Vue({
getTotalTime() { getTotalTime() {
try { try {
if (app.showingPlaylist.relationships.tracks.data.length > 0) { 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); 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')}` 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 "" } else return ""
} catch (err) { } catch (err) {
return "" return ""
} }
}, },
async getLibrarySongs() { 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.listing = response.data.data
this.library.songs.meta = response.data.meta this.library.songs.meta = response.data.meta
}, },
async getLibraryAlbums() { 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.listing = response.data.data
this.library.albums.meta = response.data.meta this.library.albums.meta = response.data.meta
}, },
@ -2476,13 +2476,13 @@ const app = new Vue({
let self = this let self = this
this.mk.api.v3.music( this.mk.api.v3.music(
"/v1/me/library/playlist-folders/", {}, { "/v1/me/library/playlist-folders/", {}, {
fetchOptions: { fetchOptions: {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
attributes: {name: name} attributes: { name: name }
}) })
}
} }
}
).then((res) => { ).then((res) => {
let playlist = (res.data.data[0]) let playlist = (res.data.data[0])
self.playlists.listing.push({ self.playlists.listing.push({
@ -2841,15 +2841,15 @@ const app = new Vue({
line: "lrcInstrumental" line: "lrcInstrumental"
}); });
} }
preLrc.push({startTime: start, endTime: end, line: element.textContent}); preLrc.push({ startTime: start, endTime: end, line: element.textContent });
endTimes.push(end); endTimes.push(end);
} }
// first line dot // first line dot
if (preLrc.length > 0) 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 { } else {
for (element of lyricsLines) { 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; this.lyrics = preLrc;
@ -2917,17 +2917,17 @@ const app = new Vue({
console.log(id, truekind, isLibrary) console.log(id, truekind, isLibrary)
try { try {
if (truekind.includes("artist")) { if (truekind.includes("artist")) {
app.mk.setStationQueue({artist: 'a-' + id}).then(() => { app.mk.setStationQueue({ artist: 'a-' + id }).then(() => {
app.mk.play() app.mk.play()
}) })
} else if (truekind == "radioStations") { } else if (truekind == "radioStations") {
this.mk.setStationQueue({url: raurl}).then(function (queue) { this.mk.setStationQueue({ url: raurl }).then(function (queue) {
MusicKit.getInstance().play() MusicKit.getInstance().play()
}); });
} else { } else {
this.mk.setQueue({ this.mk.setQueue({
[truekind]: [id], [truekind]: [id],
parameters: {l: this.mklang} parameters: { l: this.mklang }
}).then(function (queue) { }).then(function (queue) {
MusicKit.getInstance().play() MusicKit.getInstance().play()
}) })
@ -2968,7 +2968,7 @@ const app = new Vue({
if (item) { if (item) {
app.mk.setQueue({ app.mk.setQueue({
[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id, [item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id,
parameters: {l: app.mklang} parameters: { l: app.mklang }
}).then(function () { }).then(function () {
app.mk.play().then(() => { app.mk.play().then(() => {
if (app.mk.shuffleMode == 1) { if (app.mk.shuffleMode == 1) {
@ -3025,7 +3025,7 @@ const app = new Vue({
for (let kind in itemsToPlay) { for (let kind in itemsToPlay) {
let ids = itemsToPlay[kind] let ids = itemsToPlay[kind]
if (ids.length > 0) { 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] let ids = itemsToPlay[kind]
if (ids.length > 0) { if (ids.length > 0) {
if (app.mk.queue._itemIDs.length > 0) { if (app.mk.queue._itemIDs.length > 0) {
app.mk.playLater({[kind + "s"]: itemsToPlay[kind]}).then(function () { app.mk.playLater({ [kind + "s"]: itemsToPlay[kind] }).then(function () {
ind += 1; ind += 1;
console.log(ind, Object.keys(itemsToPlay).length) console.log(ind, Object.keys(itemsToPlay).length)
if (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.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.attributes.playParams.id ?? item.id))
}
} }
}
) )
} else { } else {
app.mk.setQueue({[kind + "s"]: itemsToPlay[kind]}).then(function () { app.mk.setQueue({ [kind + "s"]: itemsToPlay[kind] }).then(function () {
ind += 1; ind += 1;
console.log(ind, Object.keys(itemsToPlay).length) console.log(ind, Object.keys(itemsToPlay).length)
if (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.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"))) { if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) {
app.mk.setQueue({ app.mk.setQueue({
[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id, [item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id,
parameters: {l: app.mklang} parameters: { l: app.mklang }
}).then(function () { }).then(function () {
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function () { app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ?? 1).then(function () {
if ((app.showingPlaylist && app.showingPlaylist.id == id)) { if ((app.showingPlaylist && app.showingPlaylist.id == id)) {
@ -3114,7 +3114,7 @@ const app = new Vue({
} else { } else {
this.mk.setQueue({ this.mk.setQueue({
[truekind]: [id], [truekind]: [id],
parameters: {l: this.mklang} parameters: { l: this.mklang }
}).then(function (queue) { }).then(function (queue) {
if (item && ((queue._itemIDs[childIndex] != item.id))) { if (item && ((queue._itemIDs[childIndex] != item.id))) {
childIndex = queue._itemIDs.indexOf(item.id) childIndex = queue._itemIDs.indexOf(item.id)
@ -3226,7 +3226,7 @@ const app = new Vue({
with: ["serverBubbles", "lyricSnippet"], with: ["serverBubbles", "lyricSnippet"],
"art[url]": "f", "art[url]": "f",
"art[social-profiles:url]": "c" "art[social-profiles:url]": "c"
}, {includeResponseMeta: !0}).then(function (results) { }, { includeResponseMeta: !0 }).then(function (results) {
results.data.results["meta"] = results.data.meta results.data.results["meta"] = results.data.meta
self.search.resultsSocial = results.data.results self.search.resultsSocial = results.data.results
}) })
@ -3246,7 +3246,7 @@ const app = new Vue({
return type.type == this return type.type == this
}, type) }, type)
if (index == -1) { if (index == -1) {
types.push({type: type, id: [id]}) types.push({ type: type, id: [id] })
} else { } else {
types[index].id.push(id) types[index].id.push(id)
} }
@ -3367,9 +3367,13 @@ const app = new Vue({
}, },
async getCurrentArtURL() { async getCurrentArtURL() {
try { try {
let artworkSize = 50
if (app.getThemeDirective("lcdArtworkSize") != "") {
artworkSize = app.getThemeDirective("lcdArtworkSize")
}
this.currentArtUrl = ''; 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 != '') { 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 { try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) { } 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}`); let data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
data = data.data.data[0]; data = data.data.data[0];
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) { 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 ?? ''); ipcRenderer.send('updateRPCImage', this.currentArtUrl ?? '');
try { try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`); document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
@ -3430,10 +3434,10 @@ const app = new Vue({
}, },
quickPlay(query) { quickPlay(query) {
let self = this 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({ MusicKit.getInstance().setQueue({
song: data["songs"]['data'][0]["id"], song: data["songs"]['data'][0]["id"],
parameters: {l: app.mklang} parameters: { l: app.mklang }
}).then(function (queue) { }).then(function (queue) {
MusicKit.getInstance().play() MusicKit.getInstance().play()
setTimeout(() => { setTimeout(() => {
@ -3611,7 +3615,7 @@ const app = new Vue({
let data_type = this.mk.nowPlayingItem.playParams.kind let data_type = this.mk.nowPlayingItem.playParams.kind
let item_id = this.mk.nowPlayingItem.attributes.playParams.id ?? this.mk.nowPlayingItem.id let item_id = this.mk.nowPlayingItem.attributes.playParams.id ?? this.mk.nowPlayingItem.id
let isLibrary = this.mk.nowPlayingItem.attributes.playParams.isLibrary ?? false 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.selectedMediaItems = []
app.select_selectMediaItem(item_id, data_type, 0, '12344', isLibrary) app.select_selectMediaItem(item_id, data_type, 0, '12344', isLibrary)
let useMenu = "normal" let useMenu = "normal"
@ -3630,36 +3634,36 @@ const app = new Vue({
app.love(app.mk.nowPlayingItem) app.love(app.mk.nowPlayingItem)
} }
}, },
{ {
"icon": "./assets/feather/heart.svg", "icon": "./assets/feather/heart.svg",
"id": "unlove", "id": "unlove",
"active": true, "active": true,
"name": app.getLz('action.unlove'), "name": app.getLz('action.unlove'),
"hidden": true, "hidden": true,
"action": function () { "action": function () {
app.unlove(app.mk.nowPlayingItem) app.unlove(app.mk.nowPlayingItem)
} }
}, },
{ {
"icon": "./assets/feather/thumbs-down.svg", "icon": "./assets/feather/thumbs-down.svg",
"id": "dislike", "id": "dislike",
"name": app.getLz('action.dislike'), "name": app.getLz('action.dislike'),
"hidden": false, "hidden": false,
"disabled": true, "disabled": true,
"action": function () { "action": function () {
app.dislike(app.mk.nowPlayingItem) app.dislike(app.mk.nowPlayingItem)
} }
}, },
{ {
"icon": "./assets/feather/thumbs-down.svg", "icon": "./assets/feather/thumbs-down.svg",
"id": "undo_dislike", "id": "undo_dislike",
"name": app.getLz('action.undoDislike'), "name": app.getLz('action.undoDislike'),
"active": true, "active": true,
"hidden": true, "hidden": true,
"action": function () { "action": function () {
app.unlove(app.mk.nowPlayingItem) app.unlove(app.mk.nowPlayingItem)
} }
}, },
], ],
items: [ items: [
{ {
@ -3691,7 +3695,7 @@ const app = new Vue({
"icon": "./assets/feather/radio.svg", "icon": "./assets/feather/radio.svg",
"name": app.getLz('action.startRadio'), "name": app.getLz('action.startRadio'),
"action": function () { "action": function () {
app.mk.setStationQueue({song: app.mk.nowPlayingItem.id}).then(() => { app.mk.setStationQueue({ song: app.mk.nowPlayingItem.id }).then(() => {
app.mk.play() app.mk.play()
app.selectedMediaItems = [] app.selectedMediaItems = []
}) })
@ -4008,7 +4012,7 @@ const app = new Vue({
Vue.component('animated-number', { Vue.component('animated-number', {
template: "<div style='display: inline-block;'>{{ displayNumber }}</div>", template: "<div style='display: inline-block;'>{{ displayNumber }}</div>",
props: {'number': {default: 0}}, props: { 'number': { default: 0 } },
data() { data() {
return { return {