Revert "Revert "Radio improvement, needs optimisation.""

This reverts commit baf234085e.
This commit is contained in:
Core 2022-05-07 06:50:07 +01:00
parent a9fc51e1de
commit b6cd18be12
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
9 changed files with 100 additions and 15 deletions

View file

@ -337,4 +337,6 @@ Update 29/04/2022 00:00 UTC
* `menubar.options.license`: Added for `en_US`
* `menubar.options.conf`: Added for `en_US`
Update 07/05/2022 04:00 UTC
* `term.personalStations`: Added for `en_US`
`term.amLive`: Added for `en_US`

View file

@ -121,6 +121,8 @@
"term.audioControls": "Volume Controls",
"term.clearAll": "Clear All",
"term.recentStations": "Recent Stations",
"term.personalStations": "Personal Stations",
"term.amLive": "Apple Music Live",
"term.language": "Language",
"term.funLanguages": "Fun",
"term.noLyrics": "Loading... / Lyrics not found./ Instrumental.",

View file

@ -121,6 +121,8 @@
"term.audioControls": "Volume Controls",
"term.clearAll": "Clear All",
"term.recentStations": "Recent Stations",
"term.personalStations": "Personal Stations",
"term.amLive": "Apple Music Live",
"term.language": "Language",
"term.funLanguages": "Fun",
"term.noLyrics": "Loading... / Lyrics not found./ Instrumental.",

View file

@ -59,6 +59,7 @@ export class BrowserWindow {
"pages/settings",
"pages/installed-themes",
"pages/listen_now",
"pages/radio",
"pages/home",
"pages/artist-feed",
"pages/cider-playlist",
@ -112,6 +113,7 @@ export class BrowserWindow {
"components/artist-chip",
"components/hello-world",
"components/inline-collection-list",
"components/radio-child",
],
appRoutes: [
{
@ -186,6 +188,11 @@ export class BrowserWindow {
component: `<cider-listen-now :data="listennow"></cider-listen-now>`,
condition: `page == 'listen_now'`,
onEnter: ``
}, {
page: "radio",
component: `<cider-radio :data="radio"></cider-radio>`,
condition: `page == 'radio'`,
onEnter: ``
}, {
page: "settings",
component: `<cider-settings></cider-settings>`,

View file

@ -42,7 +42,9 @@ const app = new Vue({
listennow: [],
madeforyou: [],
radio: {
personal: []
personal: {},
recent: {},
amlive: {},
},
mklang: 'en',
webview: {
@ -322,6 +324,7 @@ const app = new Vue({
try {
this.listennow.timestamp = 0;
this.browsepage.timestamp = 0;
this.radio.timestamp = 0;
} catch (e) { }
},
/**
@ -2532,15 +2535,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.personalStations')
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)

View file

@ -25,15 +25,6 @@
</transition>
<% } %>
<transition v-on:enter="getRadioStations()" :name="chrome.desiredPageTransition">
<template v-if="page == 'radio'" @created="console.log('radio')">
<div class="content-inner">
<h1 class="header-text">{{$root.getLz('term.radio')}}</h1>
<h3>{{$root.getLz('term.recentStations')}}</h3>
<mediaitem-square :item="item" v-for="item in radio.personal"></mediaitem-square>
</div>
</template>
</transition>
<!-- Library - Recently Added -->
<transition :name="chrome.desiredPageTransition" v-on:enter="getLibraryAlbumsFull(null, 0); searchLibraryAlbums(0);">
<%- include('../pages/library-recentlyadded') %>');

View file

@ -39,8 +39,8 @@
<sidebar-library-item :name="$root.getLz('term.browse')" svg-icon="./assets/feather/globe.svg"
page="browse">
</sidebar-library-item>
<sidebar-library-item :name="$root.getLz('term.radio')" svg-icon="./assets/feather/radio.svg" page="radio">
</sidebar-library-item>
<sidebar-library-item :name="$root.getLz('term.radio')" svg-icon="./assets/feather/radio.svg"
page="radio"></sidebar-library-item>
</template>
<div class="app-sidebar-header-text"

View file

@ -0,0 +1,31 @@
<script type="text/x-template" id="radio-child">
<div>
<div class="row">
<div class="col">
<h3>{{ item.title }}</h3>
</div>
</div>
<mediaitem-square :item="station" v-for="station in item.data"></mediaitem-square>
<!-- <mediaitem-scroller-horizontal-sp-->
<!-- :withReason="index==0"-->
<!-- :items="recom.relationships.contents.data.limit(10)"></mediaitem-scroller-horizontal-sp>-->
</div>
</script>
<script>
Vue.component('radio-child', {
template: "#radio-child",
props: ["item"],
data: function () {
return {
isVisible: true,
app: this.$root
}
},
methods: {
visibilityChanged: function (isVisible, entry) {
// this.isVisible = isVisible
},
}
})
</script>

View file

@ -0,0 +1,23 @@
<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>
</script>
<script>
Vue.component('cider-radio', {
template: "#cider-radio",
props: ["data"],
data: function () {
return {
app: this.$root
}
},
mounted() {
this.$root.getRadioStations()
}
})
</script>