Fixed all the stupid shit
This commit is contained in:
parent
35438b9d1e
commit
d2a7698d49
2 changed files with 75 additions and 39 deletions
|
@ -2534,38 +2534,6 @@ const app = new Vue({
|
|||
this.getBrowsePage(attempt + 1)
|
||||
}
|
||||
},
|
||||
async getRadioStations(attempt = 0) {
|
||||
if (this.radio.timestamp > Date.now() - 120000) {
|
||||
return
|
||||
}
|
||||
if (attempt > 3) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
this.radio.personal.title = app.getLz('term.personalStations')
|
||||
this.radio.personal.data = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[identity]": "personal",
|
||||
})).data.data
|
||||
|
||||
this.radio.recent.title = app.getLz('term.recentStations')
|
||||
this.radio.recent.data = (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
|
||||
"platform": "web",
|
||||
"art[url]": "f",
|
||||
l: this.mklang
|
||||
})).data.data
|
||||
|
||||
this.radio.amlive.title = app.getLz('term.amLive')
|
||||
this.radio.amlive.data = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[featured]": "apple-music-live-radio",
|
||||
})).data.data
|
||||
|
||||
this.radio.timestamp = Date.now()
|
||||
console.debug(this.radio)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
this.getRadioStations(attempt + 1)
|
||||
}
|
||||
},
|
||||
async getMadeForYou(attempt = 0) {
|
||||
if (attempt > 3) {
|
||||
return
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
<script type="text/x-template" id="cider-radio">
|
||||
<div class="content-inner">
|
||||
<h1 class="header-text">{{ app.getLz('term.radio') }}</h1>
|
||||
<template v-for="item in data">
|
||||
<radio-child :item="item"></radio-child>
|
||||
</template>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ app.getLz('term.personalStations') }}</h3>
|
||||
</div>
|
||||
</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 of getFlattenedCategories()">-->
|
||||
<mediaitem-square :item="item" v-for="item in radio.personal"></mediaitem-square>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ app.getLz('term.recentStations') }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<mediaitem-square :item="station" v-for="station in radio.recent"></mediaitem-square>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h3>{{ app.getLz('term.amLive') }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<mediaitem-square :item="station" v-for="station in radio.am"></mediaitem-square>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
|
@ -13,11 +32,60 @@
|
|||
props: ["data"],
|
||||
data: function () {
|
||||
return {
|
||||
app: this.$root
|
||||
app: this.$root,
|
||||
radio: {personal: [], recent: [], am: []}
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
this.radio.personal = await this.getPersonalStations()
|
||||
this.radio.recent = await this.getRecentStations()
|
||||
this.radio.am = await this.getAmStations()
|
||||
console.log(this.radio)
|
||||
// this.getPersonalStations();
|
||||
// this.getAmStations();
|
||||
},
|
||||
methods: {
|
||||
async getPersonalStations(attempts = 0) {
|
||||
if (attempts > 3) {
|
||||
return []
|
||||
}
|
||||
try {
|
||||
return (await app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[identity]": "personal",
|
||||
})).data.data
|
||||
} catch (e) {
|
||||
console.error(`Failed to get personal stations: ${e}`)
|
||||
await this.getPersonalStations(attempts + 1)
|
||||
}
|
||||
},
|
||||
async getRecentStations(attempts = 0) {
|
||||
if (attempts > 3) {
|
||||
return []
|
||||
}
|
||||
try {
|
||||
return (await app.mk.api.v3.music(`/v1/me/recent/radio-stations`, {
|
||||
"platform": "web",
|
||||
"art[url]": "f",
|
||||
l: app.mklang
|
||||
})).data.data
|
||||
} catch (e) {
|
||||
console.error(`Failed to get recent stations: ${e}`)
|
||||
await this.getRecentStations(attempts + 1)
|
||||
}
|
||||
},
|
||||
async getAmStations(attempt = 0) {
|
||||
if (attempt > 3) {
|
||||
return []
|
||||
}
|
||||
try {
|
||||
return (await app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, {
|
||||
"filter[featured]": "apple-music-live-radio",
|
||||
})).data.data
|
||||
} catch (e) {
|
||||
console.error(`Failed to get AM stations: ${e}`)
|
||||
await this.getAmStations(attempt + 1)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$root.getRadioStations()
|
||||
}
|
||||
})
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue