This commit is contained in:
Core 2022-09-13 19:35:03 +01:00
parent 3b46a623cd
commit d7dd447e7a
No known key found for this signature in database
GPG key ID: 2AB8327FBA02D1C0
2 changed files with 66 additions and 80 deletions

View file

@ -46,9 +46,8 @@ const app = new Vue({
listennow: [],
madeforyou: [],
radio: {
personal: {},
recent: {},
amlive: {},
"editorial": [],
"recent": [],
},
mklang: "en",
webview: {
@ -783,6 +782,9 @@ const app = new Vue({
this.mk.volume = -1;
}
// Restore mk
// load cached library
let librarySongs = await CiderCache.getCache("library-songs");
let libraryAlbums = await CiderCache.getCache("library-albums");
@ -3002,6 +3004,48 @@ const app = new Vue({
this.getListenNow(attempt + 1);
}
},
async getRadioPage(attempt = 0) {
if (this.radio.timestamp > Date.now() - 120000) {
return;
}
if (attempt > 3) {
return;
}
try {
app.mk.api.v3.music(`/v1/editorial/${app.mk.storefrontId}/groupings`, {
platform: "web",
name: "radio",
"omit[resource:artists]": "relationships",
"include[albums]": "artists",
"include[music-videos]": "artists",
"include[songs]": "artists",
"include[stations]": "events",
extend: "artistUrl,editorialArtwork",
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
"format[resources]": "map",
"art[url]": "f",
l: app.mklang
}).then((radio) => {
app.radio.editorial = radio.data.resources
console.debug(app.radio);
})
app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
"platform": "web",
"art[url]": "f",
"format[resources]": "map",
l: app.mklang
}).then((radio) => {
app.radio.recent = radio.data
console.debug(app.radio);
})
this.radio.timestamp = Date.now();
} catch (e) {
console.log(e);
this.getRadioPage(attempt + 1);
}
},
async getBrowsePage(attempt = 0) {
if (this.browsepage.timestamp > Date.now() - 120000) {
return;
@ -3020,7 +3064,7 @@ const app = new Vue({
extend: "editorialArtwork,artistUrl",
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
"art[url]": "f",
l: this.mklang,
l: app.mklang,
});
this.browsepage = browse.data.data[0];
this.browsepage.timestamp = Date.now();