From c32b9b6d7041d303917d63e344f79cdb589be769 Mon Sep 17 00:00:00 2001 From: vapormusic Date: Thu, 1 Sep 2022 12:39:13 +0000 Subject: [PATCH] chore: Prettified Code [ci skip] --- src/main/plugins/chromecast.ts | 56 +++++++++++++++----------------- src/renderer/main/vueapp.js | 59 ++++++++++++++++++---------------- 2 files changed, 57 insertions(+), 58 deletions(-) diff --git a/src/main/plugins/chromecast.ts b/src/main/plugins/chromecast.ts index fa709e06..d140cd84 100644 --- a/src/main/plugins/chromecast.ts +++ b/src/main/plugins/chromecast.ts @@ -2,7 +2,7 @@ import * as electron from "electron"; import * as os from "os"; import { resolve } from "path"; import * as CiderReceiver from "../base/castreceiver"; -const MediaRendererClient = require('upnp-mediarenderer-client') +const MediaRendererClient = require("upnp-mediarenderer-client"); export default class ChromecastPlugin { /** @@ -15,7 +15,6 @@ export default class ChromecastPlugin { private _timer: any; private audioClient = require("castv2-client").Client; private mdns = require("mdns-js"); - private devices: any = []; private castDevices: any = []; @@ -71,15 +70,13 @@ export default class ChromecastPlugin { // actual upnp devices let ssdpBrowser2 = new Client(); - ssdpBrowser2.on('response', (headers: any, statusCode: any, rinfo: any) => { - var location = getLocation(headers); - if (location != null) { - this.getServiceDescription(location, rinfo.address); - } - - }); - ssdpBrowser2.search('urn:schemas-upnp-org:device:MediaRenderer:1'); - + ssdpBrowser2.on("response", (headers: any, statusCode: any, rinfo: any) => { + var location = getLocation(headers); + if (location != null) { + this.getServiceDescription(location, rinfo.address); + } + }); + ssdpBrowser2.search("urn:schemas-upnp-org:device:MediaRenderer:1"); } catch (e) { console.log("Search GC err", e); } @@ -258,25 +255,24 @@ export default class ChromecastPlugin { } else { // upnp devices try { - let client = new MediaRendererClient(UPNPDesc); - const options = { - autoplay: true, - contentType: 'audio/x-wav', - dlnaFeatures: 'DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000', - metadata: { - title: 'Cider', - creator: 'Streaming ...', - type: 'audio', // can be 'video', 'audio' or 'image' - // url: 'http://' + getIp() + ':' + server.address().port + '/', - // 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) { - if (err) throw err; - console.log('playing ...'); - }); - } catch (e) { - } + let client = new MediaRendererClient(UPNPDesc); + const options = { + autoplay: true, + contentType: "audio/x-wav", + dlnaFeatures: "DLNA.ORG_PN=-;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000", + metadata: { + title: "Cider", + creator: "Streaming ...", + type: "audio", // can be 'video', 'audio' or 'image' + // url: 'http://' + getIp() + ':' + server.address().port + '/', + // 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) { + if (err) throw err; + console.log("playing ..."); + }); + } catch (e) {} } } diff --git a/src/renderer/main/vueapp.js b/src/renderer/main/vueapp.js index 175c1f5d..d9aaed7c 100644 --- a/src/renderer/main/vueapp.js +++ b/src/renderer/main/vueapp.js @@ -2002,15 +2002,18 @@ const app = new Vue({ } if (kind.toString().includes("apple-curator")) { kind = "appleCurator"; - app.getTypeFromID("appleCurator", id, false, { - platform: "web", - include: "grouping,playlists", - extend: "editorialArtwork", - "art[url]": "f", - }).then(() => { - kind = "appleCurator"; - window.location.hash = `${kind}/${id}`; - document.querySelector("#app-content").scrollTop = 0}); + app + .getTypeFromID("appleCurator", id, false, { + platform: "web", + include: "grouping,playlists", + extend: "editorialArtwork", + "art[url]": "f", + }) + .then(() => { + kind = "appleCurator"; + window.location.hash = `${kind}/${id}`; + document.querySelector("#app-content").scrollTop = 0; + }); } else if (kind == "editorial-elements" || kind == "editorial-items") { console.debug(item); 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) { try { - if (typeof url == "undefined" || url == "") { - return "./assets/MissingArtwork.svg"; - } - height = parseInt(height * window.devicePixelRatio); - if (width) { - width = parseInt(width * window.devicePixelRatio); - } - let newurl = `${(url ?? "") - .replace("{w}", width ?? height) - .replace("{h}", height) - .replace("{f}", "webp") - .replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`; + if (typeof url == "undefined" || url == "") { + return "./assets/MissingArtwork.svg"; + } + height = parseInt(height * window.devicePixelRatio); + if (width) { + width = parseInt(width * window.devicePixelRatio); + } + let newurl = `${(url ?? "") + .replace("{w}", width ?? height) + .replace("{h}", height) + .replace("{f}", "webp") + .replace("{c}", width === 900 || width === 380 || width === 600 ? "sr" : "cc")}`; - if (newurl.includes("900x516")) { - newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr"); - } - return newurl;} - catch (e) { - console.log(url) - return "./assets/MissingArtwork.svg" + if (newurl.includes("900x516")) { + newurl = newurl.replace("900x516cc", "900x516sr").replace("900x516bb", "900x516sr"); + } + return newurl; + } catch (e) { + console.log(url); + return "./assets/MissingArtwork.svg"; } }, _rgbToRgb(rgb = [0, 0, 0]) {