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
|
||||
yarn-error.log
|
||||
.yarnclean
|
||||
auth.json
|
||||
|
|
1
index.js
1
index.js
|
@ -1,5 +1,6 @@
|
|||
require('v8-compile-cache');
|
||||
const {app} = require('electron');
|
||||
const {BrowserWindow} = require("electron-acrylic-window");
|
||||
|
||||
// Creating the Application Window and Calling all the Functions
|
||||
function CreateWindow() {
|
||||
|
|
|
@ -779,26 +779,20 @@ const app = new Vue({
|
|||
|
||||
document.addEventListener('musickitloaded', function () {
|
||||
// MusicKit global is now defined
|
||||
fetch("https://beta.music.apple.com/", {mode: "no-cors"})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
var el = document.createElement("html");
|
||||
el.innerHTML = data;
|
||||
var u = el.querySelector(`[name="desktop-music-app/config/environment"]`)
|
||||
var amwebCFG = JSON.parse(decodeURIComponent(u.getAttribute("content")));
|
||||
console.log(amwebCFG.MEDIA_API.token)
|
||||
MusicKit.configure({
|
||||
developerToken: amwebCFG.MEDIA_API.token,
|
||||
app: {
|
||||
name: 'My Cool Web App',
|
||||
build: '1978.4.1'
|
||||
}
|
||||
});
|
||||
setTimeout(() => {
|
||||
app.init()
|
||||
}, 1000)
|
||||
console.log("Loading musickit")
|
||||
ipcRenderer.on('devkey', (event, key) => {
|
||||
console.log(key);
|
||||
MusicKit.configure({
|
||||
developerToken: key,
|
||||
app: {
|
||||
name: 'My Cool Web App',
|
||||
build: '1978.4.1'
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
app.init()
|
||||
}, 1000)
|
||||
})
|
||||
});
|
||||
|
||||
function xmlToJson(xml) {
|
||||
|
|
|
@ -4,6 +4,8 @@ const getPort = require("get-port");
|
|||
const express = require("express");
|
||||
const path = require("path");
|
||||
const windowStateKeeper = require("electron-window-state");
|
||||
const request = require('request');
|
||||
const authFile = require("../auth.json");
|
||||
|
||||
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
|
||||
},
|
||||
async InitWebServer() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue