From 7df1b9ba166d99b73065e6cd674cc1a7994fc6cb Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 17:06:59 -0800
Subject: [PATCH 01/44] Themes in settings will now only display less files
---
src/main/base/browserwindow.ts | 6 +++++-
src/renderer/views/pages/settings.ejs | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts
index 4293e4fc..b5dbecf6 100644
--- a/src/main/base/browserwindow.ts
+++ b/src/main/base/browserwindow.ts
@@ -359,7 +359,11 @@ export class BrowserWindow {
ipcMain.on("get-themes", (event, _key) => {
if (existsSync(utils.getPath("themes"))) {
- event.returnValue = readdirSync(utils.getPath("themes"));
+ let files = readdirSync(utils.getPath("themes"));
+ let themes = files.filter((file) => {
+ return file.endsWith(".less");
+ });
+ event.returnValue = themes;
} else {
event.returnValue = [];
}
diff --git a/src/renderer/views/pages/settings.ejs b/src/renderer/views/pages/settings.ejs
index 8c856a12..29dfab1f 100644
--- a/src/renderer/views/pages/settings.ejs
+++ b/src/renderer/views/pages/settings.ejs
@@ -130,7 +130,7 @@
From 1e2978199e90b70cfca44e5541663fceafd8b2a7 Mon Sep 17 00:00:00 2001
From: vapormusic
Date: Sat, 12 Feb 2022 08:19:58 +0700
Subject: [PATCH 02/44] tmp
---
src/main/plugins/discordrpc.ts | 24 +++++++++++++++++++++---
src/renderer/index.js | 1 +
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/main/plugins/discordrpc.ts b/src/main/plugins/discordrpc.ts
index f30c68c8..31e8d81f 100644
--- a/src/main/plugins/discordrpc.ts
+++ b/src/main/plugins/discordrpc.ts
@@ -1,4 +1,6 @@
import * as RPC from 'discord-rpc'
+import {ipcMain} from "electron";
+import fetch from 'electron-fetch'
export default class DiscordRichPresence {
@@ -6,6 +8,7 @@ export default class DiscordRichPresence {
* Private variables for interaction in plugins
*/
private static _store: any;
+ private _app : any;
private static _connection: boolean = false;
/**
@@ -29,6 +32,7 @@ export default class DiscordRichPresence {
smallImageText: '',
instance: false
};
+
private _activityCache: RPC.Presence = {
details: '',
state: '',
@@ -101,7 +105,7 @@ export default class DiscordRichPresence {
}
// Check large image
- if (activity.largeImageKey === null || activity.largeImageKey === ""){
+ if (activity.largeImageKey == null || activity.largeImageKey === "" || activity.largeImageKey.length > 256) {
activity.largeImageKey = "cider";
}
@@ -169,7 +173,6 @@ export default class DiscordRichPresence {
this._client.setActivity(this._activity)
.catch((e: any) => console.error(`[DiscordRichPresence][setActivity] ${e}`));
}
-
} else if (this._activity && this._activityCache !== this._activity && this._activity.details) {
if (!DiscordRichPresence._store.general.discord_rpc_clear_on_pause) {
this._activity.smallImageKey = 'play';
@@ -190,9 +193,10 @@ export default class DiscordRichPresence {
/**
* Runs on plugin load (Currently run on application start)
*/
- constructor(_app: any, store: any) {
+ constructor(app: any, store: any) {
DiscordRichPresence._store = store
console.debug(`[Plugin][${this.name}] Loading Complete.`);
+ this._app = app;
}
/**
@@ -201,6 +205,20 @@ export default class DiscordRichPresence {
onReady(_win: any): void {
this.connect((DiscordRichPresence._store.general.discord_rpc == 1) ? '911790844204437504' : '886578863147192350');
console.debug(`[Plugin][${this.name}] Ready.`);
+ // ipcMain.on('updateRPCImage', (_event, imageurl) => {
+ // fetch('https://api.cider.sh/v1/images' ,{
+
+ // method: 'POST',
+ // body: JSON.stringify({url : imageurl}),
+ // headers: {
+ // 'Content-Type': 'application/json',
+ // 'User-Agent': 'Cider Development Environment'
+ // },
+ // })
+ // .then(res => res.text())
+ // .then(json => console.log(json))
+
+ // })
}
/**
diff --git a/src/renderer/index.js b/src/renderer/index.js
index 2c91af90..72c9248e 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -3109,6 +3109,7 @@ const app = new Vue({
data = data.data.data[0];
if (data != null && data !== "" && data.attributes != null && data.attributes.artwork != null) {
this.currentArtUrl = (data["attributes"]["artwork"]["url"] ?? '').replace('{w}', 50).replace('{h}', 50);
+ ipcRenderer.send('updateRPCImage', this.currentArtUrl ?? '');
try {
document.querySelector('.app-playback-controls .artwork').style.setProperty('--artwork', `url("${this.currentArtUrl}")`);
} catch (e) {
From d6d93ed3b7f1ee6335649f4e5d314b79950a5ed5 Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 17:21:47 -0800
Subject: [PATCH 03/44] themes can now be in folders and have resources in
those folders
---
src/main/base/browserwindow.ts | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts
index b5dbecf6..49cdf84b 100644
--- a/src/main/base/browserwindow.ts
+++ b/src/main/base/browserwindow.ts
@@ -4,7 +4,7 @@ import * as windowStateKeeper from "electron-window-state";
import * as express from "express";
import * as getPort from "get-port";
import {search} from "youtube-search-without-api-key";
-import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync} from "fs";
+import {existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync} from "fs";
import {Stream} from "stream";
import {networkInterfaces} from "os";
import * as mm from 'music-metadata';
@@ -240,7 +240,20 @@ export class BrowserWindow {
} else {
res.send(`// Theme not found - ${userThemePath}`);
}
+ });
+ app.get("/themes/:theme/:file", (req, res) => {
+ const theme = req.params.theme.toLowerCase();
+ const file = req.params.file;
+ const themePath = join(utils.getPath('srcPath'), "./renderer/themes/", theme);
+ const userThemePath = join(utils.getPath('themes'), theme);
+ if (existsSync(userThemePath)) {
+ res.sendFile(join(userThemePath, file));
+ } else if (existsSync(themePath)) {
+ res.sendFile(join(themePath, file));
+ } else {
+ res.send(`// File not found - ${userThemePath}`);
+ }
});
app.get("/audio.webm", (req, res) => {
@@ -359,10 +372,21 @@ export class BrowserWindow {
ipcMain.on("get-themes", (event, _key) => {
if (existsSync(utils.getPath("themes"))) {
+ // return any .less files and scan any folders in the themes folder for .less files
let files = readdirSync(utils.getPath("themes"));
- let themes = files.filter((file) => {
- return file.endsWith(".less");
- });
+ let themes = [];
+ for (let file of files) {
+ if (file.endsWith(".less")) {
+ themes.push(file);
+ } else if (statSync(join(utils.getPath("themes"), file)).isDirectory()) {
+ let subFiles = readdirSync(join(utils.getPath("themes"), file));
+ for (let subFile of subFiles) {
+ if (subFile.endsWith(".less")) {
+ themes.push(join(file, subFile));
+ }
+ }
+ }
+ }
event.returnValue = themes;
} else {
event.returnValue = [];
From 51534c3640d5e6e887d06d4d4a3bc97945607348 Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 18:16:31 -0800
Subject: [PATCH 04/44] added options to getLz
---
src/i18n/en_US.jsonc | 10 ++++++++++
src/renderer/index.js | 10 +++++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/i18n/en_US.jsonc b/src/i18n/en_US.jsonc
index 220a3352..76216893 100644
--- a/src/i18n/en_US.jsonc
+++ b/src/i18n/en_US.jsonc
@@ -124,6 +124,16 @@
"term.contributors": "Contributors",
"term.equalizer": "Equalizer",
"term.reset": "Reset",
+ "term.track": [
+ {
+ "value": 1,
+ "text": "track"
+ },
+ {
+ "value": 2,
+ "text": "tracks"
+ }
+ ],
"term.tracks": "tracks", // Assume x amount of tracks. e.g. 50 tracks
"term.videos": "Videos",
"term.menu": "Menu",
diff --git a/src/renderer/index.js b/src/renderer/index.js
index 72c9248e..d68e3190 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -322,8 +322,16 @@ const app = new Vue({
this.lz = ipcRenderer.sendSync("get-i18n", lang)
this.mklang = await this.MKJSLang()
},
- getLz(message) {
+ getLz(message, options = {}) {
if (this.lz[message]) {
+ if(options["plural"]) {
+ let closest = this.lz[message].reduce(function(prev, curr) {
+ return (Math.abs(curr.value - options["plural"]) < Math.abs(prev.value - options["plural"]) ? curr : prev);
+ });
+ return closest.text;
+ }else{
+ return this.lz[message][0].text
+ }
return this.lz[message]
} else {
return message
From df24bad697787f4bf3c4fbdb7bc5f94e00df7323 Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 18:17:32 -0800
Subject: [PATCH 05/44] fix
---
src/renderer/index.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/renderer/index.js b/src/renderer/index.js
index d68e3190..6e547824 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -329,8 +329,6 @@ const app = new Vue({
return (Math.abs(curr.value - options["plural"]) < Math.abs(prev.value - options["plural"]) ? curr : prev);
});
return closest.text;
- }else{
- return this.lz[message][0].text
}
return this.lz[message]
} else {
From ceb61e7e14a07ef77fc220287bd87a8299efb529 Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 18:19:57 -0800
Subject: [PATCH 06/44] added fallback if no plural is specified on a plural
object
---
src/renderer/index.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/renderer/index.js b/src/renderer/index.js
index 6e547824..7ed2b57c 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -329,6 +329,8 @@ const app = new Vue({
return (Math.abs(curr.value - options["plural"]) < Math.abs(prev.value - options["plural"]) ? curr : prev);
});
return closest.text;
+ }else if(typeof this.lz[message] === "object") {
+ return this.lz[message][0].text;
}
return this.lz[message]
} else {
From fb65965d82f1a7a778f8f41f05096fffd9a02fae Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 19:05:59 -0800
Subject: [PATCH 07/44] added ipcRenderer.send("get-github-theme", "url")
---
package.json | 5 +++--
src/main/base/browserwindow.ts | 15 +++++++++++++++
src/renderer/index.js | 5 +++++
3 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index f4ed5a4b..e3a751ef 100644
--- a/package.json
+++ b/package.json
@@ -23,8 +23,8 @@
"start:darwin": "yarn build && ELECTRON_ENABLE_LOGGING=true && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers",
"pack": "electron-builder --dir",
"dist": "yarn build && electron-builder",
- "dist:macarm" : "yarn build && electron-builder --mac --arm64",
- "dist:universalNotWorking": "yarn build && electron-builder --mac --universal",
+ "dist:macarm": "yarn build && electron-builder --mac --arm64",
+ "dist:universalNotWorking": "yarn build && electron-builder --mac --universal",
"dist:all": "yarn build && electron-builder -mwl",
"msft": "yarn build && electron-builder -c msft-package.json",
"postinstall": "electron-builder install-app-deps",
@@ -33,6 +33,7 @@
"dependencies": {
"@sentry/electron": "^2.5.4",
"@sentry/integrations": "^6.17.4",
+ "adm-zip": "^0.5.9",
"discord-rpc": "^4.0.1",
"ejs": "^3.1.6",
"electron-fetch": "^1.7.4",
diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts
index 49cdf84b..1f581fb1 100644
--- a/src/main/base/browserwindow.ts
+++ b/src/main/base/browserwindow.ts
@@ -13,6 +13,7 @@ import {wsapi} from "./wsapi";
import {jsonc} from "jsonc";
import {AppImageUpdater, NsisUpdater} from "electron-updater";
import {utils} from './utils';
+const AdmZip = require("adm-zip");
export class BrowserWindow {
@@ -370,6 +371,20 @@ export class BrowserWindow {
event.returnValue = process.platform;
});
+ ipcMain.on("get-github-theme", async (event, url) => {
+ if (url.endsWith("/")) url = url.slice(0, -1);
+ let response = await fetch(
+ `${url}/archive/refs/heads/main.zip`
+ );
+ let zip = await response.buffer();
+ let zipFile = new AdmZip(zip);
+ zipFile.extractAllTo(utils.getPath("themes"), true);
+ BrowserWindow.win.webContents.send("theme-installed", "");
+ event.returnValue = {
+ success: true,
+ };
+ });
+
ipcMain.on("get-themes", (event, _key) => {
if (existsSync(utils.getPath("themes"))) {
// return any .less files and scan any folders in the themes folder for .less files
diff --git a/src/renderer/index.js b/src/renderer/index.js
index 7ed2b57c..ae5bad38 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -693,6 +693,11 @@ const app = new Vue({
console.log(e)
}
+ ipcRenderer.on("theme-installed", (event, arg) => {
+ notyf.success("Theme installed")
+ //app.setTheme(arg)
+ })
+
MusicKit.getInstance().videoContainerElement = document.getElementById("apple-music-video-player")
ipcRenderer.on('SoundCheckTag', (event, tag) => {
From 0aaa40f4e5fe3b232a3071b16e5e92de03ad501a Mon Sep 17 00:00:00 2001
From: booploops <49113086+booploops@users.noreply.github.com>
Date: Fri, 11 Feb 2022 19:07:05 -0800
Subject: [PATCH 08/44] if theme folder does not exist create one
---
src/main/base/browserwindow.ts | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/main/base/browserwindow.ts b/src/main/base/browserwindow.ts
index 1f581fb1..d5ebe168 100644
--- a/src/main/base/browserwindow.ts
+++ b/src/main/base/browserwindow.ts
@@ -372,6 +372,9 @@ export class BrowserWindow {
});
ipcMain.on("get-github-theme", async (event, url) => {
+ if (!existsSync(utils.getPath("themes"))) {
+ mkdirSync(utils.getPath("themes"));
+ }
if (url.endsWith("/")) url = url.slice(0, -1);
let response = await fetch(
`${url}/archive/refs/heads/main.zip`
From c8a310c29b630b8367aba99e19a51fbc32fabc49 Mon Sep 17 00:00:00 2001
From: vapormusic
Date: Sat, 12 Feb 2022 10:11:57 +0700
Subject: [PATCH 09/44] plurals
---
src/i18n/en_US.jsonc | 14 ++++----------
src/renderer/index.js | 23 +++++++++++++++--------
src/renderer/views/main.ejs | 1 +
3 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/src/i18n/en_US.jsonc b/src/i18n/en_US.jsonc
index 76216893..07c72a2e 100644
--- a/src/i18n/en_US.jsonc
+++ b/src/i18n/en_US.jsonc
@@ -124,16 +124,10 @@
"term.contributors": "Contributors",
"term.equalizer": "Equalizer",
"term.reset": "Reset",
- "term.track": [
- {
- "value": 1,
- "text": "track"
- },
- {
- "value": 2,
- "text": "tracks"
- }
- ],
+ "term.track": {
+ "one" : "track",
+ "other" : "tracks"
+ },
"term.tracks": "tracks", // Assume x amount of tracks. e.g. 50 tracks
"term.videos": "Videos",
"term.menu": "Menu",
diff --git a/src/renderer/index.js b/src/renderer/index.js
index 7ed2b57c..d2475642 100644
--- a/src/renderer/index.js
+++ b/src/renderer/index.js
@@ -324,13 +324,17 @@ const app = new Vue({
},
getLz(message, options = {}) {
if (this.lz[message]) {
- if(options["plural"]) {
- let closest = this.lz[message].reduce(function(prev, curr) {
- return (Math.abs(curr.value - options["plural"]) < Math.abs(prev.value - options["plural"]) ? curr : prev);
- });
- return closest.text;
- }else if(typeof this.lz[message] === "object") {
- return this.lz[message][0].text;
+ if(options["count"] ) {
+ if (typeof this.lz[message] === "object"){
+ let type = window.fastPluralRules.getPluralFormNameForCardinalByLocale(this.cfg.general.language.replace("_","-"),options["count"]);
+ return this.lz[message][type] ?? ((this.lz[message])[Object.keys(this.lz[message])[0]] ?? this.lz[message])
+ } else {
+ // fallback English plural forms ( old i18n )
+ if (options["count"] > 1) {
+ return this.lz[message+ "s"] ?? this.lz[message]} else { return this.lz[message]}
+ }
+ } else if(typeof this.lz[message] === "object") {
+ return (this.lz[message])[Object.keys(this.lz[message])[0]]
}
return this.lz[message]
} else {
@@ -2149,7 +2153,10 @@ const app = new Vue({
let hours = Math.floor(time / 3600)
let mins = Math.floor(time / 60) % 60
let secs = time % 60
- return app.showingPlaylist.relationships.tracks.data.length + " " + app.getLz('term.tracks') + ", " + ((hours > 0) ? (hours + (" " + ((hours > 1) ? app.getLz('term.time.hours') + ", " : app.getLz('term.time.hour') + ", "))) : "") + ((mins > 0) ? (mins + ((mins > 1) ? " " + app.getLz('term.time.minutes') + ", " : " " + app.getLz('term.time.minute') + ", ")) : "") + secs + ((secs > 1) ? " " + app.getLz('term.time.seconds') + "." : " " + app.getLz('term.time.second') + ".");
+ return app.showingPlaylist.relationships.tracks.data.length + " " + app.getLz('term.track', options = {count : app.showingPlaylist.relationships.tracks.data.length}) + ", "
+ + ((hours > 0) ? (hours + (" " + (app.getLz('term.time.hour', options = {count : hours}) + ", "))) : "") +
+ ((mins > 0) ? (mins + (" " + app.getLz('term.time.minute', options = {count : mins}) + ", ")) : "") +
+ secs + (" " + app.getLz('term.time.second', options = {count : secs}) + ".");
} else return ""
} catch (err) {
return ""
diff --git a/src/renderer/views/main.ejs b/src/renderer/views/main.ejs
index 55b4403d..3097a196 100644
--- a/src/renderer/views/main.ejs
+++ b/src/renderer/views/main.ejs
@@ -72,6 +72,7 @@
document.write(unescape("%3Cscript src='https://js-cdn.music.apple.com/musickit/v2/amp/musickit.js' type='text/javascript'%3E%3C/script%3E"));
}
+
-
+