Merge branch 'ciderapp:main' into main
This commit is contained in:
commit
475797fd1c
7 changed files with 33 additions and 41 deletions
|
@ -372,7 +372,8 @@ export class BrowserWindow {
|
||||||
* @yields {object} Electron browser window
|
* @yields {object} Electron browser window
|
||||||
*/
|
*/
|
||||||
async createWindow(): Promise<Electron.BrowserWindow> {
|
async createWindow(): Promise<Electron.BrowserWindow> {
|
||||||
this.clientPort = await getPort({ port: 9000 });
|
const envPort = process.env?.CIDER_PORT || '9000'
|
||||||
|
this.clientPort = await getPort({ port: parseInt(envPort, 10) || 9000 });
|
||||||
BrowserWindow.verifyFiles();
|
BrowserWindow.verifyFiles();
|
||||||
this.StartWatcher(utils.getPath('themes'));
|
this.StartWatcher(utils.getPath('themes'));
|
||||||
|
|
||||||
|
|
|
@ -76,10 +76,6 @@ ipcMain.on("nowPlayingItemDidChange", (_event, attributes) => {
|
||||||
CiderPlug.callPlugins("onNowPlayingItemDidChange", attributes);
|
CiderPlug.callPlugins("onNowPlayingItemDidChange", attributes);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on("updatePlaybackProgress", (_event, attributes) => {
|
|
||||||
CiderPlug.callPlugins("updatePlaybackProgress", attributes);
|
|
||||||
})
|
|
||||||
|
|
||||||
app.on("before-quit", () => {
|
app.on("before-quit", () => {
|
||||||
CiderPlug.callPlugins("onBeforeQuit");
|
CiderPlug.callPlugins("onBeforeQuit");
|
||||||
console.warn(`${app.getName()} exited.`);
|
console.warn(`${app.getName()} exited.`);
|
||||||
|
|
|
@ -10,8 +10,6 @@ export default class mpris {
|
||||||
* MPRIS Service
|
* MPRIS Service
|
||||||
*/
|
*/
|
||||||
private static player: Player.Player;
|
private static player: Player.Player;
|
||||||
private static globalAttributes: any = {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base Plugin Details (Eventually implemented into a GUI in settings)
|
* Base Plugin Details (Eventually implemented into a GUI in settings)
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +74,10 @@ export default class mpris {
|
||||||
player.on('loopStatus', (status: string) => renderer.executeJavaScript(`app.mk.repeatMode = ${loopType[status.toLowerCase()]}`))
|
player.on('loopStatus', (status: string) => renderer.executeJavaScript(`app.mk.repeatMode = ${loopType[status.toLowerCase()]}`))
|
||||||
player.on('shuffle', () => renderer.executeJavaScript('app.mk.shuffleMode = (app.mk.shuffleMode === 0) ? 1 : 0'))
|
player.on('shuffle', () => renderer.executeJavaScript('app.mk.shuffleMode = (app.mk.shuffleMode === 0) ? 1 : 0'))
|
||||||
|
|
||||||
|
mpris.utils.getIPCMain().on('mpris:playbackTimeDidChange', (event: any, time: number) => {
|
||||||
|
player.getPosition = () => time;
|
||||||
|
})
|
||||||
|
|
||||||
mpris.utils.getIPCMain().on('repeatModeDidChange', (_e: any, mode: number) => {
|
mpris.utils.getIPCMain().on('repeatModeDidChange', (_e: any, mode: number) => {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -160,7 +162,6 @@ export default class mpris {
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
@mpris.linuxOnly
|
||||||
onPlaybackStateDidChange(attributes: any): void {
|
onPlaybackStateDidChange(attributes: any): void {
|
||||||
mpris.globalAttributes = attributes
|
|
||||||
mpris.player.playbackStatus = attributes?.status ? Player.PLAYBACK_STATUS_PLAYING : Player.PLAYBACK_STATUS_PAUSED
|
mpris.player.playbackStatus = attributes?.status ? Player.PLAYBACK_STATUS_PLAYING : Player.PLAYBACK_STATUS_PAUSED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,14 +171,7 @@ export default class mpris {
|
||||||
*/
|
*/
|
||||||
@mpris.linuxOnly
|
@mpris.linuxOnly
|
||||||
onNowPlayingItemDidChange(attributes: object): void {
|
onNowPlayingItemDidChange(attributes: object): void {
|
||||||
mpris.globalAttributes = attributes
|
|
||||||
mpris.updateMetaData(attributes);
|
mpris.updateMetaData(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@mpris.linuxOnly
|
|
||||||
updatePlaybackProgress(attributes: any): void {
|
|
||||||
mpris.globalAttributes = attributes
|
|
||||||
mpris.player.getPosition = () => attributes.currentPlaybackTime * 1000 * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,10 +17,13 @@ const MusicKitInterop = {
|
||||||
/** wsapi */
|
/** wsapi */
|
||||||
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackProgressDidChange, () => {
|
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackProgressDidChange, () => {
|
||||||
ipcRenderer.send('wsapi-updatePlaybackState', MusicKitInterop.getAttributes());
|
ipcRenderer.send('wsapi-updatePlaybackState', MusicKitInterop.getAttributes());
|
||||||
ipcRenderer.send('updatePlaybackProgress', MusicKitInterop.getAttributes());
|
|
||||||
});
|
});
|
||||||
/** wsapi */
|
/** wsapi */
|
||||||
|
|
||||||
|
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackTimeDidChange, () => {
|
||||||
|
ipcRenderer.send('mpris:playbackTimeDidChange', (MusicKit.getInstance()?.currentPlaybackTime * 1000 * 1000 ) ?? 0);
|
||||||
|
})
|
||||||
|
|
||||||
MusicKit.getInstance().addEventListener(MusicKit.Events.nowPlayingItemDidChange, async () => {
|
MusicKit.getInstance().addEventListener(MusicKit.Events.nowPlayingItemDidChange, async () => {
|
||||||
console.debug('[cider:preload] nowPlayingItemDidChange')
|
console.debug('[cider:preload] nowPlayingItemDidChange')
|
||||||
const attributes = MusicKitInterop.getAttributes()
|
const attributes = MusicKitInterop.getAttributes()
|
||||||
|
|
|
@ -3196,45 +3196,40 @@ const app = new Vue({
|
||||||
function getMXMTrans(lang, vanity_id) {
|
function getMXMTrans(lang, vanity_id) {
|
||||||
try {
|
try {
|
||||||
if (lang != "disabled" && vanity_id != '') { // Mode 2 -> Trans
|
if (lang != "disabled" && vanity_id != '') { // Mode 2 -> Trans
|
||||||
fetch('https://www.musixmatch.com/lyrics/' + vanity_id +'/translation/' + lang, {
|
let url = "https://api.cider.sh/v1/lyrics?vanityID=" + vanity_id +'&source=mxm&lang=' + lang;
|
||||||
method: 'GET',
|
let req = new XMLHttpRequest();
|
||||||
headers: {
|
req.overrideMimeType("application/json");
|
||||||
'Host': 'musixmatch.com',
|
req.onload = function () {
|
||||||
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
|
if (req.status == 200) { // If it's not 200, 237890127389012 things could go wrong and I don't really care what those things are.
|
||||||
'authority': "www.musixmatch.com"
|
let jsonResponse = JSON.parse(this.responseText);
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(async (res) => {
|
|
||||||
if (res.status != 200) {return}
|
|
||||||
let html = document.createElement('html'); html.innerHTML = await res.text()
|
|
||||||
let lyric_isolated = html.querySelector("#site > div > div > div > main > div > div > div.mxm-track-lyrics-container > div.container > div > div > div > div.col-sm-12.col-md-10.col-ml-9.col-lg-9 > div.mxm-lyrics.translated > div.row > div.col-xs-12.col-sm-12.col-md-12.col-ml-12.col-lg-12")
|
|
||||||
let raw_lines = lyric_isolated.getElementsByClassName("col-xs-6 col-sm-6 col-md-6 col-ml-6 col-lg-6")
|
|
||||||
let applied = 0;
|
let applied = 0;
|
||||||
for (let i = 1; applied < app.lyrics.length; i+=2) { // Start on odd elements because even ones are original.
|
for (let i = 0; applied < app.lyrics.length; i++) {
|
||||||
if (raw_lines[i].childNodes[0].childNodes[0].textContent.trim() == "") {i+=2;}
|
if (app.lyrics[applied].line.trim() === "") {applied+=1;}
|
||||||
if (app.lyrics[applied].line.trim() == "") {applied+=1;}
|
if (app.lyrics[applied].line.trim() === jsonResponse[i]) {
|
||||||
if (app.lyrics[applied].line.trim() === raw_lines[i].childNodes[0].childNodes[0].textContent.trim().replace('′', "'")) {
|
|
||||||
// Do Nothing
|
// Do Nothing
|
||||||
applied +=1;
|
applied +=1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (app.lyrics[applied].line === "lrcInstrumental") {
|
if (app.lyrics[applied].line === "lrcInstrumental") {
|
||||||
if (app.lyrics[applied+1].line.trim() === raw_lines[i].childNodes[0].childNodes[0].textContent.trim()) {
|
if (app.lyrics[applied+1].line.trim() === jsonResponse[i]) {
|
||||||
// Do Nothing
|
// Do Nothing
|
||||||
applied +=2;
|
applied +=2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.lyrics[applied+1].translation = raw_lines[i].childNodes[0].childNodes[0].textContent.trim();
|
app.lyrics[applied+1].translation = jsonResponse[i];
|
||||||
applied +=2;
|
applied +=2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
app.lyrics[applied].translation = raw_lines[i].childNodes[0].childNodes[0].textContent.trim();
|
app.lyrics[applied].translation = jsonResponse[i];
|
||||||
applied +=1;
|
applied +=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
req.open('POST', url, true);
|
||||||
|
req.send();
|
||||||
}
|
}
|
||||||
} catch (e) {console.debug("Error while parsing MXM Trans: " + e)}
|
} catch (e) {console.debug("Error while parsing MXM Trans: " + e)}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<script async
|
<script async
|
||||||
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") %>"
|
src="<%- (env.useV3 ? "https://js-cdn.music.apple.com/musickit/v3/amp/musickit.js" : "https://api.cider.sh/musickit.js") %>"
|
||||||
data-web-components>
|
data-web-components>
|
||||||
</script>
|
</script>
|
||||||
<script src="index.js?v=1"></script>
|
<script src="index.js?v=1"></script>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script type="text/x-template" id="cider-playlist">
|
<script type="text/x-template" id="cider-playlist">
|
||||||
<div class="content-inner playlist-page" :class="classes" v-if="data != [] && data.attributes != null"
|
<div class="content-inner playlist-page" :class="classes" :is-album="isAlbum()" v-if="data != [] && data.attributes != null"
|
||||||
|
|
||||||
:style="{'--bgColor': (data.attributes.artwork != null && data.attributes.artwork['bgColor'] != null) ? ('#' + data.attributes.artwork.bgColor) : ''}">
|
:style="{'--bgColor': (data.attributes.artwork != null && data.attributes.artwork['bgColor'] != null) ? ('#' + data.attributes.artwork.bgColor) : ''}">
|
||||||
<template v-if="app.playlists.loadingState == 0">
|
<template v-if="app.playlists.loadingState == 0">
|
||||||
|
@ -347,6 +347,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
isAlbum() {
|
||||||
|
return (this.data.attributes?.playParams?.kind ?? this.data.type ?? '').includes('album')
|
||||||
|
},
|
||||||
minClass(val) {
|
minClass(val) {
|
||||||
if(app.appMode == 'fullscreen') {
|
if(app.appMode == 'fullscreen') {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue