fix #80
This commit is contained in:
parent
919729f618
commit
6b82771697
1 changed files with 363 additions and 410 deletions
|
@ -378,8 +378,7 @@ const app = new Vue({
|
||||||
let data = await response.text();
|
let data = await response.text();
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
getSocialBadges(cb = () => {
|
getSocialBadges(cb = () => {}) {
|
||||||
}) {
|
|
||||||
let self = this
|
let self = this
|
||||||
try {
|
try {
|
||||||
app.mk.api.v3.music("/v1/social/badging-map").then(data => {
|
app.mk.api.v3.music("/v1/social/badging-map").then(data => {
|
||||||
|
@ -464,9 +463,7 @@ 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({
|
||||||
|
@ -486,6 +483,7 @@ const app = new Vue({
|
||||||
this.mk = MusicKit.getInstance()
|
this.mk = MusicKit.getInstance()
|
||||||
this.mk.authorize().then(() => {
|
this.mk.authorize().then(() => {
|
||||||
self.mkIsReady = true
|
self.mkIsReady = true
|
||||||
|
document.location.reload()
|
||||||
})
|
})
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
if (this.isDev) {
|
if (this.isDev) {
|
||||||
|
@ -561,7 +559,8 @@ const app = new Vue({
|
||||||
lastItem = JSON.parse(lastItem)
|
lastItem = JSON.parse(lastItem)
|
||||||
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({[truekind]: [lastItem.attributes.playParams.id]})
|
app.mk.setQueue({
|
||||||
|
[truekind]: [lastItem.attributes.playParams.id] })
|
||||||
app.mk.mute()
|
app.mk.mute()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
app.mk.play().then(() => {
|
app.mk.play().then(() => {
|
||||||
|
@ -580,8 +579,7 @@ const app = new Vue({
|
||||||
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) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -630,8 +628,7 @@ const app = new Vue({
|
||||||
let previewURL = null
|
let previewURL = null
|
||||||
try {
|
try {
|
||||||
previewURL = app.mk.nowPlayingItem.previewURL
|
previewURL = app.mk.nowPlayingItem.previewURL
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
if (!previewURL) {
|
if (!previewURL) {
|
||||||
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${app.mk.nowPlayingItem._songId ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id}`).then((response) => {
|
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/songs/${app.mk.nowPlayingItem._songId ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id}`).then((response) => {
|
||||||
previewURL = response.data.data[0].attributes.previews[0].url
|
previewURL = response.data.data[0].attributes.previews[0].url
|
||||||
|
@ -643,14 +640,12 @@ const app = new Vue({
|
||||||
ipcRenderer.send('getPreviewURL', previewURL)
|
ipcRenderer.send('getPreviewURL', previewURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
a = a.item.attributes;
|
a = a.item.attributes;
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
}
|
|
||||||
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ? ? '' : '';
|
let type = (self.mk.nowPlayingItem != null) ? self.mk.nowPlayingItem["type"] ? ? '' : '';
|
||||||
|
|
||||||
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
|
if (type.includes("musicVideo") || type.includes("uploadedVideo") || type.includes("music-movie")) {
|
||||||
|
@ -777,8 +772,7 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
playlistHeaderContextMenu(event) {
|
playlistHeaderContextMenu(event) {
|
||||||
let menu = {
|
let menu = {
|
||||||
items: [
|
items: [{
|
||||||
{
|
|
||||||
name: "New Playlist",
|
name: "New Playlist",
|
||||||
action: () => {
|
action: () => {
|
||||||
this.newPlaylist()
|
this.newPlaylist()
|
||||||
|
@ -797,9 +791,7 @@ const app = new Vue({
|
||||||
async editPlaylistFolder(id, name = "New Playlist") {
|
async editPlaylistFolder(id, name = "New Playlist") {
|
||||||
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({
|
||||||
|
@ -814,9 +806,7 @@ const app = new Vue({
|
||||||
async editPlaylist(id, name = "New Playlist") {
|
async editPlaylist(id, name = "New Playlist") {
|
||||||
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({
|
||||||
|
@ -839,23 +829,17 @@ const app = new Vue({
|
||||||
if (tracks.length > 0) {
|
if (tracks.length > 0) {
|
||||||
request.tracks = tracks
|
request.tracks = tracks
|
||||||
}
|
}
|
||||||
app.mk.api.v3.music(`/v1/me/library/playlists`, {},
|
app.mk.api.v3.music(`/v1/me/library/playlists`, {}, {
|
||||||
{
|
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(
|
body: JSON.stringify({
|
||||||
{
|
"attributes": { "name": name },
|
||||||
"attributes":
|
"relationships": {
|
||||||
{ "name": name },
|
"tracks": { "data": tracks },
|
||||||
"relationships":
|
|
||||||
{ "tracks":
|
|
||||||
{ "data": tracks },
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
}).then(res => {
|
||||||
}
|
|
||||||
}
|
|
||||||
).then(res => {
|
|
||||||
res = res.data.data[0]
|
res = res.data.data[0]
|
||||||
console.log(res)
|
console.log(res)
|
||||||
self.appRoute(`playlist_` + res.id);
|
self.appRoute(`playlist_` + res.id);
|
||||||
|
@ -877,13 +861,11 @@ const app = new Vue({
|
||||||
deletePlaylist(id) {
|
deletePlaylist(id) {
|
||||||
let self = this
|
let self = this
|
||||||
if (confirm(`Are you sure you want to delete this playlist?`)) {
|
if (confirm(`Are you sure you want to delete this playlist?`)) {
|
||||||
app.mk.api.v3.music(`/v1/me/library/playlists/${id}`, {},
|
app.mk.api.v3.music(`/v1/me/library/playlists/${id}`, {}, {
|
||||||
{
|
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
}
|
}
|
||||||
}
|
}).then(res => {
|
||||||
).then(res => {
|
|
||||||
// remove this playlist from playlists.listing if it exists
|
// remove this playlist from playlists.listing if it exists
|
||||||
let found = self.playlists.listing.find(item => item.id == id)
|
let found = self.playlists.listing.find(item => item.id == id)
|
||||||
if (found) {
|
if (found) {
|
||||||
|
@ -1076,7 +1058,8 @@ const app = new Vue({
|
||||||
return `${mins}:${seconds.replace("0.", "")}`
|
return `${mins}:${seconds.replace("0.", "")}`
|
||||||
},
|
},
|
||||||
hashCode(str) {
|
hashCode(str) {
|
||||||
let hash = 0, i, chr;
|
let hash = 0,
|
||||||
|
i, chr;
|
||||||
if (str.length === 0) return hash;
|
if (str.length === 0) return hash;
|
||||||
for (i = 0; i < str.length; i++) {
|
for (i = 0; i < str.length; i++) {
|
||||||
chr = str.charCodeAt(i);
|
chr = str.charCodeAt(i);
|
||||||
|
@ -1112,8 +1095,7 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
routeView(item) {
|
routeView(item) {
|
||||||
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ? ? (item.type ? ? '')) : (item.type ? ? ''));
|
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ? ? (item.type ? ? '')) : (item.type ? ? ''));
|
||||||
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));
|
let id = (item.attributes.playParams ? (item.attributes.playParams.id ? ? (item.id ? ? '')) : (item.id ? ? ''));;
|
||||||
;
|
|
||||||
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false;
|
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false;
|
||||||
console.log(kind, id, isLibrary)
|
console.log(kind, id, isLibrary)
|
||||||
|
|
||||||
|
@ -1195,8 +1177,7 @@ const app = new Vue({
|
||||||
artistId = artistId.substring(artistId.lastIndexOf('ids=') + 4, artistId.lastIndexOf('-'))
|
artistId = artistId.substring(artistId.lastIndexOf('ids=') + 4, artistId.lastIndexOf('-'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
}
|
|
||||||
|
|
||||||
if (artistId == "") {
|
if (artistId == "") {
|
||||||
let artistQuery = (await app.mk.api.v3.music(`v1/catalog/${app.mk.storefrontId}/search?term=${item.attributes.artistName}`, {
|
let artistQuery = (await app.mk.api.v3.music(`v1/catalog/${app.mk.storefrontId}/search?term=${item.attributes.artistName}`, {
|
||||||
|
@ -1208,8 +1189,7 @@ const app = new Vue({
|
||||||
artistId = artistQuery.artists.data[0].id;
|
artistId = artistQuery.artists.data[0].id;
|
||||||
console.log(artistId)
|
console.log(artistId)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
console.log(artistId);
|
console.log(artistId);
|
||||||
if (artistId != "")
|
if (artistId != "")
|
||||||
|
@ -1230,8 +1210,7 @@ const app = new Vue({
|
||||||
albumId = albumId.substring(0, albumId.indexOf("?i="))
|
albumId = albumId.substring(0, albumId.indexOf("?i="))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
}
|
|
||||||
|
|
||||||
if (albumId == "") {
|
if (albumId == "") {
|
||||||
try {
|
try {
|
||||||
|
@ -1243,8 +1222,7 @@ const app = new Vue({
|
||||||
albumId = albumQuery.albums.data[0].id;
|
albumId = albumQuery.albums.data[0].id;
|
||||||
console.log(albumId)
|
console.log(albumId)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (albumId != "") {
|
if (albumId != "") {
|
||||||
self.appRoute(`album/${albumId}`)
|
self.appRoute(`album/${albumId}`)
|
||||||
|
@ -1254,8 +1232,7 @@ const app = new Vue({
|
||||||
let labelId = '';
|
let labelId = '';
|
||||||
try {
|
try {
|
||||||
labelId = item.relationships['record-labels'].data[0].id
|
labelId = item.relationships['record-labels'].data[0].id
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
}
|
|
||||||
|
|
||||||
if (labelId == "") {
|
if (labelId == "") {
|
||||||
try {
|
try {
|
||||||
|
@ -1267,8 +1244,7 @@ const app = new Vue({
|
||||||
labelId = labelQuery["record-labels"].data[0].id;
|
labelId = labelQuery["record-labels"].data[0].id;
|
||||||
console.log(labelId)
|
console.log(labelId)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (labelId != "") {
|
if (labelId != "") {
|
||||||
app.showingPlaylist = []
|
app.showingPlaylist = []
|
||||||
|
@ -1289,8 +1265,7 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
playMediaItem(item) {
|
playMediaItem(item) {
|
||||||
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ? ? (item.type ? ? '')) : (item.type ? ? ''));
|
let kind = (item.attributes.playParams ? (item.attributes.playParams.kind ? ? (item.type ? ? '')) : (item.type ? ? ''));
|
||||||
let id = (item.attributes.playParams ? (item.attributes.playParams.id ?? (item.id ?? '')) : (item.id ?? ''));
|
let id = (item.attributes.playParams ? (item.attributes.playParams.id ? ? (item.id ? ? '')) : (item.id ? ? ''));;
|
||||||
;
|
|
||||||
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false;
|
let isLibrary = item.attributes.playParams ? (item.attributes.playParams.isLibrary ? ? false) : false;
|
||||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
console.log(kind, id, isLibrary)
|
console.log(kind, id, isLibrary)
|
||||||
|
@ -1398,8 +1373,7 @@ const app = new Vue({
|
||||||
} else {
|
} else {
|
||||||
this.getPlaylistContinuous(a)
|
this.getPlaylistContinuous(a)
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
;
|
|
||||||
},
|
},
|
||||||
searchLibrarySongs() {
|
searchLibrarySongs() {
|
||||||
let self = this
|
let self = this
|
||||||
|
@ -1906,8 +1880,7 @@ const app = new Vue({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.listennow = (await this.mk.api.v3.music(`v1/me/recommendations?timezone=${encodeURIComponent(this.formatTimezoneOffset())}`,
|
this.listennow = (await this.mk.api.v3.music(`v1/me/recommendations?timezone=${encodeURIComponent(this.formatTimezoneOffset())}`, {
|
||||||
{
|
|
||||||
name: "listen-now",
|
name: "listen-now",
|
||||||
with: "friendsMix,library,social",
|
with: "friendsMix,library,social",
|
||||||
"art[social-profiles:url]": "c",
|
"art[social-profiles:url]": "c",
|
||||||
|
@ -1929,8 +1902,7 @@ const app = new Vue({
|
||||||
"meta[stations]": "inflectionPoints",
|
"meta[stations]": "inflectionPoints",
|
||||||
types: "artists,albums,editorial-items,library-albums,library-playlists,music-movies,music-videos,playlists,stations,uploaded-audios,uploaded-videos,activities,apple-curators,curators,tv-shows,social-upsells",
|
types: "artists,albums,editorial-items,library-albums,library-playlists,music-movies,music-videos,playlists,stations,uploaded-audios,uploaded-videos,activities,apple-curators,curators,tv-shows,social-upsells",
|
||||||
platform: "web"
|
platform: "web"
|
||||||
},
|
}, {
|
||||||
{
|
|
||||||
includeResponseMeta: !0,
|
includeResponseMeta: !0,
|
||||||
reload: !0
|
reload: !0
|
||||||
})).data;
|
})).data;
|
||||||
|
@ -1968,8 +1940,7 @@ const app = new Vue({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.radio.personal = (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`,
|
this.radio.personal = (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
|
||||||
{
|
|
||||||
"platform": "web",
|
"platform": "web",
|
||||||
"art[url]": "f"
|
"art[url]": "f"
|
||||||
})).data.data;
|
})).data.data;
|
||||||
|
@ -1993,9 +1964,7 @@ const app = new Vue({
|
||||||
newPlaylistFolder(name = "New Folder") {
|
newPlaylistFolder(name = "New Folder") {
|
||||||
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({
|
||||||
|
@ -2058,11 +2027,11 @@ const app = new Vue({
|
||||||
removeFromLibrary(kind, id) {
|
removeFromLibrary(kind, id) {
|
||||||
let self = this
|
let self = this
|
||||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`, {}, {
|
||||||
{
|
|
||||||
fetchOptions: {
|
fetchOptions: {
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
}}).then((data) => {
|
}
|
||||||
|
}).then((data) => {
|
||||||
self.getLibrarySongsFull(true)
|
self.getLibrarySongsFull(true)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -2212,8 +2181,7 @@ const app = new Vue({
|
||||||
lrcrich = jsonResponse["message"]["body"]["macro_calls"]["track.richsync.get"]["message"]["body"]["richsync"]["richsync_body"];
|
lrcrich = jsonResponse["message"]["body"]["macro_calls"]["track.richsync.get"]["message"]["body"]["richsync"]["richsync_body"];
|
||||||
richsync = JSON.parse(lrcrich);
|
richsync = JSON.parse(lrcrich);
|
||||||
app.richlyrics = richsync;
|
app.richlyrics = richsync;
|
||||||
} catch (_) {
|
} catch (_) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lrcfile == "") {
|
if (lrcfile == "") {
|
||||||
|
@ -2442,7 +2410,8 @@ const app = new Vue({
|
||||||
MusicKit.getInstance().play()
|
MusicKit.getInstance().play()
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.mk.setQueue({[truekind]: [id]}).then(function (queue) {
|
this.mk.setQueue({
|
||||||
|
[truekind]: [id] }).then(function(queue) {
|
||||||
MusicKit.getInstance().play()
|
MusicKit.getInstance().play()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2487,7 +2456,8 @@ const app = new Vue({
|
||||||
if (childIndex != -1) {
|
if (childIndex != -1) {
|
||||||
app.mk.changeToMediaAtIndex(childIndex)
|
app.mk.changeToMediaAtIndex(childIndex)
|
||||||
} else if (item) {
|
} else if (item) {
|
||||||
app.mk.playNext({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
app.mk.playNext({
|
||||||
|
[item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id }).then(function() {
|
||||||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1)
|
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1)
|
||||||
app.mk.play()
|
app.mk.play()
|
||||||
})
|
})
|
||||||
|
@ -2499,7 +2469,8 @@ const app = new Vue({
|
||||||
} else {
|
} else {
|
||||||
app.mk.stop().then(() => {
|
app.mk.stop().then(() => {
|
||||||
if (truekind == "playlists" && (id.startsWith("p.") || id.startsWith("pl.u"))) {
|
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}).then(function () {
|
app.mk.setQueue({
|
||||||
|
[item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id }).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)) {
|
||||||
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
let query = app.showingPlaylist.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
||||||
|
@ -2522,14 +2493,16 @@ const app = new Vue({
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.mk.setQueue({[truekind]: [id]}).then(function (queue) {
|
this.mk.setQueue({
|
||||||
|
[truekind]: [id] }).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)
|
||||||
}
|
}
|
||||||
if (childIndex != -1) {
|
if (childIndex != -1) {
|
||||||
app.mk.changeToMediaAtIndex(childIndex)
|
app.mk.changeToMediaAtIndex(childIndex)
|
||||||
} else if (item) {
|
} else if (item) {
|
||||||
app.mk.playNext({[item.attributes.playParams.kind ?? item.type]: item.attributes.playParams.id ?? item.id}).then(function () {
|
app.mk.playNext({
|
||||||
|
[item.attributes.playParams.kind ? ? item.type]: item.attributes.playParams.id ? ? item.id }).then(function() {
|
||||||
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1)
|
app.mk.changeToMediaAtIndex(app.mk.queue._itemIDs.indexOf(item.id) ? ? 1)
|
||||||
app.mk.play()
|
app.mk.play()
|
||||||
})
|
})
|
||||||
|
@ -2544,8 +2517,7 @@ const app = new Vue({
|
||||||
console.log(err)
|
console.log(err)
|
||||||
try {
|
try {
|
||||||
app.mk.stop()
|
app.mk.stop()
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
this.playMediaItemById(item.attributes.playParams.id ? ? item.id, item.attributes.playParams.kind ? ? item.type, item.attributes.playParams.isLibrary ? ? false, item.attributes.url)
|
this.playMediaItemById(item.attributes.playParams.id ? ? item.id, item.attributes.playParams.kind ? ? item.type, item.attributes.playParams.isLibrary ? ? false, item.attributes.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2603,8 +2575,7 @@ const app = new Vue({
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${this.search.term}`
|
//this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${this.search.term}`
|
||||||
this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${this.search.term}`,
|
this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${this.search.term}`, {
|
||||||
{
|
|
||||||
types: "activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels",
|
types: "activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels",
|
||||||
"relate[editorial-items]": "contents",
|
"relate[editorial-items]": "contents",
|
||||||
"include[editorial-items]": "contents",
|
"include[editorial-items]": "contents",
|
||||||
|
@ -2656,18 +2627,20 @@ const app = new Vue({
|
||||||
types[index].id.push(id)
|
types[index].id.push(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
types2 = types.map(function(item){return {[`ids[${item.type}]`]: [item.id]}})
|
types2 = types.map(function(item) { return {
|
||||||
|
[`ids[${item.type}]`]: [item.id] } })
|
||||||
types2 = types2.reduce(function(result, item) {
|
types2 = types2.reduce(function(result, item) {
|
||||||
var key = Object.keys(item)[0]; //first property: a, b, c
|
var key = Object.keys(item)[0]; //first property: a, b, c
|
||||||
result[key] = item[key];
|
result[key] = item[key];
|
||||||
return result;
|
return result;
|
||||||
}, {});
|
}, {});
|
||||||
return (await
|
return (await this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}`, {... {
|
||||||
this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}`, {...{
|
|
||||||
"omit[resource]": "autos",
|
"omit[resource]": "autos",
|
||||||
relate: "library",
|
relate: "library",
|
||||||
fields: "inLibrary"
|
fields: "inLibrary"
|
||||||
},...types2})).data.data
|
},
|
||||||
|
...types2
|
||||||
|
})).data.data
|
||||||
},
|
},
|
||||||
isInLibrary(playParams) {
|
isInLibrary(playParams) {
|
||||||
let self = this
|
let self = this
|
||||||
|
@ -2759,24 +2732,21 @@ const app = new Vue({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
clearInterval(bginterval);
|
clearInterval(bginterval);
|
||||||
} catch (err) {
|
} catch (err) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.setLibraryArtBG()
|
this.setLibraryArtBG()
|
||||||
}
|
}
|
||||||
} else if (this.mk.nowPlayingItem["id"] == this.currentTrackID) {
|
} else if (this.mk.nowPlayingItem["id"] == this.currentTrackID) {
|
||||||
try {
|
try {
|
||||||
clearInterval(bginterval);
|
clearInterval(bginterval);
|
||||||
} catch (err) {
|
} catch (err) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] && document.querySelector('.bg-artwork')) {
|
if (this.mk.nowPlayingItem && this.mk.nowPlayingItem["id"] && document.querySelector('.bg-artwork')) {
|
||||||
this.setLibraryArtBG()
|
this.setLibraryArtBG()
|
||||||
try {
|
try {
|
||||||
clearInterval(bginterval);
|
clearInterval(bginterval);
|
||||||
} catch (err) {
|
} catch (err) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
|
@ -2829,8 +2799,7 @@ const app = new Vue({
|
||||||
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50);
|
this.currentArtUrl = (this.mk["nowPlayingItem"]["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50);
|
||||||
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) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
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];
|
||||||
|
@ -2838,14 +2807,12 @@ const app = new Vue({
|
||||||
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50);
|
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ? ? '').replace('{w}', 50).replace('{h}', 50);
|
||||||
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) {}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.currentArtUrl = '';
|
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}")`);
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -2863,8 +2830,7 @@ const app = new Vue({
|
||||||
} else {
|
} else {
|
||||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("")`);
|
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("")`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async setLibraryArtBG() {
|
async setLibraryArtBG() {
|
||||||
if (typeof this.mk.nowPlayingItem === "undefined") return;
|
if (typeof this.mk.nowPlayingItem === "undefined") return;
|
||||||
|
@ -2880,8 +2846,7 @@ const app = new Vue({
|
||||||
self.$store.commit("setLCDArtwork", img)
|
self.$store.commit("setLCDArtwork", img)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
quickPlay(query) {
|
quickPlay(query) {
|
||||||
|
@ -2922,17 +2887,14 @@ const app = new Vue({
|
||||||
id = item.id
|
id = item.id
|
||||||
}
|
}
|
||||||
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
||||||
fetchOptions:
|
fetchOptions: {
|
||||||
{
|
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(
|
body: JSON.stringify({
|
||||||
{
|
|
||||||
"type": "rating",
|
"type": "rating",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"value": 1
|
"value": 1
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -2946,17 +2908,14 @@ const app = new Vue({
|
||||||
id = item.id
|
id = item.id
|
||||||
}
|
}
|
||||||
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
||||||
fetchOptions:
|
fetchOptions: {
|
||||||
{
|
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify(
|
body: JSON.stringify({
|
||||||
{
|
|
||||||
"type": "rating",
|
"type": "rating",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"value": -1
|
"value": -1
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -2970,8 +2929,7 @@ const app = new Vue({
|
||||||
id = item.id
|
id = item.id
|
||||||
}
|
}
|
||||||
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
this.mk.api.v3.music(`/v1/me/ratings/${type}/${id}`, {}, {
|
||||||
fetchOptions:
|
fetchOptions: {
|
||||||
{
|
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -3062,8 +3020,7 @@ const app = new Vue({
|
||||||
items: []
|
items: []
|
||||||
},
|
},
|
||||||
normal: {
|
normal: {
|
||||||
headerItems: [
|
headerItems: [{
|
||||||
{
|
|
||||||
"icon": "./assets/feather/heart.svg",
|
"icon": "./assets/feather/heart.svg",
|
||||||
"id": "love",
|
"id": "love",
|
||||||
"name": "Love",
|
"name": "Love",
|
||||||
|
@ -3104,8 +3061,7 @@ const app = new Vue({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
items: [
|
items: [{
|
||||||
{
|
|
||||||
"icon": "./assets/feather/list.svg",
|
"icon": "./assets/feather/list.svg",
|
||||||
"name": "Add to Playlist...",
|
"name": "Add to Playlist...",
|
||||||
"hidden": true,
|
"hidden": true,
|
||||||
|
@ -3241,9 +3197,9 @@ const app = new Vue({
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
const s = e.getTimezoneOffset()
|
const s = e.getTimezoneOffset(),
|
||||||
, n = Math.floor(Math.abs(s) / 60)
|
n = Math.floor(Math.abs(s) / 60),
|
||||||
, d = Math.round(Math.abs(s) % 60);
|
d = Math.round(Math.abs(s) % 60);
|
||||||
let h = "+";
|
let h = "+";
|
||||||
return 0 !== s && (h = s > 0 ? "-" : "+"),
|
return 0 !== s && (h = s > 0 ? "-" : "+"),
|
||||||
`${h}${leadingZeros(n, 2)}:${leadingZeros(d, 2)}`
|
`${h}${leadingZeros(n, 2)}:${leadingZeros(d, 2)}`
|
||||||
|
@ -3495,8 +3451,7 @@ var checkIfScrollIsStatic = setInterval(() => {
|
||||||
// do something
|
// do something
|
||||||
}
|
}
|
||||||
position = document.getElementsByClassName('lyric-body')[0].scrollTop
|
position = document.getElementsByClassName('lyric-body')[0].scrollTop
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
}
|
|
||||||
|
|
||||||
}, 50);
|
}, 50);
|
||||||
|
|
||||||
|
@ -3514,5 +3469,3 @@ webGPU().then()
|
||||||
|
|
||||||
let screenWidth = screen.width;
|
let screenWidth = screen.width;
|
||||||
let screenHeight = screen.height;
|
let screenHeight = screen.height;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue