Radio improvement, needs optimisation.
This commit is contained in:
parent
a79a96b946
commit
c0c12bc2ba
9 changed files with 100 additions and 15 deletions
|
@ -42,7 +42,9 @@ const app = new Vue({
|
|||
listennow: [],
|
||||
madeforyou: [],
|
||||
radio: {
|
||||
personal: []
|
||||
personal: {},
|
||||
recent: {},
|
||||
amlive: {},
|
||||
},
|
||||
mklang: 'en',
|
||||
webview: {
|
||||
|
@ -321,6 +323,7 @@ const app = new Vue({
|
|||
try {
|
||||
this.listennow.timestamp = 0;
|
||||
this.browsepage.timestamp = 0;
|
||||
this.radio.timestamp = 0;
|
||||
} catch (e) { }
|
||||
},
|
||||
/**
|
||||
|
@ -2531,15 +2534,39 @@ const app = new Vue({
|
|||
}
|
||||
},
|
||||
async getRadioStations(attempt = 0) {
|
||||
if (this.radio.timestamp > Date.now() - 120000) {
|
||||
return
|
||||
}
|
||||
if (attempt > 3) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.radio.personal = (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
|
||||
this.radio.personal.title = app.getLz('term.personal')
|
||||
this.radio.recent.title = app.getLz('term.recentStations')
|
||||
this.radio.amlive.title = app.getLz('term.amLive')
|
||||
|
||||
app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[identity]": "personal",
|
||||
}).then(res => {
|
||||
this.radio.personal.data = res.data.data
|
||||
})
|
||||
|
||||
app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
|
||||
"platform": "web",
|
||||
"art[url]": "f",
|
||||
l: this.mklang
|
||||
})).data.data;
|
||||
}).then(res => {
|
||||
this.radio.recent.data = res.data.data
|
||||
})
|
||||
|
||||
app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[featured]": "apple-music-live-radio",
|
||||
}).then(res => {
|
||||
this.radio.amlive.data = res.data.data
|
||||
})
|
||||
|
||||
this.radio.timestamp = Date.now()
|
||||
console.debug(this.radio)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.getRadioStations(attempt + 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue