Use API
This commit is contained in:
parent
23541ae239
commit
79a62b5e2f
4 changed files with 30 additions and 20 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ package-lock.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
yarn-error.log
|
yarn-error.log
|
||||||
.yarnclean
|
.yarnclean
|
||||||
|
auth.json
|
||||||
|
|
1
index.js
1
index.js
|
@ -1,5 +1,6 @@
|
||||||
require('v8-compile-cache');
|
require('v8-compile-cache');
|
||||||
const {app} = require('electron');
|
const {app} = require('electron');
|
||||||
|
const {BrowserWindow} = require("electron-acrylic-window");
|
||||||
|
|
||||||
// Creating the Application Window and Calling all the Functions
|
// Creating the Application Window and Calling all the Functions
|
||||||
function CreateWindow() {
|
function CreateWindow() {
|
||||||
|
|
|
@ -779,26 +779,20 @@ const app = new Vue({
|
||||||
|
|
||||||
document.addEventListener('musickitloaded', function () {
|
document.addEventListener('musickitloaded', function () {
|
||||||
// MusicKit global is now defined
|
// MusicKit global is now defined
|
||||||
fetch("https://beta.music.apple.com/", {mode: "no-cors"})
|
console.log("Loading musickit")
|
||||||
.then(response => response.text())
|
ipcRenderer.on('devkey', (event, key) => {
|
||||||
.then(data => {
|
console.log(key);
|
||||||
var el = document.createElement("html");
|
MusicKit.configure({
|
||||||
el.innerHTML = data;
|
developerToken: key,
|
||||||
var u = el.querySelector(`[name="desktop-music-app/config/environment"]`)
|
app: {
|
||||||
var amwebCFG = JSON.parse(decodeURIComponent(u.getAttribute("content")));
|
name: 'My Cool Web App',
|
||||||
console.log(amwebCFG.MEDIA_API.token)
|
build: '1978.4.1'
|
||||||
MusicKit.configure({
|
}
|
||||||
developerToken: amwebCFG.MEDIA_API.token,
|
|
||||||
app: {
|
|
||||||
name: 'My Cool Web App',
|
|
||||||
build: '1978.4.1'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
|
||||||
app.init()
|
|
||||||
}, 1000)
|
|
||||||
});
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
app.init()
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
function xmlToJson(xml) {
|
function xmlToJson(xml) {
|
||||||
|
|
|
@ -4,6 +4,8 @@ const getPort = require("get-port");
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const windowStateKeeper = require("electron-window-state");
|
const windowStateKeeper = require("electron-window-state");
|
||||||
|
const request = require('request');
|
||||||
|
const authFile = require("../auth.json");
|
||||||
|
|
||||||
const CiderBase = {
|
const CiderBase = {
|
||||||
|
|
||||||
|
@ -106,6 +108,18 @@ const CiderBase = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
win.webContents.on('did-finish-load', () => {
|
||||||
|
let authFile = require("../auth.json")
|
||||||
|
request({url: "https://devkey.cider.sh/",
|
||||||
|
headers: {
|
||||||
|
"Authorization": "Bearer "+authFile.authHeader
|
||||||
|
}
|
||||||
|
}, function (error, response, body) {
|
||||||
|
if (error) return console.log(error);
|
||||||
|
let parsedJson = JSON.parse(body)
|
||||||
|
win.webContents.send("devkey", parsedJson.Key)
|
||||||
|
})
|
||||||
|
})
|
||||||
return win
|
return win
|
||||||
},
|
},
|
||||||
async InitWebServer() {
|
async InitWebServer() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue