initial
This commit is contained in:
parent
3b46a623cd
commit
d7dd447e7a
2 changed files with 66 additions and 80 deletions
|
@ -46,9 +46,8 @@ const app = new Vue({
|
||||||
listennow: [],
|
listennow: [],
|
||||||
madeforyou: [],
|
madeforyou: [],
|
||||||
radio: {
|
radio: {
|
||||||
personal: {},
|
"editorial": [],
|
||||||
recent: {},
|
"recent": [],
|
||||||
amlive: {},
|
|
||||||
},
|
},
|
||||||
mklang: "en",
|
mklang: "en",
|
||||||
webview: {
|
webview: {
|
||||||
|
@ -783,6 +782,9 @@ const app = new Vue({
|
||||||
this.mk.volume = -1;
|
this.mk.volume = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore mk
|
||||||
|
|
||||||
|
|
||||||
// load cached library
|
// load cached library
|
||||||
let librarySongs = await CiderCache.getCache("library-songs");
|
let librarySongs = await CiderCache.getCache("library-songs");
|
||||||
let libraryAlbums = await CiderCache.getCache("library-albums");
|
let libraryAlbums = await CiderCache.getCache("library-albums");
|
||||||
|
@ -3002,6 +3004,48 @@ const app = new Vue({
|
||||||
this.getListenNow(attempt + 1);
|
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) {
|
async getBrowsePage(attempt = 0) {
|
||||||
if (this.browsepage.timestamp > Date.now() - 120000) {
|
if (this.browsepage.timestamp > Date.now() - 120000) {
|
||||||
return;
|
return;
|
||||||
|
@ -3020,7 +3064,7 @@ const app = new Vue({
|
||||||
extend: "editorialArtwork,artistUrl",
|
extend: "editorialArtwork,artistUrl",
|
||||||
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
|
"fields[artists]": "name,url,artwork,editorialArtwork,genreNames,editorialNotes",
|
||||||
"art[url]": "f",
|
"art[url]": "f",
|
||||||
l: this.mklang,
|
l: app.mklang,
|
||||||
});
|
});
|
||||||
this.browsepage = browse.data.data[0];
|
this.browsepage = browse.data.data[0];
|
||||||
this.browsepage.timestamp = Date.now();
|
this.browsepage.timestamp = Date.now();
|
||||||
|
|
|
@ -1,28 +1,18 @@
|
||||||
<script type="text/x-template" id="cider-radio">
|
<script type="text/x-template" id="cider-radio">
|
||||||
<div class="content-inner">
|
<div class="content-inner">
|
||||||
<h1 class="header-text">{{ app.getLz('term.radio') }}</h1>
|
<h1 class="header-text">{{$root.getLz("term.radio")}}</h1>
|
||||||
|
<template v-if="data.editorial">
|
||||||
|
<template v-for="(recom,index) in data.editorial[4]">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<mediaitem-scroller-horizontal-mvview :imagesize="800"
|
||||||
<h3>{{ app.getLz('term.personalStations') }}</h3>
|
:browsesp="index == 0"
|
||||||
|
:kind="recom.attributes.editorialElementKind"
|
||||||
|
:items="recom.relationships.children ? recom.relationships.children.data.limit(10) : recom.relationships.contents.data.limit(10)"></mediaitem-scroller-horizontal-mvview>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
<!-- <mediaitem-square :kind="'385'" size="600"-->
|
</template>
|
||||||
<!-- :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>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -33,59 +23,11 @@
|
||||||
data: function() {
|
data: function() {
|
||||||
return {
|
return {
|
||||||
app: this.$root,
|
app: this.$root,
|
||||||
radio: { personal: [], recent: [], am: [] }
|
};
|
||||||
}
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
mounted() {
|
||||||
this.radio.personal = await this.getPersonalStations()
|
this.$root.getRadioPage();
|
||||||
this.radio.recent = await this.getRecentStations()
|
|
||||||
this.radio.am = await this.getAmStations()
|
|
||||||
console.log(this.radio)
|
|
||||||
// this.getPersonalStations();
|
|
||||||
// this.getAmStations();
|
|
||||||
},
|
},
|
||||||
methods: {
|
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)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue