Revert "Merge branch 'develop' of https://github.com/ciderapp/Cider into develop"
This reverts commit065614d668
, reversing changes made to51ef452dad
.
This commit is contained in:
parent
065614d668
commit
0f13566009
5 changed files with 46 additions and 124 deletions
|
@ -1,26 +0,0 @@
|
||||||
const CiderKit = {
|
|
||||||
v1: {
|
|
||||||
musickit: {
|
|
||||||
async mkv3(route, body, options) {
|
|
||||||
let opts = {
|
|
||||||
method: 'POST',
|
|
||||||
cache: 'no-cache',
|
|
||||||
credentials: 'same-origin',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
redirect: 'follow',
|
|
||||||
referrerPolicy: 'no-referrer',
|
|
||||||
body: {}
|
|
||||||
}
|
|
||||||
opts.body = JSON.stringify({
|
|
||||||
route: route,
|
|
||||||
body: body,
|
|
||||||
options: options
|
|
||||||
})
|
|
||||||
let response = await fetch("http://localhost:9000/api/musickit/v3", opts);
|
|
||||||
return response.json()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -328,9 +328,10 @@
|
||||||
"settings.option.lyrics.enableYoutubeLyrics": "播放 MV 時,使用 YouTube 歌詞",
|
"settings.option.lyrics.enableYoutubeLyrics": "播放 MV 時,使用 YouTube 歌詞",
|
||||||
"settings.header.connectivity": "外部連接",
|
"settings.header.connectivity": "外部連接",
|
||||||
"settings.header.connectivity.description": "調整 Cider 與外部的連接",
|
"settings.header.connectivity.description": "調整 Cider 與外部的連接",
|
||||||
"settings.option.connectivity.playbackNotifications": "歌曲播放通知",
|
|
||||||
"settings.option.connectivity.discordRPC": "Discord 動態",
|
"settings.option.connectivity.discordRPC": "Discord 動態",
|
||||||
"settings.option.connectivity.discordRPC.clientName": "應用程式名稱",
|
"settings.option.connectivity.playbackNotifications": "歌曲播放通知",
|
||||||
|
"settings.header.connectivity.discordRPC.cider": "顯示正在使用 Cider",
|
||||||
|
"settings.header.connectivity.discordRPC.appleMusic": "顯示正在使用 Apple Music",
|
||||||
"settings.option.connectivity.discordRPC.clearOnPause": "暫停時清除 Discord 動態",
|
"settings.option.connectivity.discordRPC.clearOnPause": "暫停時清除 Discord 動態",
|
||||||
"settings.option.connectivity.discordRPC.hideButtons": "隱藏 Discord 動態上的按鈕",
|
"settings.option.connectivity.discordRPC.hideButtons": "隱藏 Discord 動態上的按鈕",
|
||||||
"settings.option.connectivity.lastfmScrobble": "Last.FM Scrobbling 記錄",
|
"settings.option.connectivity.lastfmScrobble": "Last.FM Scrobbling 記錄",
|
||||||
|
@ -356,9 +357,6 @@
|
||||||
"settings.option.visual.transparent": "透明視窗框架",
|
"settings.option.visual.transparent": "透明視窗框架",
|
||||||
"settings.option.visual.transparent.description": "需主題有支援透明框架,且須重新啟動才會套用。",
|
"settings.option.visual.transparent.description": "需主題有支援透明框架,且須重新啟動才會套用。",
|
||||||
"settings.header.advanced": "進階",
|
"settings.header.advanced": "進階",
|
||||||
"settings.header.connect": "同步",
|
|
||||||
"settings.option.connect.link_account": "開啟與 Cider Connect 同步",
|
|
||||||
"settings.option.connect.link_account.description": "將您的 Discord 帳戶與 Cider Connect 連接後,你可以儲存使用者資料,包括設定、等化器,並最終在完成後儲存更多資料。(正在進行中)",
|
|
||||||
"spatial.notTurnedOn": "空間音訊目前是關閉狀態,請先開啟再使用。",
|
"spatial.notTurnedOn": "空間音訊目前是關閉狀態,請先開啟再使用。",
|
||||||
"spatial.spatialProperties": "空間音訊屬性設定",
|
"spatial.spatialProperties": "空間音訊屬性設定",
|
||||||
"spatial.width": "寬度",
|
"spatial.width": "寬度",
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
import { join } from "path";
|
import {join} from "path";
|
||||||
import { app, BrowserWindow as bw, ipcMain, ShareMenu, shell } from "electron";
|
import {app, BrowserWindow as bw, ipcMain, ShareMenu, shell} from "electron";
|
||||||
import * as windowStateKeeper from "electron-window-state";
|
import * as windowStateKeeper from "electron-window-state";
|
||||||
import * as express from "express";
|
import * as express from "express";
|
||||||
import * as getPort from "get-port";
|
import * as getPort from "get-port";
|
||||||
import { search } from "youtube-search-without-api-key";
|
import {search} from "youtube-search-without-api-key";
|
||||||
import { existsSync, rmSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync } from "fs";
|
import {existsSync, rmSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync} from "fs";
|
||||||
import { Stream } from "stream";
|
import {Stream} from "stream";
|
||||||
import { networkInterfaces } from "os";
|
import {networkInterfaces} from "os";
|
||||||
import * as mm from 'music-metadata';
|
import * as mm from 'music-metadata';
|
||||||
import fetch from 'electron-fetch'
|
import fetch from 'electron-fetch'
|
||||||
import { wsapi } from "./wsapi";
|
import {wsapi} from "./wsapi";
|
||||||
import { utils } from './utils';
|
import {utils} from './utils';
|
||||||
import { Plugins } from "./plugins";
|
import {Plugins} from "./plugins";
|
||||||
import { watch } from "chokidar";
|
import {watch} from "chokidar";
|
||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
const wallpaper = require('wallpaper');
|
const wallpaper = require('wallpaper');
|
||||||
const bodyParser = require('body-parser');
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import * as AdmZip from "adm-zip";
|
import * as AdmZip from "adm-zip";
|
||||||
|
@ -242,7 +241,7 @@ export class BrowserWindow {
|
||||||
show: false,
|
show: false,
|
||||||
// backgroundColor: "#1E1E1E",
|
// backgroundColor: "#1E1E1E",
|
||||||
titleBarStyle: 'hidden',
|
titleBarStyle: 'hidden',
|
||||||
trafficLightPosition: { x: 15, y: 20 },
|
trafficLightPosition: {x: 15, y: 20},
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
experimentalFeatures: true,
|
experimentalFeatures: true,
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
|
@ -302,7 +301,7 @@ 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 });
|
this.clientPort = await getPort({port: 9000});
|
||||||
BrowserWindow.verifyFiles();
|
BrowserWindow.verifyFiles();
|
||||||
this.StartWatcher(utils.getPath('themes'));
|
this.StartWatcher(utils.getPath('themes'));
|
||||||
|
|
||||||
|
@ -326,7 +325,7 @@ export class BrowserWindow {
|
||||||
this.options.transparent = true;
|
this.options.transparent = true;
|
||||||
}
|
}
|
||||||
this.options.autoHideMenuBar = true
|
this.options.autoHideMenuBar = true
|
||||||
if (utils.getStoreValue("visual.nativeTitleBar")) {
|
if(utils.getStoreValue("visual.nativeTitleBar")) {
|
||||||
this.options.titleBarStyle = "visible";
|
this.options.titleBarStyle = "visible";
|
||||||
this.options.frame = true
|
this.options.frame = true
|
||||||
}
|
}
|
||||||
|
@ -334,7 +333,7 @@ export class BrowserWindow {
|
||||||
case "linux":
|
case "linux":
|
||||||
this.options.backgroundColor = "#1E1E1E";
|
this.options.backgroundColor = "#1E1E1E";
|
||||||
this.options.autoHideMenuBar = true
|
this.options.autoHideMenuBar = true
|
||||||
if (utils.getStoreValue("visual.nativeTitleBar")) {
|
if(utils.getStoreValue("visual.nativeTitleBar")) {
|
||||||
this.options.titleBarStyle = "visible";
|
this.options.titleBarStyle = "visible";
|
||||||
this.options.frame = true
|
this.options.frame = true
|
||||||
}
|
}
|
||||||
|
@ -406,14 +405,7 @@ export class BrowserWindow {
|
||||||
private startWebServer(): void {
|
private startWebServer(): void {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(function (req, res, next) {
|
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
|
||||||
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
|
|
||||||
next();
|
|
||||||
});
|
|
||||||
app.use(express.static(join(utils.getPath('srcPath'), "./renderer/")));
|
app.use(express.static(join(utils.getPath('srcPath'), "./renderer/")));
|
||||||
app.use(bodyParser.urlencoded({ extended: true }))
|
|
||||||
app.use(bodyParser.json())
|
|
||||||
app.set("views", join(utils.getPath('srcPath'), "./renderer/views"));
|
app.set("views", join(utils.getPath('srcPath'), "./renderer/views"));
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
let firstRequest = true;
|
let firstRequest = true;
|
||||||
|
@ -433,35 +425,6 @@ export class BrowserWindow {
|
||||||
res.render("main", this.EnvironmentVariables);
|
res.render("main", this.EnvironmentVariables);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/api/ciderkit.js", (req, res) =>{
|
|
||||||
res.sendFile(join(utils.getPath('srcPath'), "./ciderkit/public.js"));
|
|
||||||
})
|
|
||||||
|
|
||||||
app.post("/api/musickit/:action", async (req, res) => {
|
|
||||||
const action = req.params.action
|
|
||||||
switch (action) {
|
|
||||||
case "v3":
|
|
||||||
try {
|
|
||||||
const encoded = btoa(JSON.stringify(req.body))
|
|
||||||
console.log(encoded)
|
|
||||||
|
|
||||||
const result = await BrowserWindow.win.webContents.executeJavaScript(`
|
|
||||||
wsapi.v3("${encoded}")
|
|
||||||
`)
|
|
||||||
res.header("Content-Type", "application/json");
|
|
||||||
res.send(result)
|
|
||||||
break;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e)
|
|
||||||
res.send("error")
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
res.send("null")
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
app.get("/api/playback/:action", (req, res) => {
|
app.get("/api/playback/:action", (req, res) => {
|
||||||
const action = req.params.action;
|
const action = req.params.action;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
@ -589,7 +552,7 @@ export class BrowserWindow {
|
||||||
remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
|
remote.use(express.static(join(utils.getPath('srcPath'), "./web-remote/")))
|
||||||
remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
|
remote.set("views", join(utils.getPath('srcPath'), "./web-remote/views"));
|
||||||
remote.set("view engine", "ejs");
|
remote.set("view engine", "ejs");
|
||||||
getPort({ port: 6942 }).then((port) => {
|
getPort({port: 6942}).then((port) => {
|
||||||
this.remotePort = port;
|
this.remotePort = port;
|
||||||
// Start Remote Discovery
|
// Start Remote Discovery
|
||||||
this.broadcastRemote()
|
this.broadcastRemote()
|
||||||
|
@ -652,8 +615,7 @@ export class BrowserWindow {
|
||||||
details.requestHeaders['Accept-Language'] = 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
details.requestHeaders['Accept-Language'] = 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||||
details.requestHeaders['Referer'] = 'https://y.qq.com/',
|
details.requestHeaders['Referer'] = 'https://y.qq.com/',
|
||||||
details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 ('
|
details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X; zh-CN) AppleWebKit/537.51.1 ('
|
||||||
'KHTML, like Gecko) Mobile/17D50 UCBrowser/12.8.2.1268 Mobile AliApp(TUnionSDK/0.1.20.3) '
|
'KHTML, like Gecko) Mobile/17D50 UCBrowser/12.8.2.1268 Mobile AliApp(TUnionSDK/0.1.20.3) '}
|
||||||
}
|
|
||||||
if (details.url.includes("https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg")) {
|
if (details.url.includes("https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg")) {
|
||||||
details.requestHeaders['Accept'] = '*/*',
|
details.requestHeaders['Accept'] = '*/*',
|
||||||
details.requestHeaders['Accept-Encoding'] = 'gzip, deflate, br',
|
details.requestHeaders['Accept-Encoding'] = 'gzip, deflate, br',
|
||||||
|
@ -662,7 +624,7 @@ export class BrowserWindow {
|
||||||
'KHTML, like Gecko) Mobile/17D50 UCBrowser/12.8.2.1268 Mobile AliApp(TUnionSDK/0.1.20.3) '
|
'KHTML, like Gecko) Mobile/17D50 UCBrowser/12.8.2.1268 Mobile AliApp(TUnionSDK/0.1.20.3) '
|
||||||
details.requestHeaders['Referer'] = "https://y.qq.com/portal/player.html"
|
details.requestHeaders['Referer'] = "https://y.qq.com/portal/player.html"
|
||||||
}
|
}
|
||||||
callback({ requestHeaders: details.requestHeaders });
|
callback({requestHeaders: details.requestHeaders});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -701,7 +663,7 @@ export class BrowserWindow {
|
||||||
// remove WidevineCDM from appdata folder
|
// remove WidevineCDM from appdata folder
|
||||||
const widevineCdmPath = join(app.getPath("userData"), "./WidevineCdm");
|
const widevineCdmPath = join(app.getPath("userData"), "./WidevineCdm");
|
||||||
if (existsSync(widevineCdmPath)) {
|
if (existsSync(widevineCdmPath)) {
|
||||||
rmSync(widevineCdmPath, { recursive: true, force: true })
|
rmSync(widevineCdmPath, {recursive: true, force: true})
|
||||||
}
|
}
|
||||||
// reinstall WidevineCDM
|
// reinstall WidevineCDM
|
||||||
app.relaunch()
|
app.relaunch()
|
||||||
|
@ -973,7 +935,7 @@ export class BrowserWindow {
|
||||||
|
|
||||||
//Fullscreen
|
//Fullscreen
|
||||||
ipcMain.on('detachDT', (_event, _) => {
|
ipcMain.on('detachDT', (_event, _) => {
|
||||||
BrowserWindow.win.webContents.openDevTools({ mode: 'detach' });
|
BrowserWindow.win.webContents.openDevTools({mode: 'detach'});
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcMain.handle('relaunchApp', (_event, _) => {
|
ipcMain.handle('relaunchApp', (_event, _) => {
|
||||||
|
@ -1091,7 +1053,7 @@ export class BrowserWindow {
|
||||||
return Math.max(-32768, Math.min(32768, v)); // clamp
|
return Math.max(-32768, Math.min(32768, v)); // clamp
|
||||||
}
|
}
|
||||||
|
|
||||||
function bitratechange(e: any) {
|
function bitratechange(e: any){
|
||||||
var t = e.length;
|
var t = e.length;
|
||||||
let sampleRate = 96.0;
|
let sampleRate = 96.0;
|
||||||
let outputSampleRate = 48.0;
|
let outputSampleRate = 48.0;
|
||||||
|
@ -1287,10 +1249,10 @@ export class BrowserWindow {
|
||||||
// Set window Handler
|
// Set window Handler
|
||||||
BrowserWindow.win.webContents.setWindowOpenHandler((x: any) => {
|
BrowserWindow.win.webContents.setWindowOpenHandler((x: any) => {
|
||||||
if (x.url.includes("apple") || x.url.includes("localhost")) {
|
if (x.url.includes("apple") || x.url.includes("localhost")) {
|
||||||
return { action: "allow" };
|
return {action: "allow"};
|
||||||
}
|
}
|
||||||
shell.openExternal(x.url).catch(console.error);
|
shell.openExternal(x.url).catch(console.error);
|
||||||
return { action: "deny" };
|
return {action: "deny"};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1346,7 +1308,7 @@ export class BrowserWindow {
|
||||||
"CtlN": "Cider",
|
"CtlN": "Cider",
|
||||||
"iV": "196623"
|
"iV": "196623"
|
||||||
};
|
};
|
||||||
let server2 = mdns.createAdvertisement(x, `${await getPort({ port: 3839 })}`, {
|
let server2 = mdns.createAdvertisement(x, `${await getPort({port: 3839})}`, {
|
||||||
name: encoded,
|
name: encoded,
|
||||||
txt: txt_record
|
txt: txt_record
|
||||||
});
|
});
|
||||||
|
|
|
@ -157,10 +157,6 @@ export class wsapi {
|
||||||
this._win.webContents.executeJavaScript(`MusicKit.getInstance().pause()`);
|
this._win.webContents.executeJavaScript(`MusicKit.getInstance().pause()`);
|
||||||
response.message = "Paused";
|
response.message = "Paused";
|
||||||
break;
|
break;
|
||||||
case "playpause":
|
|
||||||
this._win.webContents.executeJavaScript(`MusicKitInterop.playPause()`);
|
|
||||||
response.message = "Play/Pause";
|
|
||||||
break
|
|
||||||
case "play":
|
case "play":
|
||||||
this._win.webContents.executeJavaScript(`MusicKit.getInstance().play()`);
|
this._win.webContents.executeJavaScript(`MusicKit.getInstance().play()`);
|
||||||
response.message = "Playing";
|
response.message = "Playing";
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
const wsapi = {
|
const wsapi = {
|
||||||
cache: {playParams: {id: 0}, status: null, remainingTime: 0},
|
cache: {playParams: {id: 0}, status: null, remainingTime: 0},
|
||||||
playbackCache: {status: null, time: Date.now()},
|
playbackCache: {status: null, time: Date.now()},
|
||||||
async v3(encoded = "") {
|
|
||||||
let decoded = atob(encoded);
|
|
||||||
let json = JSON.parse(decoded);
|
|
||||||
console.log(json)
|
|
||||||
let response = await (await MusicKit.getInstance().api.v3.music(json.route, json.body, json.options))
|
|
||||||
let ret = response.data
|
|
||||||
return JSON.stringify(ret)
|
|
||||||
},
|
|
||||||
search(term, limit) {
|
search(term, limit) {
|
||||||
MusicKit.getInstance().api.search(term, {limit: limit, types: 'songs,artists,albums,playlists'}).then((results)=>{
|
MusicKit.getInstance().api.search(term, {limit: limit, types: 'songs,artists,albums,playlists'}).then((results)=>{
|
||||||
ipcRenderer.send('wsapi-returnSearch', JSON.stringify(results))
|
ipcRenderer.send('wsapi-returnSearch', JSON.stringify(results))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue