chore: Prettified Code

[ci skip]
This commit is contained in:
vapormusic 2022-09-01 12:39:13 +00:00 committed by cider-chore[bot]
parent a023bd619c
commit c32b9b6d70
2 changed files with 57 additions and 58 deletions

View file

@ -2,7 +2,7 @@ import * as electron from "electron";
import * as os from "os"; import * as os from "os";
import { resolve } from "path"; import { resolve } from "path";
import * as CiderReceiver from "../base/castreceiver"; import * as CiderReceiver from "../base/castreceiver";
const MediaRendererClient = require('upnp-mediarenderer-client') const MediaRendererClient = require("upnp-mediarenderer-client");
export default class ChromecastPlugin { export default class ChromecastPlugin {
/** /**
@ -15,7 +15,6 @@ export default class ChromecastPlugin {
private _timer: any; private _timer: any;
private audioClient = require("castv2-client").Client; private audioClient = require("castv2-client").Client;
private mdns = require("mdns-js"); private mdns = require("mdns-js");
private devices: any = []; private devices: any = [];
private castDevices: any = []; private castDevices: any = [];
@ -71,15 +70,13 @@ export default class ChromecastPlugin {
// actual upnp devices // actual upnp devices
let ssdpBrowser2 = new Client(); let ssdpBrowser2 = new Client();
ssdpBrowser2.on('response', (headers: any, statusCode: any, rinfo: any) => { ssdpBrowser2.on("response", (headers: any, statusCode: any, rinfo: any) => {
var location = getLocation(headers); var location = getLocation(headers);
if (location != null) { if (location != null) {
this.getServiceDescription(location, rinfo.address); this.getServiceDescription(location, rinfo.address);
} }
});
}); ssdpBrowser2.search("urn:schemas-upnp-org:device:MediaRenderer:1");
ssdpBrowser2.search('urn:schemas-upnp-org:device:MediaRenderer:1');
} catch (e) { } catch (e) {
console.log("Search GC err", e); console.log("Search GC err", e);
} }
@ -258,25 +255,24 @@ export default class ChromecastPlugin {
} else { } else {
// upnp devices // upnp devices
try { try {
let client = new MediaRendererClient(UPNPDesc); let client = new MediaRendererClient(UPNPDesc);
const options = { const options = {
autoplay: true, autoplay: true,
contentType: 'audio/x-wav', contentType: "audio/x-wav",
dlnaFeatures: 'DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000', dlnaFeatures: "DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000",
metadata: { metadata: {
title: 'Cider', title: "Cider",
creator: 'Streaming ...', creator: "Streaming ...",
type: 'audio', // can be 'video', 'audio' or 'image' type: "audio", // can be 'video', 'audio' or 'image'
// url: 'http://' + getIp() + ':' + server.address().port + '/', // url: 'http://' + getIp() + ':' + server.address().port + '/',
// protocolInfo: 'DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000; // protocolInfo: 'DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000;
} },
}; };
client.load('http://' + this.getIp() + ':' + this.ciderPort + '/audio.wav', options, function (err: any, _result: any) { client.load("http://" + this.getIp() + ":" + this.ciderPort + "/audio.wav", options, function (err: any, _result: any) {
if (err) throw err; if (err) throw err;
console.log('playing ...'); console.log("playing ...");
}); });
} catch (e) { } catch (e) {}
}
} }
} }

View file

@ -2002,15 +2002,18 @@ const app = new Vue({
} }
if (kind.toString().includes("apple-curator")) { if (kind.toString().includes("apple-curator")) {
kind = "appleCurator"; kind = "appleCurator";
app.getTypeFromID("appleCurator", id, false, { app
platform: "web", .getTypeFromID("appleCurator", id, false, {
include: "grouping,playlists", platform: "web",
extend: "editorialArtwork", include: "grouping,playlists",
"art[url]": "f", extend: "editorialArtwork",
}).then(() => { "art[url]": "f",
kind = "appleCurator"; })
window.location.hash = `${kind}/${id}`; .then(() => {
document.querySelector("#app-content").scrollTop = 0}); kind = "appleCurator";
window.location.hash = `${kind}/${id}`;
document.querySelector("#app-content").scrollTop = 0;
});
} else if (kind == "editorial-elements" || kind == "editorial-items") { } else if (kind == "editorial-elements" || kind == "editorial-items") {
console.debug(item); console.debug(item);
if (item.relationships?.contents?.data != null && item.relationships?.contents?.data.length > 0) { if (item.relationships?.contents?.data != null && item.relationships?.contents?.data.length > 0) {
@ -4024,26 +4027,26 @@ const app = new Vue({
}, },
getMediaItemArtwork(url, height = 64, width) { getMediaItemArtwork(url, height = 64, width) {
try { try {
if (typeof url == "undefined" || url == "") { if (typeof url == "undefined" || url == "") {
return "./assets/MissingArtwork.svg"; return "./assets/MissingArtwork.svg";
} }
height = parseInt(height * window.devicePixelRatio); height = parseInt(height * window.devicePixelRatio);
if (width) { if (width) {
width = parseInt(width * window.devicePixelRatio); width = parseInt(width * window.devicePixelRatio);
} }
let newurl = `${(url ?? "") let newurl = `${(url ?? "")
.replace("{w}", width ?? height) .replace("{w}", width ?? height)
.replace("{h}", height) .replace("{h}", height)
.replace("{f}", "webp") .replace("{f}", "webp")
.replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`; .replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`;
if (newurl.includes("900x516")) { if (newurl.includes("900x516")) {
newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr"); newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr");
} }
return newurl;} return newurl;
catch (e) { } catch (e) {
console.log(url) console.log(url);
return "./assets/MissingArtwork.svg" return "./assets/MissingArtwork.svg";
} }
}, },
_rgbToRgb(rgb = [0, 0, 0]) { _rgbToRgb(rgb = [0, 0, 0]) {