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)}`
|
||||
},
|
||||
|
||||
}
|
||||
})
|
||||
|
|
|
@ -70,14 +70,14 @@
|
|||
},
|
||||
async select(e) {
|
||||
let u = this.item
|
||||
let u1 = await app.mk.api.library.artistRelationship(u.id,"albums",
|
||||
let u1 = await app.mk.api.v3.music(`/v1/me/library/artists/${u.id}/albums`,
|
||||
{platform: "web",
|
||||
"include[library-albums]": "artists,tracks",
|
||||
"include[library-artists]": "catalog",
|
||||
"fields[artists]": "url",
|
||||
"includeOnly": "catalog,artists"}
|
||||
)
|
||||
app.showCollection({data : Object.assign({},u1)}, u.attributes.name?? '', '');
|
||||
app.showCollection({data : Object.assign({},u1.data.data)}, u.attributes.name?? '', '');
|
||||
},
|
||||
getArtwork(){
|
||||
let u = ""
|
||||
|
|
|
@ -502,22 +502,21 @@
|
|||
app.mk.setQueue({[truekind]: [item.attributes.playParams.id ?? item.id]}).then(function () {
|
||||
app.mk.play().then(function (){
|
||||
var playlistId = id
|
||||
function getPlaylist(id, params, isLibrary){
|
||||
function getPlaylist(id, isLibrary){
|
||||
if (isLibrary){
|
||||
return app.mk.api.library.playlist(id, params)
|
||||
} else { return app.mk.api.playlist(id, params)}
|
||||
return this.app.mk.api.v3.music(`/v1/me/library/playlists/${id}`)
|
||||
} else { return this.app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/playlists/${id}`)}
|
||||
}
|
||||
try {
|
||||
|
||||
getPlaylist(id, params, isLibrary).then(res => {
|
||||
getPlaylist(id, isLibrary).then(res => {
|
||||
//let query = res.relationships.tracks.data.map(item => new MusicKit.MediaItem(item));
|
||||
//if (app.mk.shuffleMode == 1){shuffleArray(query); }
|
||||
// console.log(query)
|
||||
// app.mk.queue.append(query)
|
||||
if (!res.relationships.tracks.next) {
|
||||
if (!res.data.relationships.tracks.next) {
|
||||
return
|
||||
} else {
|
||||
getPlaylistTracks(res.relationships.tracks.next)
|
||||
getPlaylistTracks(res.data.relationships.tracks.next)
|
||||
}
|
||||
|
||||
function getPlaylistTracks(next) {
|
||||
|
|
|
@ -122,7 +122,11 @@
|
|||
}
|
||||
let kind = this.item.attributes.playParams.kind ?? this.item.type ?? '';
|
||||
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.api.library.remove({[truekind]: id})
|
||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}})
|
||||
this.addedToLibrary = true
|
||||
},
|
||||
async contextMenu(event) {
|
||||
|
|
|
@ -96,6 +96,7 @@
|
|||
if (this.item.type && !this.item.type.includes("library")) {
|
||||
var params = {"fields[playlists]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "extend": this.revisedRandId()}
|
||||
var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params);
|
||||
res = res.data.data[0]
|
||||
this.addedToLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false
|
||||
} else {
|
||||
this.addedToLibrary = true
|
||||
|
@ -105,12 +106,17 @@
|
|||
var params = {"fields[playlists]": "inLibrary","fields[songs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library", "extend": this.revisedRandId()}
|
||||
var id = this.item.id ?? this.item.attributes.playParams.id
|
||||
var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params);
|
||||
res = res.data.data[0]
|
||||
if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
|
||||
id = res.relationships.library.data[0].id
|
||||
}
|
||||
let kind = this.item.attributes.playParams.kind ?? this.item.type ?? '';
|
||||
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.api.library.remove({[truekind]: id})
|
||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}})
|
||||
this.addedToLibrary = true
|
||||
},
|
||||
subtitleSearchNavigate(item) {
|
||||
|
|
|
@ -146,8 +146,8 @@
|
|||
let friends = this.badges[id]
|
||||
if (friends) {
|
||||
friends.forEach(function (friend) {
|
||||
self.app.mk.api.socialProfile(friend).then(data => {
|
||||
self.itemBadges.push(data)
|
||||
self.app.mk.api.v3.music(`/v1/social/${app.mk.storefrontId}/social-profiles/${friend}`).then(data => {
|
||||
self.itemBadges.push(data.data.data[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -165,6 +165,7 @@
|
|||
"extend": this.revisedRandId()
|
||||
}
|
||||
var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params);
|
||||
res = res.data.data[0]
|
||||
this.addedToLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false
|
||||
} else {
|
||||
this.addedToLibrary = true
|
||||
|
@ -180,12 +181,17 @@
|
|||
}
|
||||
var id = this.item.id ?? this.item.attributes.playParams.id
|
||||
var res = await app.mkapi(this.item.attributes.playParams.kind ?? this.item.type, this.item.attributes.playParams.isLibrary ?? false, this.item.attributes.playParams.id ?? this.item.id, params);
|
||||
res= res.data.data[0]
|
||||
if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
|
||||
id = res.relationships.library.data[0].id
|
||||
}
|
||||
let kind = this.item.attributes.playParams.kind ?? this.item.type ?? '';
|
||||
var truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.api.library.remove({[truekind]: id})
|
||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}})
|
||||
this.addedToLibrary = true
|
||||
},
|
||||
uuidv4() {
|
||||
|
|
|
@ -181,7 +181,9 @@
|
|||
this.children = []
|
||||
this.getChildren()
|
||||
this.toggleFolder()
|
||||
this.$root.mk.api.library.playlistFolderChildren(item.id).then(children => {
|
||||
|
||||
this.$root.mk.api.v3.music(`v1/me/library/playlist-folders/${item.id}/children`).then(data => {
|
||||
let children = data.data.data;
|
||||
children.forEach(child => {
|
||||
if(!self.$root.playlists.listing.find(listing => listing.id == child.id)) {
|
||||
child.parent = self.item.id
|
||||
|
|
|
@ -40,16 +40,8 @@
|
|||
async getArtistFeed() {
|
||||
let artists = this.followedArtists
|
||||
let self = this
|
||||
this.app.mk.api.artists(artists, {
|
||||
"views": "featured-release,full-albums,appears-on-albums,featured-albums,featured-on-albums,singles,compilation-albums,live-albums,latest-release,top-music-videos,similar-artists,top-songs,playlists,more-to-hear,more-to-see",
|
||||
"extend": "artistBio,bornOrFormed,editorialArtwork,editorialVideo,isGroup,origin,hero",
|
||||
"extend[playlists]": "trackCount",
|
||||
"include[songs]": "albums",
|
||||
"fields[albums]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,editorialVideo,name,playParams,releaseDate,url,trackCount",
|
||||
"limit[artists:top-songs]": 20,
|
||||
"art[url]": "f"
|
||||
}, {includeResponseMeta: !0}).then(artistData => {
|
||||
artistData.data.forEach(item => {
|
||||
this.app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists?ids=${artists.toString()}&views=featured-release,full-albums,appears-on-albums,featured-albums,featured-on-albums,singles,compilation-albums,live-albums,latest-release,top-music-videos,similar-artists,top-songs,playlists,more-to-hear,more-to-see&extend=artistBio,bornOrFormed,editorialArtwork,editorialVideo,isGroup,origin,hero&extend[playlists]=trackCount&include[songs]=albums&fields[albums]=artistName,artistUrl,artwork,contentRating,editorialArtwork,editorialVideo,name,playParams,releaseDate,url,trackCount&limit[artists:top-songs]=20&art[url]=f`).then(artistData => {
|
||||
artistData.data.data.forEach(item => {
|
||||
if (item.views["latest-release"].data.length != 0) {
|
||||
self.artistFeed.push(item.views["latest-release"].data[0])
|
||||
}
|
||||
|
|
|
@ -171,8 +171,8 @@
|
|||
let friends = badges[id]
|
||||
if (friends) {
|
||||
friends.forEach(function (friend) {
|
||||
self.app.mk.api.socialProfile(friend).then(data => {
|
||||
self.itemBadges.push(data)
|
||||
self.app.mk.api.v3.music(`/v1/social/${app.mk.storefrontId}/social-profiles/${friend}`).then(data => {
|
||||
self.itemBadges.push(data.data.data[0])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -205,7 +205,7 @@
|
|||
"relate": "library"
|
||||
};
|
||||
const res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, this.data.attributes.playParams.isLibrary ?? false, this.data.attributes.playParams.id ?? this.data.id, params);
|
||||
this.inLibrary = (res && res.attributes && res.attributes.inLibrary) ? res.attributes.inLibrary : false
|
||||
this.inLibrary = (res.data.data[0] && res.data.data[0].attributes && res.data.data[0].attributes.inLibrary) ? res.data.data[0].attributes.inLibrary : false
|
||||
console.log(res)
|
||||
} else {
|
||||
this.inLibrary = true
|
||||
|
@ -229,12 +229,16 @@
|
|||
const params = {"fields[somgs]": "inLibrary", "fields[albums]": "inLibrary", "relate": "library"};
|
||||
var id = this.data.id ?? this.data.attributes.playParams.id
|
||||
const res = await app.mkapi(this.data.attributes.playParams.kind ?? this.data.type, this.data.attributes.playParams.isLibrary ?? false, this.data.attributes.playParams.id ?? this.data.id, params);
|
||||
if (res && res.relationships && res.relationships.library && res.relationships.library.data && res.relationships.library.data.length > 0) {
|
||||
id = res.relationships.library.data[0].id
|
||||
if (res.data.data[0] && res.data.data[0].relationships && res.data.data[0].relationships.library && res.data.data[0].relationships.library.data && res.data.data[0].relationships.library.data.length > 0) {
|
||||
id = res.data.data[0].relationships.library.data[0].id
|
||||
}
|
||||
let kind = this.data.attributes.playParams.kind ?? this.data.type ?? '';
|
||||
const truekind = (!kind.endsWith("s")) ? (kind + "s") : kind;
|
||||
app.mk.api.library.remove({[truekind]: id})
|
||||
app.mk.api.v3.music(`v1/me/library/${truekind}/${id.toString()}`,{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "DELETE"
|
||||
}})
|
||||
this.inLibrary = false
|
||||
this.confirm = false
|
||||
},
|
||||
|
@ -274,7 +278,19 @@
|
|||
if (!this.data.attributes.canEdit) {
|
||||
return
|
||||
}
|
||||
await app.mk.api.library.putPlaylistTracklisting(this.data.attributes.playParams.id, this.convert())
|
||||
console.log('sds',this.convert())
|
||||
await app.mk.api.v3.music(
|
||||
`/v1/me/library/playlists/${this.data.attributes.playParams.id}/tracks`,
|
||||
{},
|
||||
{
|
||||
fetchOptions: {
|
||||
method: "PUT",
|
||||
body: JSON.stringify({
|
||||
data: this.convert()
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
async remove() {
|
||||
if (!this.data.attributes.canEdit) {
|
||||
|
|
|
@ -131,32 +131,22 @@
|
|||
playlists.push(item.id)
|
||||
}
|
||||
}
|
||||
if (playlists.length != 0) {
|
||||
this.app.mk.api.playlists(playlists).then(playlistsData => {
|
||||
self.favorites.push(...playlistsData)
|
||||
if (playlists.length != 0) {
|
||||
this.app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/playlists/${playlists.toString()}`).then(playlistsData => {
|
||||
self.favorites.push(...playlistsData.data)
|
||||
})
|
||||
}
|
||||
if (libraryPlaylists.length != 0) {
|
||||
this.app.mk.api.library.playlists(libraryPlaylists).then(playlistsData => {
|
||||
self.favorites.push(...playlistsData)
|
||||
if (libraryPlaylists.length != 0) {
|
||||
this.app.mk.api.v3.music(`v1/me/library/playlists/${playlists.toString()}`).then(playlistsData => {
|
||||
self.favorites.push(...playlistsData.data)
|
||||
})
|
||||
}
|
||||
},
|
||||
async getArtistFeed() {
|
||||
let artists = this.followedArtists
|
||||
let self = this
|
||||
this.app.mk.api.artists(artists, {
|
||||
"views": "featured-release,full-albums,appears-on-albums,featured-albums,featured-on-albums,singles,compilation-albums,live-albums,latest-release,top-music-videos,similar-artists,top-songs,playlists,more-to-hear,more-to-see",
|
||||
"extend": "artistBio,bornOrFormed,editorialArtwork,editorialVideo,isGroup,origin,hero",
|
||||
"extend[playlists]": "trackCount",
|
||||
"include[songs]": "albums",
|
||||
"fields[albums]": "artistName,artistUrl,artwork,contentRating,editorialArtwork,editorialVideo,name,playParams,releaseDate,url,trackCount",
|
||||
"limit[artists:top-songs]": 20,
|
||||
"art[url]": "f"
|
||||
}, {
|
||||
includeResponseMeta: !0
|
||||
}).then(artistData => {
|
||||
artistData.data.forEach(item => {
|
||||
this.app.mk.api.v3.music(`/v1/catalog/${app.mk.storefrontId}/artists?ids=${artists.toString()}&views=featured-release,full-albums,appears-on-albums,featured-albums,featured-on-albums,singles,compilation-albums,live-albums,latest-release,top-music-videos,similar-artists,top-songs,playlists,more-to-hear,more-to-see&extend=artistBio,bornOrFormed,editorialArtwork,editorialVideo,isGroup,origin,hero&extend[playlists]=trackCount&include[songs]=albums&fields[albums]=artistName,artistUrl,artwork,contentRating,editorialArtwork,editorialVideo,name,playParams,releaseDate,url,trackCount&limit[artists:top-songs]=20&art[url]=f`).then(artistData => {
|
||||
artistData.data.data.forEach(item => {
|
||||
if (item.views["latest-release"].data.length != 0) {
|
||||
self.artistFeed.push(item.views["latest-release"].data[0])
|
||||
}
|
||||
|
@ -176,35 +166,10 @@
|
|||
},
|
||||
async getListenNowData() {
|
||||
let self = this
|
||||
this.app.mk.api.personalRecommendations("", {
|
||||
name: "listen-now",
|
||||
with: "friendsMix,library,social",
|
||||
"art[social-profiles:url]": "c",
|
||||
"art[url]": "c,f",
|
||||
"omit[resource]": "autos",
|
||||
"relate[editorial-items]": "contents",
|
||||
extend: ["editorialCard", "editorialVideo"],
|
||||
"extend[albums]": ["artistUrl"],
|
||||
"extend[library-albums]": ["artistUrl", "editorialVideo"],
|
||||
"extend[playlists]": ["artistNames", "editorialArtwork", "editorialVideo"],
|
||||
"extend[library-playlists]": ["artistNames", "editorialArtwork", "editorialVideo"],
|
||||
"extend[social-profiles]": "topGenreNames",
|
||||
"include[albums]": "artists",
|
||||
"include[songs]": "artists",
|
||||
"include[music-videos]": "artists",
|
||||
"fields[albums]": ["artistName", "artistUrl", "artwork", "contentRating", "editorialArtwork", "editorialVideo", "name", "playParams", "releaseDate", "url"],
|
||||
"fields[artists]": ["name", "url"],
|
||||
"extend[stations]": ["airDate", "supportsAirTimeUpdates"],
|
||||
"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-profiles,social-upsells",
|
||||
platform: "web"
|
||||
}, {
|
||||
includeResponseMeta: !0,
|
||||
reload: !0
|
||||
}).then((data) => {
|
||||
console.log(data.data[1])
|
||||
this.app.mk.api.v3.music(`/v1/me/recommendations?timezone=${encodeURIComponent(app.formatTimezoneOffset())}&name=listen-now&with=friendsMix,library,social&art[social-profiles:url]=c&art[url]=c,f&omit[resource]=autos&relate[editorial-items]=contents&extend=editorialCard,editorialVideo&extend[albums]=artistUrl&extend[library-albums]=artistUrl,editorialVideo&extend[playlists]=artistNames,editorialArtwork,editorialVideo&extend[library-playlists]=artistNames,editorialArtwork,editorialVideo&extend[social-profiles]=topGenreNames&include[albums]=artists&include[songs]=artists&include[music-videos]=artists&fields[albums]=artistName,artistUrl,artwork,contentRating,editorialArtwork,editorialVideo,name,playParams,releaseDate,url&fields[artists]=name,url&extend[stations]=airDate,supportsAirTimeUpdates&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&platform=web`).then((data) => {
|
||||
console.log(data.data.data[1])
|
||||
try {
|
||||
self.madeForYou = data.data.filter(section => {
|
||||
self.madeForYou = data.data.data.filter(section => {
|
||||
if (section.meta.metrics.moduleType == "6") {
|
||||
return section
|
||||
};
|
||||
|
@ -213,8 +178,8 @@
|
|||
self.sectionsReady.push("madeForYou")
|
||||
|
||||
try {
|
||||
self.recentlyPlayed = data.data[1].relationships.contents.data
|
||||
self.friendsListeningTo = data.data.filter(section => {
|
||||
self.recentlyPlayed = data.data.data[1].relationships.contents.data
|
||||
self.friendsListeningTo = data.data.data.filter(section => {
|
||||
if (section.meta.metrics.moduleType == "11") {
|
||||
return section
|
||||
};
|
||||
|
@ -228,7 +193,7 @@
|
|||
self.profile = response.data.data[0]
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -1,82 +1,97 @@
|
|||
<script type="text/x-template" id="cider-search">
|
||||
<div class="content-inner">
|
||||
<div class="row">
|
||||
<div class="col-sm" style="width: auto;" v-if="getTopResult()">
|
||||
<template>
|
||||
<h3>Top Result</h3>
|
||||
<mediaitem-square :item="getTopResult()"></mediaitem-square>
|
||||
</template>
|
||||
</div>
|
||||
<div class="col" v-if="search.results.song">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>Songs</h3>
|
||||
<div v-if="search != null && search != [] && search.term != ''">
|
||||
<div class="row">
|
||||
<div class="col-sm" style="width: auto;" v-if="getTopResult()">
|
||||
<template>
|
||||
<h3>Top Result</h3>
|
||||
<mediaitem-square :item="getTopResult()"></mediaitem-square>
|
||||
</template>
|
||||
</div>
|
||||
<div class="col" v-if="search.results.song">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>Songs</h3>
|
||||
</div>
|
||||
<div class="col-auto flex-center"
|
||||
@click="app.showSearchView(app.search.term, 'song', app.friendlyTypes('song'))"
|
||||
v-if="search.results.song.data.length >= 6">
|
||||
<button class="cd-btn-seeall">See All</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto flex-center"
|
||||
@click="app.showSearchView(app.search.term, 'song', app.friendlyTypes('song'))"
|
||||
v-if="search.results.song.data.length >= 6">
|
||||
<button class="cd-btn-seeall">See All</button>
|
||||
<div>
|
||||
<mediaitem-list-item :item="item" :index="index"
|
||||
v-for="(item, index) in search.results.song.data.limit(6)"></mediaitem-list-item>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<mediaitem-list-item :item="item" :index="index"
|
||||
v-for="(item, index) in search.results.song.data.limit(6)"></mediaitem-list-item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="search.results['meta']">
|
||||
<template
|
||||
v-for="section in search.results.meta.results.order" v-if="section != 'song' && section != 'top'">
|
||||
<template v-if="search.results['meta'] != null">
|
||||
<template
|
||||
v-for="section in search.results.meta.results.order" v-if="section != 'song' && section != 'top'">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ app.friendlyTypes(section) }}</h3>
|
||||
</div>
|
||||
<div class="col-auto flex-center" v-if="search.results[section].data.length >= 10">
|
||||
<button class="cd-btn-seeall"
|
||||
@click="app.showSearchView(app.search.term, section, app.friendlyTypes(section))">See
|
||||
All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="!app.friendlyTypes(section).includes('Video')">
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.results[section].data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
<template v-else>
|
||||
<mediaitem-scroller-horizontal-mvview
|
||||
:items="search.results[section].data.limit(10)"></mediaitem-scroller-horizontal-mvview>
|
||||
</template>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="search.resultsSocial.playlist">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ app.friendlyTypes(section) }}</h3>
|
||||
<h3>Shared Playlists</h3>
|
||||
</div>
|
||||
<div class="col-auto flex-center" v-if="search.results[section].data.length >= 10">
|
||||
<div class="col-auto flex-center" v-if="search.resultsSocial.playlist.data.length >= 10">
|
||||
<button class="cd-btn-seeall"
|
||||
@click="app.showSearchView(app.search.term, section, app.friendlyTypes(section))">See
|
||||
All
|
||||
@click="app.showCollection(search.resultsSocial.playlist, 'Shared Playlists', 'default')">See All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="!app.friendlyTypes(section).includes('Video')">
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.results[section].data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
<template v-else>
|
||||
<mediaitem-scroller-horizontal-mvview
|
||||
:items="search.results[section].data.limit(10)"></mediaitem-scroller-horizontal-mvview>
|
||||
</template>
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.resultsSocial.playlist.data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="search.resultsSocial.playlist">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>Shared Playlists</h3>
|
||||
<template v-if="search.resultsSocial.profile">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>People</h3>
|
||||
</div>
|
||||
<div class="col-auto flex-center" v-if="search.resultsSocial.profile.data.length >= 10">
|
||||
<button class="cd-btn-seeall"
|
||||
@click="app.showCollection(search.resultsSocial.profile, 'People', 'default')">See All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto flex-center" v-if="search.resultsSocial.playlist.data.data.length >= 10">
|
||||
<button class="cd-btn-seeall"
|
||||
@click="app.showCollection(search.resultsSocial.playlist.data, 'Shared Playlists', 'default')">See All
|
||||
</button>
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.resultsSocial.profile.data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div v-if="categoriesReady || getCategories()">
|
||||
<div>
|
||||
<div class="col" v-if="categoriesView != null && categoriesView != [] && categoriesView[0].attributes != null && categoriesView[0].attributes.title != null">
|
||||
<h3>{{categoriesView[0].attributes.title.stringForDisplay ?? ""}}</h3>
|
||||
</div>
|
||||
<mediaitem-square :kind="'385'" size="600"
|
||||
:item="item ? (item.attributes.kind ? item : ((item.relationships && item.relationships.contents ) ? item.relationships.contents.data[0] : item)) : []"
|
||||
:imagesize="800"
|
||||
v-for="item in categoriesView[1].relationships.contents.data.filter(item => item.type != 'editorial-items')">
|
||||
</div>
|
||||
</div>
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.resultsSocial.playlist.data.data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
<template v-if="search.resultsSocial.profile">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>People</h3>
|
||||
</div>
|
||||
<div class="col-auto flex-center" v-if="search.resultsSocial.profile.data.data.length >= 10">
|
||||
<button class="cd-btn-seeall"
|
||||
@click="app.showCollection(search.resultsSocial.profile.data, 'People', 'default')">See All
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<mediaitem-scroller-horizontal-large
|
||||
:items="search.resultsSocial.profile.data.data.limit(10)"></mediaitem-scroller-horizontal-large>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -86,8 +101,10 @@
|
|||
props: ['search'],
|
||||
data: function () {
|
||||
return {
|
||||
app: this.$root
|
||||
}
|
||||
app: this.$root,
|
||||
categoriesView : [],
|
||||
categoriesReady : false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getTopResult() {
|
||||
|
@ -96,6 +113,13 @@
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async getCategories() {
|
||||
if(this.categoriesView != [] && this.categoriesView.length > 0) {this.categoriesReady = true; return await true;} else {
|
||||
let response = await this.app.mk.api.v3.music(`/v1/recommendations/${this.app.mk.storefrontId}?timezone=${encodeURIComponent(this.app.formatTimezoneOffset())}&name=search-landing&platform=web&extend=editorialArtwork&art%5Burl%5D=f%2Cc&types=editorial-items%2Capple-curators%2Cactivities`);
|
||||
this.categoriesView = response.data.data;
|
||||
this.categoriesReady = true;
|
||||
return await true;}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue