From 0921ef80bff3f8a252dac39c4f9acad252a09a72 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Sat, 7 May 2022 06:48:42 +0100 Subject: [PATCH 1/6] plsplsplspls --- src/renderer/main/vueapp.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index a99b0b44..e31f4241 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -2541,29 +2541,23 @@ const app = new Vue({ return } try { - this.radio.personal.title = app.getLz('term.personal') + 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`, { + this.radio.personal.data = await 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 - }) + }).data.data - app.mk.api.v3.music(`/v1/me/recent/radio-stations`, { + this.radio.recent.data = await app.mk.api.v3.music(`/v1/me/recent/radio-stations`, { "platform": "web", "art[url]": "f", l: this.mklang - }).then(res => { - this.radio.recent.data = res.data.data - }) + }).data.data - app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, { + this.radio.amlive.data = await 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 - }) + }).data.data this.radio.timestamp = Date.now() console.debug(this.radio) From b6cd18be126a74680849f72c0c900b0a41f3b578 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Sat, 7 May 2022 06:50:07 +0100 Subject: [PATCH 2/6] Revert "Revert "Radio improvement, needs optimisation."" This reverts commit baf234085e0edfaa8f69c1d88eaae15fbdcba231. --- src/i18n/README.md | 4 ++- src/i18n/en_US.json | 2 ++ src/i18n/source/en_US.json | 2 ++ src/main/base/browserwindow.ts | 7 ++++ src/renderer/main/vueapp.js | 33 +++++++++++++++++-- src/renderer/views/app/app-content.ejs | 9 ----- src/renderer/views/app/sidebar.ejs | 4 +-- src/renderer/views/components/radio-child.ejs | 31 +++++++++++++++++ src/renderer/views/pages/radio.ejs | 23 +++++++++++++ 9 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 src/renderer/views/components/radio-child.ejs diff --git a/src/i18n/README.md b/src/i18n/README.md index 3422daa7..c43468ec 100644 --- a/src/i18n/README.md +++ b/src/i18n/README.md @@ -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` diff --git a/src/i18n/en_US.json b/src/i18n/en_US.json index 8f1b77dc..9536fb79 100644 --- a/src/i18n/en_US.json +++ b/src/i18n/en_US.json @@ -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.", diff --git a/src/i18n/source/en_US.json b/src/i18n/source/en_US.json index c76a5c01..5d91201c 100644 --- a/src/i18n/source/en_US.json +++ b/src/i18n/source/en_US.json @@ -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.", diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index 99300827..680f176d 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -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: ``, condition: `page == 'listen_now'`, onEnter: `` + }, { + page: "radio", + component: ``, + condition: `page == 'radio'`, + onEnter: `` }, { page: "settings", component: ``, diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 8218881d..f0e271bb 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -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) diff --git a/src/renderer/views/app/app-content.ejs b/src/renderer/views/app/app-content.ejs index dfa1cb33..1134fe9f 100644 --- a/src/renderer/views/app/app-content.ejs +++ b/src/renderer/views/app/app-content.ejs @@ -25,15 +25,6 @@ <% } %> - - - - {{$root.getLz('term.radio')}} - {{$root.getLz('term.recentStations')}} - - - - <%- include('../pages/library-recentlyadded') %>'); diff --git a/src/renderer/views/app/sidebar.ejs b/src/renderer/views/app/sidebar.ejs index 979db2f5..ead0d4aa 100644 --- a/src/renderer/views/app/sidebar.ejs +++ b/src/renderer/views/app/sidebar.ejs @@ -39,8 +39,8 @@ - - + + + + + {{ item.title }} + + + + + + + + + + \ No newline at end of file diff --git a/src/renderer/views/pages/radio.ejs b/src/renderer/views/pages/radio.ejs index e69de29b..f993f117 100644 --- a/src/renderer/views/pages/radio.ejs +++ b/src/renderer/views/pages/radio.ejs @@ -0,0 +1,23 @@ + + + \ No newline at end of file From b8fef4f8f760bdfb29ff2e65949fa6c9ba2991b0 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Sat, 7 May 2022 06:54:23 +0100 Subject: [PATCH 3/6] Does this make a difference --- src/renderer/main/vueapp.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index f0e271bb..41f48bf3 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -2543,28 +2543,21 @@ const app = new Vue({ } try { 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`, { + this.radio.personal.data = await 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 - }) + }).data.data - app.mk.api.v3.music(`/v1/me/recent/radio-stations`, { + 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 - }).then(res => { - this.radio.recent.data = res.data.data - }) + }).data.data - app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, { + 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", - }).then(res => { - this.radio.amlive.data = res.data.data - }) + }).data.data this.radio.timestamp = Date.now() console.debug(this.radio) From 35438b9d1e6e4a83eeccadd8f1fc97d7b232d1cb Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Sat, 7 May 2022 07:02:16 +0100 Subject: [PATCH 4/6] Added test command, tried something else --- package.json | 1 + src/renderer/main/vueapp.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 9c22e95d..88d55166 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dist:macarm": "yarn build && electron-builder --mac --arm64", "dist:universalNotWorking": "yarn build && electron-builder --mac --universal", "dist:all": "yarn build && electron-builder -mwl", + "testdist": "yarn build && electron-builder --dir", "winget": "yarn build && electron-builder --win -c winget.json", "msft": "yarn build && electron-builder -c msft-package.json", "mstest": "yarn build && electron-builder -c msft-test.json", diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 41f48bf3..9b89f8d2 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -2543,21 +2543,21 @@ const app = new Vue({ } 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`, { + this.radio.personal.data = (await app.mk.api.v3.music(`/v1/catalog/${app.mk.api.v3.storefrontId}/stations`, { "filter[identity]": "personal", - }).data.data + })).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`, { + 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 + })).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`, { + 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 + })).data.data this.radio.timestamp = Date.now() console.debug(this.radio) From d2a7698d49a2ff90c736b9978d0e76a420966baa Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Thu, 12 May 2022 19:32:27 +0100 Subject: [PATCH 5/6] Fixed all the stupid shit --- src/renderer/main/vueapp.js | 32 ------------ src/renderer/views/pages/radio.ejs | 82 +++++++++++++++++++++++++++--- 2 files changed, 75 insertions(+), 39 deletions(-) diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 9b89f8d2..165c2db1 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -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 diff --git a/src/renderer/views/pages/radio.ejs b/src/renderer/views/pages/radio.ejs index f993f117..10d42caa 100644 --- a/src/renderer/views/pages/radio.ejs +++ b/src/renderer/views/pages/radio.ejs @@ -1,9 +1,28 @@ @@ -13,11 +32,60 @@ props: ["data"], data: function () { return { - app: this.$root + app: this.$root, + radio: {personal: [], recent: [], am: []} } }, - mounted() { - this.$root.getRadioStations() + 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) + } + }, } }) \ No newline at end of file From 7d223ad2810e408ec770db815c10033cc0ce1c56 Mon Sep 17 00:00:00 2001 From: Core <64542347+coredev-uk@users.noreply.github.com> Date: Wed, 25 May 2022 03:10:04 +0100 Subject: [PATCH 6/6] remove unused code --- src/main/base/browserwindow.ts | 1 - src/renderer/views/components/radio-child.ejs | 31 ------------------- 2 files changed, 32 deletions(-) delete mode 100644 src/renderer/views/components/radio-child.ejs diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts index ccda44e7..8649ce97 100644 --- a/src/main/base/browserwindow.ts +++ b/src/main/base/browserwindow.ts @@ -115,7 +115,6 @@ export class BrowserWindow { "components/artist-chip", "components/hello-world", "components/inline-collection-list", - "components/radio-child", ], appRoutes: [ { diff --git a/src/renderer/views/components/radio-child.ejs b/src/renderer/views/components/radio-child.ejs deleted file mode 100644 index 3fa7d9b0..00000000 --- a/src/renderer/views/components/radio-child.ejs +++ /dev/null @@ -1,31 +0,0 @@ - - \ No newline at end of file