This maybe works
This commit is contained in:
parent
4b2513330c
commit
51f28144d0
4 changed files with 36 additions and 12 deletions
|
@ -770,7 +770,7 @@ export class BrowserWindow {
|
||||||
};
|
};
|
||||||
Object.assign(options, args);
|
Object.assign(options, args);
|
||||||
|
|
||||||
let res = await fetch(
|
let res = await utils.fetch(
|
||||||
`https://amp-api.music.apple.com/${options.route}?${new URLSearchParams({
|
`https://amp-api.music.apple.com/${options.route}?${new URLSearchParams({
|
||||||
...options.GETBody,
|
...options.GETBody,
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
|
@ -882,9 +882,9 @@ export class BrowserWindow {
|
||||||
mkdirSync(utils.getPath("plugins"));
|
mkdirSync(utils.getPath("plugins"));
|
||||||
}
|
}
|
||||||
if (url.endsWith("/")) url = url.slice(0, -1);
|
if (url.endsWith("/")) url = url.slice(0, -1);
|
||||||
let response = await fetch(`${url}/archive/refs/heads/main.zip`);
|
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
|
||||||
let repo = url.split("/").slice(-2).join("/");
|
let repo = url.split("/").slice(-2).join("/");
|
||||||
let apiRepo = await fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
|
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
|
||||||
console.debug(`REPO ID: ${apiRepo.id}`);
|
console.debug(`REPO ID: ${apiRepo.id}`);
|
||||||
// extract the files from the first folder in the zip response
|
// extract the files from the first folder in the zip response
|
||||||
let zip = new AdmZip(await response.buffer());
|
let zip = new AdmZip(await response.buffer());
|
||||||
|
@ -894,7 +894,7 @@ export class BrowserWindow {
|
||||||
}
|
}
|
||||||
console.log(join(utils.getPath("plugins"), "gh_" + apiRepo.id));
|
console.log(join(utils.getPath("plugins"), "gh_" + apiRepo.id));
|
||||||
zip.extractEntryTo(entry, join(utils.getPath("plugins"), "gh_" + apiRepo.id), false, true);
|
zip.extractEntryTo(entry, join(utils.getPath("plugins"), "gh_" + apiRepo.id), false, true);
|
||||||
let commit = await fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
|
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
|
||||||
console.debug(`COMMIT SHA: ${commit[0].sha}`);
|
console.debug(`COMMIT SHA: ${commit[0].sha}`);
|
||||||
let theme = JSON.parse(readFileSync(join(utils.getPath("plugins"), "gh_" + apiRepo.id, "package.json"), "utf8"));
|
let theme = JSON.parse(readFileSync(join(utils.getPath("plugins"), "gh_" + apiRepo.id, "package.json"), "utf8"));
|
||||||
theme.id = apiRepo.id;
|
theme.id = apiRepo.id;
|
||||||
|
@ -919,9 +919,9 @@ export class BrowserWindow {
|
||||||
mkdirSync(utils.getPath("themes"));
|
mkdirSync(utils.getPath("themes"));
|
||||||
}
|
}
|
||||||
if (url.endsWith("/")) url = url.slice(0, -1);
|
if (url.endsWith("/")) url = url.slice(0, -1);
|
||||||
let response = await fetch(`${url}/archive/refs/heads/main.zip`);
|
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
|
||||||
let repo = url.split("/").slice(-2).join("/");
|
let repo = url.split("/").slice(-2).join("/");
|
||||||
let apiRepo = await fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
|
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json());
|
||||||
console.debug(`REPO ID: ${apiRepo.id}`);
|
console.debug(`REPO ID: ${apiRepo.id}`);
|
||||||
// extract the files from the first folder in the zip response
|
// extract the files from the first folder in the zip response
|
||||||
let zip = new AdmZip(await response.buffer());
|
let zip = new AdmZip(await response.buffer());
|
||||||
|
@ -931,7 +931,7 @@ export class BrowserWindow {
|
||||||
}
|
}
|
||||||
console.log(join(utils.getPath("themes"), "gh_" + apiRepo.id));
|
console.log(join(utils.getPath("themes"), "gh_" + apiRepo.id));
|
||||||
zip.extractEntryTo(entry, join(utils.getPath("themes"), "gh_" + apiRepo.id), false, true);
|
zip.extractEntryTo(entry, join(utils.getPath("themes"), "gh_" + apiRepo.id), false, true);
|
||||||
let commit = await fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
|
let commit = await utils.fetch(`https://api.github.com/repos/${repo}/commits`).then((res) => res.json());
|
||||||
console.debug(`COMMIT SHA: ${commit[0].sha}`);
|
console.debug(`COMMIT SHA: ${commit[0].sha}`);
|
||||||
let theme = JSON.parse(readFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), "utf8"));
|
let theme = JSON.parse(readFileSync(join(utils.getPath("themes"), "gh_" + apiRepo.id, "theme.json"), "utf8"));
|
||||||
theme.id = apiRepo.id;
|
theme.id = apiRepo.id;
|
||||||
|
|
|
@ -3,6 +3,7 @@ import * as path from "path";
|
||||||
import { Store } from "./store";
|
import { Store } from "./store";
|
||||||
import { BrowserWindow as bw } from "./browserwindow";
|
import { BrowserWindow as bw } from "./browserwindow";
|
||||||
import { app, BrowserWindow, ipcMain } from "electron";
|
import { app, BrowserWindow, ipcMain } from "electron";
|
||||||
|
import fetch from "electron-fetch";
|
||||||
import ElectronStore from "electron-store";
|
import ElectronStore from "electron-store";
|
||||||
|
|
||||||
export class utils {
|
export class utils {
|
||||||
|
@ -77,6 +78,29 @@ export class utils {
|
||||||
return bw.express;
|
return bw.express;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MitM the electron fetch for a function that proxies github.
|
||||||
|
* Written in TS so Maikiwi doesn't fuck up
|
||||||
|
* @param url {string} URL param
|
||||||
|
* @param opts {object} Other options
|
||||||
|
*/
|
||||||
|
static readonly _mirror: boolean = this.getStoreValue("advanced.experiments").includes('cider_mirror') ? true : false;
|
||||||
|
static fetch(url: string, opts = {}) {
|
||||||
|
if (this._mirror === true) {
|
||||||
|
if (url.includes("api.github.com/")) {
|
||||||
|
return fetch(url.replace("api.github.com/", "mirror.api.cider.sh/v2/api/"), opts);
|
||||||
|
}
|
||||||
|
else if (url.includes("raw.githubusercontent.com/")) {
|
||||||
|
return fetch(url.replace("raw.githubusercontent.com/", "mirror.api.cider.sh/v2/raw/"), opts);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return fetch(url, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return fetch(url, opts);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches the i18n locale for the given language.
|
* Fetches the i18n locale for the given language.
|
||||||
* @param language {string} The language to fetch the locale for.
|
* @param language {string} The language to fetch the locale for.
|
||||||
|
|
|
@ -1241,14 +1241,14 @@
|
||||||
|
|
||||||
<div class="md-option-line">
|
<div class="md-option-line">
|
||||||
<div class="md-option-segment">
|
<div class="md-option-segment">
|
||||||
Load MusicKit from Apple
|
Theme & Plugin Mirror to Cider
|
||||||
<small>Requires relaunch</small>
|
<small>Only works in region where GitHub is blacklisted. Requires relaunch.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="md-option-segment md-option-segment_auto">
|
<div class="md-option-segment md-option-segment_auto">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
v-model="app.cfg.advanced.experiments.includes('ampv3')"
|
v-model="app.cfg.advanced.experiments.includes('cider_mirror')"
|
||||||
@click="app.cfg.advanced.experiments.includes('ampv3') ? removeExperiment('ampv3') : addExperiment('ampv3')"
|
@click="app.cfg.advanced.experiments.includes('cider_mirror') ? removeExperiment('cider_mirror') : addExperiment('cider_mirror')"
|
||||||
switch />
|
switch />
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<script async
|
<script async
|
||||||
src="<%- (env.useV3 ? "https://js-cdn.music.apple.com/musickit/v3/amp/musickit.js" : "https://api.cider.sh/musickit.js"); %>"
|
src="<%- (env.useV3 ? "https://js-cdn.music.apple.com/musickit/v3/amp/musickit.js" : "https://js-cdn.music.apple.com/musickit/v2/amp/musickit.js"); %>"
|
||||||
data-web-components>
|
data-web-components>
|
||||||
</script>
|
</script>
|
||||||
<script src="index.js?v=1"></script>
|
<script src="index.js?v=1"></script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue