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
|
||||
*/
|
||||
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();
|
||||
this.StartWatcher(utils.getPath('themes'));
|
||||
|
||||
|
@ -1573,4 +1574,4 @@ export class BrowserWindow {
|
|||
server2.start();
|
||||
console.log('remote broadcasted')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,10 +76,6 @@ ipcMain.on("nowPlayingItemDidChange", (_event, attributes) => {
|
|||
CiderPlug.callPlugins("onNowPlayingItemDidChange", attributes);
|
||||
});
|
||||
|
||||
ipcMain.on("updatePlaybackProgress", (_event, attributes) => {
|
||||
CiderPlug.callPlugins("updatePlaybackProgress", attributes);
|
||||
})
|
||||
|
||||
app.on("before-quit", () => {
|
||||
CiderPlug.callPlugins("onBeforeQuit");
|
||||
console.warn(`${app.getName()} exited.`);
|
||||
|
|
|
@ -10,8 +10,6 @@ export default class mpris {
|
|||
* MPRIS Service
|
||||
*/
|
||||
private static player: Player.Player;
|
||||
private static globalAttributes: any = {}
|
||||
|
||||
/**
|
||||
* 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('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) => {
|
||||
switch (mode) {
|
||||
case 0:
|
||||
|
@ -160,7 +162,6 @@ export default class mpris {
|
|||
*/
|
||||
@mpris.linuxOnly
|
||||
onPlaybackStateDidChange(attributes: any): void {
|
||||
mpris.globalAttributes = attributes
|
||||
mpris.player.playbackStatus = attributes?.status ? Player.PLAYBACK_STATUS_PLAYING : Player.PLAYBACK_STATUS_PAUSED
|
||||
}
|
||||
|
||||
|
@ -170,14 +171,7 @@ export default class mpris {
|
|||
*/
|
||||
@mpris.linuxOnly
|
||||
onNowPlayingItemDidChange(attributes: object): void {
|
||||
mpris.globalAttributes = 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 */
|
||||
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackProgressDidChange, () => {
|
||||
ipcRenderer.send('wsapi-updatePlaybackState', MusicKitInterop.getAttributes());
|
||||
ipcRenderer.send('updatePlaybackProgress', MusicKitInterop.getAttributes());
|
||||
});
|
||||
/** wsapi */
|
||||
|
||||
MusicKit.getInstance().addEventListener(MusicKit.Events.playbackTimeDidChange, () => {
|
||||
ipcRenderer.send('mpris:playbackTimeDidChange', (MusicKit.getInstance()?.currentPlaybackTime * 1000 * 1000 ) ?? 0);
|
||||
})
|
||||
|
||||
MusicKit.getInstance().addEventListener(MusicKit.Events.nowPlayingItemDidChange, async () => {
|
||||
console.debug('[cider:preload] nowPlayingItemDidChange')
|
||||
const attributes = MusicKitInterop.getAttributes()
|
||||
|
|
|
@ -3196,45 +3196,40 @@ const app = new Vue({
|
|||
function getMXMTrans(lang, vanity_id) {
|
||||
try {
|
||||
if (lang != "disabled" && vanity_id != '') { // Mode 2 -> Trans
|
||||
fetch('https://www.musixmatch.com/lyrics/' + vanity_id +'/translation/' + lang, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Host': 'musixmatch.com',
|
||||
'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",
|
||||
'authority': "www.musixmatch.com"
|
||||
},
|
||||
})
|
||||
.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;
|
||||
for (let i = 1; applied < app.lyrics.length; i+=2) { // Start on odd elements because even ones are original.
|
||||
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() === raw_lines[i].childNodes[0].childNodes[0].textContent.trim().replace('′', "'")) {
|
||||
let url = "https://api.cider.sh/v1/lyrics?vanityID=" + vanity_id +'&source=mxm&lang=' + lang;
|
||||
let req = new XMLHttpRequest();
|
||||
req.overrideMimeType("application/json");
|
||||
req.onload = function () {
|
||||
if (req.status == 200) { // If it's not 200, 237890127389012 things could go wrong and I don't really care what those things are.
|
||||
let jsonResponse = JSON.parse(this.responseText);
|
||||
let applied = 0;
|
||||
for (let i = 0; applied < app.lyrics.length; i++) {
|
||||
if (app.lyrics[applied].line.trim() === "") {applied+=1;}
|
||||
if (app.lyrics[applied].line.trim() === jsonResponse[i]) {
|
||||
// Do Nothing
|
||||
applied +=1;
|
||||
}
|
||||
else {
|
||||
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
|
||||
applied +=2;
|
||||
}
|
||||
else {
|
||||
app.lyrics[applied+1].translation = raw_lines[i].childNodes[0].childNodes[0].textContent.trim();
|
||||
app.lyrics[applied+1].translation = jsonResponse[i];
|
||||
applied +=2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
app.lyrics[applied].translation = raw_lines[i].childNodes[0].childNodes[0].textContent.trim();
|
||||
app.lyrics[applied].translation = jsonResponse[i];
|
||||
applied +=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
req.open('POST', url, true);
|
||||
req.send();
|
||||
}
|
||||
} catch (e) {console.debug("Error while parsing MXM Trans: " + e)}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<% } %>
|
||||
|
||||
<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>
|
||||
</script>
|
||||
<script src="index.js?v=1"></script>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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) : ''}">
|
||||
<template v-if="app.playlists.loadingState == 0">
|
||||
|
@ -347,6 +347,9 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
isAlbum() {
|
||||
return (this.data.attributes?.playParams?.kind ?? this.data.type ?? '').includes('album')
|
||||
},
|
||||
minClass(val) {
|
||||
if(app.appMode == 'fullscreen') {
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue