Merge branch 'musickit-v3' into typescript
This commit is contained in:
commit
2f57d9bb3f
11 changed files with 338 additions and 252 deletions
|
@ -382,9 +382,9 @@ const app = new Vue({
|
|||
}) {
|
||||
let self = this
|
||||
try {
|
||||
app.mk.api.socialBadgingMap().then(data => {
|
||||
self.socialBadges.badgeMap = data.badgingMap
|
||||
cb(data.badgingMap)
|
||||
app.mk.api.v3.music("/v1/social/badging-map").then(data => {
|
||||
self.socialBadges.badgeMap = data.data.results.badgingMap
|
||||
cb(data.data.results.badgingMap)
|
||||
})
|
||||
} catch (ex) {
|
||||
this.socialBadges.badgeMap = {}
|
||||
|
@ -435,9 +435,9 @@ const app = new Vue({
|
|||
type: self.selectedMediaItems[i].kind
|
||||
})
|
||||
} else if ((self.selectedMediaItems[i].kind == "album" || self.selectedMediaItems[i].kind == "albums") && self.selectedMediaItems[i].isLibrary != true) {
|
||||
self.selectedMediaItems[i].kind = "albums"
|
||||
let res = await self.mk.api.albumRelationship(self.selectedMediaItems[i].id, "tracks");
|
||||
let ids = res.map(function (i) {
|
||||
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}
|
||||
})
|
||||
pl_items = pl_items.concat(ids)
|
||||
|
@ -449,8 +449,8 @@ const app = new Vue({
|
|||
})
|
||||
} else if ((self.selectedMediaItems[i].kind == "library-album" || self.selectedMediaItems[i].kind == "library-albums") || (self.selectedMediaItems[i].kind == "album" && self.selectedMediaItems[i].isLibrary == true)) {
|
||||
self.selectedMediaItems[i].kind = "library-albums"
|
||||
let res = await self.mk.api.library.albumRelationship(self.selectedMediaItems[i].id, "tracks");
|
||||
let ids = res.map(function (i) {
|
||||
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}
|
||||
})
|
||||
pl_items = pl_items.concat(ids)
|
||||
|
@ -463,7 +463,18 @@ const app = new Vue({
|
|||
|
||||
}
|
||||
this.modals.addToPlaylist = false
|
||||
this.mk.api.library.appendTracksToPlaylist(playlist_id, pl_items).then(() => {
|
||||
await app.mk.api.v3.music(
|
||||
`/v1/me/library/playlists/${playlist_id}/tracks`,
|
||||
{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
data: pl_items
|
||||
})
|
||||
}
|
||||
}
|
||||
).then(() => {
|
||||
if (this.page == 'playlist_' + this.showingPlaylist.id) {
|
||||
this.getPlaylistFromID(this.showingPlaylist.id)
|
||||
}
|
||||
|
@ -485,8 +496,12 @@ const app = new Vue({
|
|||
}
|
||||
this.mk._services.timing.mode = 0
|
||||
this.platform = ipcRenderer.sendSync('cider-platform');
|
||||
// Set profile name
|
||||
this.chrome.userinfo = await this.mkapi("personalSocialProfile", false, "")
|
||||
|
||||
try{
|
||||
// Set profile name
|
||||
this.chrome.userinfo = (await app.mk.api.v3.music(`/v1/me/social-profile`)).data.data[0]
|
||||
} catch (err) {}
|
||||
|
||||
// API Fallback
|
||||
if (!this.chrome.userinfo) {
|
||||
this.chrome.userinfo = {
|
||||
|
@ -618,8 +633,8 @@ const app = new Vue({
|
|||
} catch (e) {
|
||||
}
|
||||
if (!previewURL) {
|
||||
app.mk.api.song(app.mk.nowPlayingItem._songId ?? app.mk.nowPlayingItem.relationships.catalog.data[0].id).then((response) => {
|
||||
previewURL = response.attributes.previews[0].url
|
||||
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
|
||||
if (previewURL)
|
||||
ipcRenderer.send('getPreviewURL', previewURL)
|
||||
})
|
||||
|
@ -824,7 +839,24 @@ const app = new Vue({
|
|||
if (tracks.length > 0) {
|
||||
request.tracks = tracks
|
||||
}
|
||||
app.mk.api.library.createPlaylist(request).then(res => {
|
||||
app.mk.api.v3.music(`/v1/me/library/playlists`, {},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "POST",
|
||||
body: JSON.stringify(
|
||||
{
|
||||
"attributes":
|
||||
{ "name": name },
|
||||
"relationships":
|
||||
{ "tracks":
|
||||
{ "data": tracks },
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
res = res.data.data[0]
|
||||
console.log(res)
|
||||
self.appRoute(`playlist_` + res.id);
|
||||
self.showingPlaylist = [];
|
||||
|
@ -845,7 +877,13 @@ const app = new Vue({
|
|||
deletePlaylist(id) {
|
||||
let self = this
|
||||
if (confirm(`Are you sure you want to delete this playlist?`)) {
|
||||
app.mk.api.library.deletePlaylist(id).then(res => {
|
||||
app.mk.api.v3.music(`/v1/me/library/playlists/${id}`, {},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
// remove this playlist from playlists.listing if it exists
|
||||
let found = self.playlists.listing.find(item => item.id == id)
|
||||
if (found) {
|
||||
|
@ -862,15 +900,16 @@ const app = new Vue({
|
|||
app.appRoute("collection-list")
|
||||
},
|
||||
async showArtistView(artist, title, view) {
|
||||
let response = await this.mk.api.artistView(artist, view, {}, {view: view, includeResponseMeta: !0})
|
||||
let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists/${artist}/view/${view}`)).data
|
||||
console.log(response)
|
||||
await this.showCollection(response, title, "artists")
|
||||
},
|
||||
async showRecordLabelView(label, title, view) {
|
||||
let response = await this.mk.api.recordLabelView(label, view, {}, {view: view, includeResponseMeta: !0})
|
||||
async showRecordLabelView(label, title, view) {
|
||||
let response = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/record-labels/${label}/view/${view}`)).data
|
||||
await this.showCollection(response, title, "record-labels")
|
||||
},
|
||||
async showSearchView(term, group, title) {
|
||||
let response = await this.mk.api.search(term, {
|
||||
let response = await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search?term=${term}`, {
|
||||
platform: "web",
|
||||
groups: group,
|
||||
types: "activities,albums,apple-curators,artists,curators,editorial-items,music-movies,music-videos,playlists,songs,stations,tv-episodes,uploaded-videos,record-labels",
|
||||
|
@ -894,17 +933,19 @@ const app = new Vue({
|
|||
},
|
||||
omit: {
|
||||
resource: ["autos"]
|
||||
}
|
||||
}, {groups: group, includeResponseMeta: !0})
|
||||
console.log(response)
|
||||
},
|
||||
groups: group
|
||||
})
|
||||
console.log('searchres',response)
|
||||
let responseFormat = {
|
||||
data: response[group].data.data,
|
||||
next: response[group].next,
|
||||
data: response.data.results[group].data,
|
||||
next: response.data.results[group].data,
|
||||
groups: group
|
||||
}
|
||||
await this.showCollection(responseFormat, title, "search")
|
||||
},
|
||||
async getPlaylistContinuous(response, transient = false) {
|
||||
response = response.data.data[0]
|
||||
let self = this
|
||||
let playlistId = response.id
|
||||
if (!transient) this.playlists.loadingState = 0
|
||||
|
@ -937,30 +978,26 @@ const app = new Vue({
|
|||
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"
|
||||
"fields[playlists]": "curatorName,playlistType,name,artwork,url,playParams",
|
||||
"include[library-songs]": "catalog,artists,albums,playParams,name,artwork,url",
|
||||
"fields[catalog]": "artistUrl,albumUrl,url",
|
||||
"fields[songs]": "artistUrl,albumUrl,playParams,name,artwork,url,artistName,albumName,durationInMillis"
|
||||
}
|
||||
if (!transient) {
|
||||
this.playlists.loadingState = 0;
|
||||
}
|
||||
let playlistId = ''
|
||||
|
||||
try {
|
||||
app.mk.api.library.playlist(id, params).then(res => {
|
||||
}
|
||||
app.mk.api.v3.music(`/v1/me/library/playlists/${id}`, params).then(res => {
|
||||
self.getPlaylistContinuous(res, transient)
|
||||
})
|
||||
} catch (e) {
|
||||
}).catch((e) => {
|
||||
console.log(e);
|
||||
try {
|
||||
app.mk.api.library.playlist(id, params).then(res => {
|
||||
app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/playlists/${id}`,params).then(res => {
|
||||
self.getPlaylistContinuous(res, transient)
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
async getArtistFromID(id) {
|
||||
|
@ -973,8 +1010,8 @@ const app = new Vue({
|
|||
"limit[artists:top-songs]": 20,
|
||||
"art[url]": "f"
|
||||
}, {includeResponseMeta: !0})
|
||||
console.log(artistData)
|
||||
this.artistPage.data = artistData.data[0]
|
||||
console.log(artistData.data.data[0])
|
||||
this.artistPage.data = artistData.data.data[0]
|
||||
this.page = "artist-page"
|
||||
},
|
||||
progressBarStyle() {
|
||||
|
@ -1023,7 +1060,7 @@ const app = new Vue({
|
|||
this.search.hints = []
|
||||
return
|
||||
}
|
||||
let hints = await app.mkapi("searchHints", false, this.search.term)
|
||||
let hints = await (await app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/search/hints?term=${this.search.term}`)).data.results
|
||||
this.search.hints = hints ? hints.terms : []
|
||||
},
|
||||
getSongProgress() {
|
||||
|
@ -1137,7 +1174,7 @@ const app = new Vue({
|
|||
},
|
||||
async getNowPlayingItemDetailed(target) {
|
||||
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"});
|
||||
app.searchAndNavigate(u, target)
|
||||
app.searchAndNavigate(u.data.data[0], target)
|
||||
},
|
||||
async searchAndNavigate(item, target) {
|
||||
let self = this
|
||||
|
@ -1162,10 +1199,10 @@ const app = new Vue({
|
|||
}
|
||||
|
||||
if (artistId == "") {
|
||||
let artistQuery = await app.mk.api.search(item.attributes.artistName, {
|
||||
let artistQuery =(await app.mk.api.v3.music(`v1/catalog/${app.mk.storefrontId}/search?term=${item.attributes.artistName}`,{
|
||||
limit: 1,
|
||||
types: 'artists'
|
||||
})
|
||||
})).data.results;
|
||||
try {
|
||||
if (artistQuery.artists.data.length > 0) {
|
||||
artistId = artistQuery.artists.data[0].id;
|
||||
|
@ -1198,10 +1235,10 @@ const app = new Vue({
|
|||
|
||||
if (albumId == "") {
|
||||
try {
|
||||
let albumQuery = await app.mk.api.search(item.attributes.albumName + " " + (item.attributes.artistName ?? ""), {
|
||||
let albumQuery =(await app.mk.api.v3.music(`v1/catalog/${app.mk.storefrontId}/search?term=${item.attributes.albumName + " " + (item.attributes.artistName ?? "")}`,{
|
||||
limit: 1,
|
||||
types: 'albums'
|
||||
})
|
||||
})).data.results;
|
||||
if (albumQuery.albums.data.length > 0) {
|
||||
albumId = albumQuery.albums.data[0].id;
|
||||
console.log(albumId)
|
||||
|
@ -1222,10 +1259,10 @@ const app = new Vue({
|
|||
|
||||
if (labelId == "") {
|
||||
try {
|
||||
let labelQuery = await app.mk.api.search(item.attributes.recordLabel, {
|
||||
let labelQuery =(await app.mk.api.v3.music(`v1/catalog/${app.mk.storefrontId}/search?term=${item.attributes.recordLabel}`,{
|
||||
limit: 1,
|
||||
types: 'record-labels'
|
||||
})
|
||||
})).data.results;
|
||||
if (labelQuery["record-labels"].data.length > 0) {
|
||||
labelId = labelQuery["record-labels"].data[0].id;
|
||||
console.log(labelId)
|
||||
|
@ -1350,14 +1387,14 @@ const app = new Vue({
|
|||
a = []
|
||||
} finally {
|
||||
if (kind == "appleCurator") {
|
||||
app.appleCurator = a
|
||||
app.appleCurator = a.data.data[0]
|
||||
} else {
|
||||
this.getPlaylistContinuous(a)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (kind == "appleCurator") {
|
||||
app.appleCurator = a
|
||||
app.appleCurator = a.data.data[0]
|
||||
} else {
|
||||
this.getPlaylistContinuous(a)
|
||||
}
|
||||
|
@ -1566,14 +1603,17 @@ const app = new Vue({
|
|||
}
|
||||
},
|
||||
async mkapi(method, library = false, term, params = {}, params2 = {}, attempts = 0) {
|
||||
if (method.includes(`recordLabel`)){method = `record-labels`}
|
||||
if (method.includes(`appleCurator`)){method = `apple-curators`}
|
||||
if (attempts > 3) {
|
||||
return
|
||||
}
|
||||
let truemethod = (!method.endsWith("s")) ? (method + "s") : method;
|
||||
try {
|
||||
if (library) {
|
||||
return await this.mk.api.library[method](term, params, params2)
|
||||
} else {
|
||||
return await this.mk.api[method](term, params, params2)
|
||||
return await this.mk.api.v3.music(`v1/me/library/${truemethod}/${term.toString()}`, params, params2)
|
||||
} else {
|
||||
return await this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/${truemethod}/${term.toString()}`, params, params2)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
@ -1625,14 +1665,14 @@ const app = new Vue({
|
|||
}
|
||||
self.library.songs.downloadState = 1
|
||||
if (downloaded == null) {
|
||||
app.mk.api.library.songs("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
app.mk.api.v3.music(`/v1/me/library/songs/`, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
} else {
|
||||
|
||||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
if (downloaded.next != null) {
|
||||
app.mk.api.v3.music(downloaded.next, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
|
@ -1706,13 +1746,13 @@ const app = new Vue({
|
|||
limit: 100,
|
||||
}
|
||||
if (downloaded == null) {
|
||||
app.mk.api.library.albums("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
app.mk.api.v3.music(`/v1/me/library/albums/`, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
} else {
|
||||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
if (downloaded.next != null) {
|
||||
app.mk.api.v3.music(downloaded.next, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
|
@ -1787,13 +1827,14 @@ const app = new Vue({
|
|||
limit: 100,
|
||||
}
|
||||
if (downloaded == null) {
|
||||
app.mk.api.library.artists("", params, {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
app.mk.api.v3.music(`/v1/me/library/artists/`, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
|
||||
} else {
|
||||
if (downloaded.next != null && typeof downloaded.next === "function") {
|
||||
downloaded.next("", "artists", {includeResponseMeta: !0}).then((response) => {
|
||||
processChunk(response)
|
||||
if (downloaded.next != null) {
|
||||
app.mk.api.v3.music(downloaded.next, params).then((response) => {
|
||||
processChunk(response.data)
|
||||
})
|
||||
} else {
|
||||
console.log("Download next", downloaded.next)
|
||||
|
@ -1852,20 +1893,20 @@ const app = new Vue({
|
|||
},
|
||||
async getLibrarySongs() {
|
||||
let response = await this.mkapi("songs", true, "", {limit: 100}, {includeResponseMeta: !0})
|
||||
this.library.songs.listing = response.data
|
||||
this.library.songs.meta = response.meta
|
||||
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}, {includeResponseMeta: !0})
|
||||
this.library.albums.listing = response.data
|
||||
this.library.albums.meta = response.meta
|
||||
this.library.albums.listing = response.data.data
|
||||
this.library.albums.meta = response.data.meta
|
||||
},
|
||||
async getListenNow(attempt = 0) {
|
||||
if (attempt > 3) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.listennow = await this.mk.api.personalRecommendations("",
|
||||
this.listennow = (await this.mk.api.v3.music(`v1/me/recommendations?timezone=${encodeURIComponent(this.formatTimezoneOffset())}`,
|
||||
{
|
||||
name: "listen-now",
|
||||
with: "friendsMix,library,social",
|
||||
|
@ -1892,7 +1933,7 @@ const app = new Vue({
|
|||
{
|
||||
includeResponseMeta: !0,
|
||||
reload: !0
|
||||
});
|
||||
})).data;
|
||||
console.log(this.listennow)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
@ -1904,19 +1945,18 @@ const app = new Vue({
|
|||
return
|
||||
}
|
||||
try {
|
||||
let browse = await this.mk.api.groupings("",
|
||||
{
|
||||
platform: "web",
|
||||
name: "music",
|
||||
"omit[resource:artists]": "relationships",
|
||||
"include[albums]": "artists",
|
||||
"include[songs]": "artists",
|
||||
"include[music-videos]": "artists",
|
||||
extend: "editorialArtwork,artistUrl",
|
||||
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
|
||||
"art[url]": "f"
|
||||
});
|
||||
this.browsepage = browse[0];
|
||||
let browse = await app.mk.api.v3.music(`/v1/editorial/${app.mk.storefrontId}/groupings`, {
|
||||
platform: "web",
|
||||
name: "music",
|
||||
"omit[resource:artists]": "relationships",
|
||||
"include[albums]": "artists",
|
||||
"include[songs]": "artists",
|
||||
"include[music-videos]": "artists",
|
||||
extend: "editorialArtwork,artistUrl",
|
||||
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
|
||||
"art[url]": "f"
|
||||
});
|
||||
this.browsepage = browse.data.data[0];
|
||||
console.log(this.browsepage)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
@ -1928,11 +1968,11 @@ const app = new Vue({
|
|||
return
|
||||
}
|
||||
try {
|
||||
this.radio.personal = await this.mkapi("recentRadioStations", false, "",
|
||||
{
|
||||
"platform": "web",
|
||||
"art[url]": "f"
|
||||
});
|
||||
this.radio.personal = (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`,
|
||||
{
|
||||
"platform": "web",
|
||||
"art[url]": "f"
|
||||
})).data.data;
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.getRadioStations(attempt + 1)
|
||||
|
@ -2018,7 +2058,11 @@ const app = new Vue({
|
|||
removeFromLibrary(kind, id) {
|
||||
let self = this
|
||||
let truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
this.mk.api.library.remove({[truekind]: id}).then((data) => {
|
||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}}).then((data) => {
|
||||
self.getLibrarySongsFull(true)
|
||||
})
|
||||
},
|
||||
|
@ -2558,7 +2602,8 @@ const app = new Vue({
|
|||
if (term == "") {
|
||||
return
|
||||
}
|
||||
this.mk.api.search(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",
|
||||
"relate[editorial-items]": "contents",
|
||||
|
@ -2576,16 +2621,19 @@ const app = new Vue({
|
|||
"platform": "web",
|
||||
limit: 25
|
||||
}).then(function (results) {
|
||||
self.search.results = results
|
||||
results.data.results["meta"] = results.data.meta
|
||||
self.search.results = results.data.results
|
||||
})
|
||||
await this.mk.api.socialSearch(this.search.term, {
|
||||
|
||||
await app.mk.api.v3.music(`v1/social/${app.mk.storefrontId}/search?term=${app.search.term}`, {
|
||||
types: ["playlists", "social-profiles"],
|
||||
limit: 25,
|
||||
with: ["serverBubbles", "lyricSnippet"],
|
||||
"art[url]": "f",
|
||||
"art[social-profiles:url]": "c"
|
||||
}, {includeResponseMeta: !0}).then(function (results) {
|
||||
self.search.resultsSocial = results
|
||||
results.data.results["meta"] = results.data.meta
|
||||
self.search.resultsSocial = results.data.results
|
||||
})
|
||||
},
|
||||
async inLibrary(items = []) {
|
||||
|
@ -2608,11 +2656,18 @@ const app = new Vue({
|
|||
types[index].id.push(id)
|
||||
}
|
||||
}
|
||||
return await this.mk.api.catalogResources(types, {
|
||||
types2 = types.map(function(item){return {[`ids[${item.type}]`]: [item.id]}})
|
||||
types2 = types2.reduce(function(result, item) {
|
||||
var key = Object.keys(item)[0]; //first property: a, b, c
|
||||
result[key] = item[key];
|
||||
return result;
|
||||
}, {});
|
||||
return (await
|
||||
this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}`, {...{
|
||||
"omit[resource]": "autos",
|
||||
relate: "library",
|
||||
fields: "inLibrary"
|
||||
})
|
||||
},...types2})).data.data
|
||||
},
|
||||
isInLibrary(playParams) {
|
||||
let self = this
|
||||
|
@ -2777,7 +2832,8 @@ const app = new Vue({
|
|||
} catch (e) {
|
||||
}
|
||||
} else {
|
||||
let data = await this.mk.api.library.song(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];
|
||||
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
|
||||
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
|
||||
try {
|
||||
|
@ -2798,9 +2854,9 @@ const app = new Vue({
|
|||
},
|
||||
async setLibraryArt() {
|
||||
if (typeof this.mk.nowPlayingItem === "undefined") return;
|
||||
const data = await this.mk.api.library.song(this.mk.nowPlayingItem["id"])
|
||||
try {
|
||||
const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id)
|
||||
const data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
|
||||
data = data.data.data[0];
|
||||
|
||||
if (data != null && data !== "") {
|
||||
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', 'url("' + (data["attributes"]["artwork"]["url"]).toString() + '")');
|
||||
|
@ -2812,9 +2868,9 @@ const app = new Vue({
|
|||
},
|
||||
async setLibraryArtBG() {
|
||||
if (typeof this.mk.nowPlayingItem === "undefined") return;
|
||||
const data = await this.mk.api.library.song(this.mk.nowPlayingItem["id"])
|
||||
try {
|
||||
const data = await this.mk.api.library.song(this.mk.nowPlayingItem.id)
|
||||
const data = await this.mk.api.v3.music(`/v1/me/library/songs/${this.mk.nowPlayingItem.id}`);
|
||||
data = data.data.data[0];
|
||||
|
||||
if (data != null && data !== "") {
|
||||
getBase64FromUrl((data["attributes"]["artwork"]["url"]).toString()).then(img => {
|
||||
|
@ -2848,7 +2904,7 @@ const app = new Vue({
|
|||
}
|
||||
id = item.id
|
||||
}
|
||||
let response = await this.mk.api.v3.music(`/v1/me/ratings/${type}?platform=web&ids=${id}`)
|
||||
let response = await this.mk.api.v3.music(`/v1/me/ratings/${type}?platform=web&ids=${type.includes('library') ? item.id : id}}`)
|
||||
if (response.data.data.length != 0) {
|
||||
let value = response.data.data[0].attributes.value
|
||||
return value
|
||||
|
@ -2965,8 +3021,9 @@ const app = new Vue({
|
|||
},
|
||||
fetchPlaylist(id, callback) {
|
||||
// id can be found in playlist.attributes.playParams.globalId
|
||||
this.mk.api.playlist(id).then(res => {
|
||||
callback(res)
|
||||
// this.mk.api.
|
||||
this.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/playlists/${id}`).then(res => {
|
||||
callback(res.data.data[0])
|
||||
})
|
||||
|
||||
// tracks are found in relationship.data
|
||||
|
@ -3175,7 +3232,22 @@ const app = new Vue({
|
|||
ipcRenderer.send('setFullScreen', false);
|
||||
app.appMode = 'player';
|
||||
}
|
||||
}
|
||||
},
|
||||
formatTimezoneOffset : (e=new Date)=>{
|
||||
let leadingZeros = (e,s=2)=>{
|
||||
let n = "" + e;
|
||||
for (; n.length < s; )
|
||||
n = "0" + n;
|
||||
return n
|
||||
}
|
||||
|
||||
const s = e.getTimezoneOffset()
|
||||
, n = Math.floor(Math.abs(s) / 60)
|
||||
, d = Math.round(Math.abs(s) % 60);
|
||||
let h = "+";
|
||||
return 0 !== s && (h = s > 0 ? "-" : "+"),
|
||||
`${h}${leadingZeros(n, 2)}:${leadingZeros(d, 2)}`
|
||||
},
|
||||
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue