commit
f87f110525
6 changed files with 84 additions and 67 deletions
41
index.js
41
index.js
|
@ -1,8 +1,8 @@
|
||||||
require('v8-compile-cache');
|
require('v8-compile-cache');
|
||||||
const {app, components} = require('electron'),
|
const { app, components } = require('electron'), { resolve, join } = require("path"),
|
||||||
{resolve, join} = require("path"),
|
|
||||||
CiderBase = require('./src/main/cider-base');
|
CiderBase = require('./src/main/cider-base');
|
||||||
|
const customProtocols = require('./package.json').fileAssociations[0].protocols
|
||||||
|
console.log(customProtocols)
|
||||||
const comps = components;
|
const comps = components;
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,25 +208,28 @@ app.on('widevine-error', (error) => {
|
||||||
|
|
||||||
if (process.defaultApp) {
|
if (process.defaultApp) {
|
||||||
if (process.argv.length >= 2) {
|
if (process.argv.length >= 2) {
|
||||||
app.setAsDefaultProtocolClient('cider', process.execPath, [resolve(process.argv[1])])
|
customProtocols.forEach((customProtocol) => {
|
||||||
app.setAsDefaultProtocolClient('ame', process.execPath, [resolve(process.argv[1])])
|
app.setAsDefaultProtocolClient(customProtocol, process.execPath, [resolve(process.argv[1])])
|
||||||
app.setAsDefaultProtocolClient('itms', process.execPath, [resolve(process.argv[1])])
|
})
|
||||||
app.setAsDefaultProtocolClient('itmss', process.execPath, [resolve(process.argv[1])])
|
|
||||||
app.setAsDefaultProtocolClient('musics', process.execPath, [resolve(process.argv[1])])
|
|
||||||
app.setAsDefaultProtocolClient('music', process.execPath, [resolve(process.argv[1])])
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.setAsDefaultProtocolClient('cider') // Custom AME Protocol
|
/*
|
||||||
app.setAsDefaultProtocolClient('ame') // Custom AME Protocol
|
* cider - Custom Cider Protocol
|
||||||
app.setAsDefaultProtocolClient('itms') // iTunes HTTP Protocol
|
* ame - Custom AME Protocol (Backwards Compat.)
|
||||||
app.setAsDefaultProtocolClient('itmss') // iTunes HTTPS Protocol
|
* itms - iTunes HTTP Protocol
|
||||||
app.setAsDefaultProtocolClient('musics') // macOS Client Protocol
|
* itmss - iTunes HTTPS Protocol
|
||||||
app.setAsDefaultProtocolClient('music') // macOS Client Protocol
|
* musics - macOS Client Protocol
|
||||||
|
* music - macOS Client Protocol
|
||||||
|
*/
|
||||||
|
customProtocols.forEach((customProtocol) => {
|
||||||
|
app.setAsDefaultProtocolClient(customProtocol)
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('open-url', (event, url) => {
|
app.on('open-url', (event, url) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
if (url.includes('ame://') || url.includes('itms://') || url.includes('itmss://') || url.includes('musics://') || url.includes('music://')) {
|
if (customProtocols.some(protocol => url.includes(protocol))) {
|
||||||
CiderBase.LinkHandler(url)
|
CiderBase.LinkHandler(url)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -236,8 +239,7 @@ app.on('second-instance', (_e, argv) => {
|
||||||
|
|
||||||
// Checks if first instance is authorized and if second instance has protocol args
|
// Checks if first instance is authorized and if second instance has protocol args
|
||||||
argv.forEach((value) => {
|
argv.forEach((value) => {
|
||||||
if (value.includes('ame://') || value.includes('itms://') || value.includes('itmss://') || value.includes('musics://') || value.includes('music://')) {
|
if (customProtocols.some(protocol => value.includes(protocol))) {
|
||||||
console.warn(`[InstanceHandler][SecondInstanceHandler] Found Protocol!`)
|
|
||||||
CiderBase.LinkHandler(value);
|
CiderBase.LinkHandler(value);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -258,6 +260,3 @@ if (!app.requestSingleInstanceLock() && true) {
|
||||||
app.quit();
|
app.quit();
|
||||||
// app.isQuiting = true
|
// app.isQuiting = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ const CiderBase = {
|
||||||
|
|
||||||
win.webContents.session.webRequest.onHeadersReceived((details, callback) => {
|
win.webContents.session.webRequest.onHeadersReceived((details, callback) => {
|
||||||
if (details.url.match(/^https:\/\/store-\d{3}\.blobstore\.apple\.com/) || details.url.startsWith("https://store-037.blobstore.apple.com")) {
|
if (details.url.match(/^https:\/\/store-\d{3}\.blobstore\.apple\.com/) || details.url.startsWith("https://store-037.blobstore.apple.com")) {
|
||||||
details.responseHeaders['Access-Control-Allow-Origin'] = '*';}
|
details.responseHeaders['Access-Control-Allow-Origin'] = '*';
|
||||||
|
}
|
||||||
callback({ responseHeaders: details.responseHeaders })
|
callback({ responseHeaders: details.responseHeaders })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -338,10 +339,11 @@ const CiderBase = {
|
||||||
},
|
},
|
||||||
LinkHandler: (startArgs) => {
|
LinkHandler: (startArgs) => {
|
||||||
if (!startArgs) return;
|
if (!startArgs) return;
|
||||||
console.log("lfmtoken", String(startArgs))
|
|
||||||
if (String(startArgs).includes('auth')) {
|
if (String(startArgs).includes('auth')) {
|
||||||
let authURI = String(startArgs).split('/auth/')[1]
|
let authURI = String(startArgs).split('/auth/')[1]
|
||||||
if (authURI.startsWith('lastfm')) { // If we wanted more auth options
|
if (authURI.startsWith('lastfm')) { // If we wanted more auth options
|
||||||
|
console.log("lfmtoken", String(startArgs))
|
||||||
const authKey = authURI.split('lastfm?token=')[1];
|
const authKey = authURI.split('lastfm?token=')[1];
|
||||||
app.cfg.set('lastfm.enabled', true);
|
app.cfg.set('lastfm.enabled', true);
|
||||||
app.cfg.set('lastfm.auth_token', authKey);
|
app.cfg.set('lastfm.auth_token', authKey);
|
||||||
|
@ -349,17 +351,28 @@ const CiderBase = {
|
||||||
lastfm.authenticate()
|
lastfm.authenticate()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const formattedSongID = startArgs.replace('ame://', '').replace('/', '');
|
if (String(startArgs).includes('/play/')) { //Steer away from protocal:// specific conditionals
|
||||||
console.warn(`[LinkHandler] Attempting to load song id: ${formattedSongID}`);
|
const playParam = String(startArgs).split('/play/')[1]
|
||||||
|
if (playParam.includes('s/')) { // setQueue can be done with album, song, url, playlist id
|
||||||
// setQueue can be done with album, song, url, playlist id
|
console.log(playParam)
|
||||||
|
let song = playParam.split('s/')[1]
|
||||||
|
console.warn(`[LinkHandler] Attempting to load song by id: ${song}`);
|
||||||
this.win.webContents.executeJavaScript(`
|
this.win.webContents.executeJavaScript(`
|
||||||
MusicKit.getInstance().setQueue({ song: '${formattedSongID}'}).then(function(queue) {
|
MusicKit.getInstance().setQueue({ song: '${song}'}).then(function(queue) {
|
||||||
MusicKit.getInstance().play();
|
MusicKit.getInstance().play();
|
||||||
});
|
});
|
||||||
`).catch((err) => console.error(err));
|
`).catch((err) => console.error(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async InitWebServer() {
|
async InitWebServer() {
|
||||||
|
|
|
@ -64,7 +64,7 @@ module.exports = {
|
||||||
|
|
||||||
// console.log('[DiscordRPC][updateActivity] Updating Discord Activity.')
|
// console.log('[DiscordRPC][updateActivity] Updating Discord Activity.')
|
||||||
|
|
||||||
const listenURL = `https://applemusicelectron.com/p?id=${attributes.playParams.id}`
|
const listenURL = `https://cider.sh/p?s&id=${attributes.playParams.id}` // cider://play/s/[id] (for song)
|
||||||
//console.log(attributes)
|
//console.log(attributes)
|
||||||
let ActivityObject = {
|
let ActivityObject = {
|
||||||
details: attributes.name,
|
details: attributes.name,
|
||||||
|
|
|
@ -2929,6 +2929,8 @@ input[type="range"].web-slider.display--small::-webkit-slider-thumb {
|
||||||
|
|
||||||
.autoplay {
|
.autoplay {
|
||||||
background: rgb(200 200 200 / 15%);
|
background: rgb(200 200 200 / 15%);
|
||||||
|
color:rgb(255 255 255);
|
||||||
|
font-size: larger;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<h3 class="queue-header-text">Queue</h3>
|
<h3 class="queue-header-text">Queue</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto flex-center">
|
<div class="col-auto flex-center">
|
||||||
<button class="autoplay" :style="{'background': app.mk.autoplayEnabled ? 'var(--keyColor)' : ''}" @click="app.mk.autoplayEnabled = !app.mk.autoplayEnabled">AUTO</button>
|
<button class="autoplay" :style="{'background': app.mk.autoplayEnabled ? 'var(--keyColor)' : ''}" @click="app.mk.autoplayEnabled = !app.mk.autoplayEnabled">∞</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="queue-body">
|
<div class="queue-body">
|
||||||
|
|
|
@ -142,8 +142,11 @@
|
||||||
@click="invokeDrawer('queue')"></button>
|
@click="invokeDrawer('queue')"></button>
|
||||||
</div>
|
</div>
|
||||||
<div class="app-chrome-item generic">
|
<div class="app-chrome-item generic">
|
||||||
|
<template v-if="lyrics && lyrics != [] && lyrics.length > 0">
|
||||||
<button class="playback-button--small lyrics" :class="{'active': drawer.panel == 'lyrics'}"
|
<button class="playback-button--small lyrics" :class="{'active': drawer.panel == 'lyrics'}"
|
||||||
@click="invokeDrawer('lyrics')"></button>
|
@click="invokeDrawer('lyrics')"></button>
|
||||||
|
</template>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="app-chrome-item full-height" v-if="chrome.windowControlPosition == 'right'">
|
<div class="app-chrome-item full-height" v-if="chrome.windowControlPosition == 'right'">
|
||||||
<div class="window-controls">
|
<div class="window-controls">
|
||||||
|
@ -517,7 +520,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<transition name="drawertransition">
|
<transition name="drawertransition">
|
||||||
<div class="app-drawer" v-if="drawer.open && drawer.panel == 'lyrics'">
|
<div class="app-drawer" v-if="drawer.open && drawer.panel == 'lyrics' && lyrics && lyrics != [] && lyrics.length > 0">
|
||||||
<div class="bgArtworkMaterial">
|
<div class="bgArtworkMaterial">
|
||||||
<div class="bg-artwork-container">
|
<div class="bg-artwork-container">
|
||||||
<img class="bg-artwork a" :src="$store.state.artwork.playerLCD">
|
<img class="bg-artwork a" :src="$store.state.artwork.playerLCD">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue