better chromecast name

This commit is contained in:
vapormusic 2022-04-01 00:16:00 +07:00
parent d10531c01b
commit 1354db6724

View file

@ -43,7 +43,9 @@ export default class ChromecastPlugin {
browser.on('update', (service: any) => { browser.on('update', (service: any) => {
if (service.addresses && service.fullname && service.fullname.includes('_googlecast._tcp')) { if (service.addresses && service.fullname && service.fullname.includes('_googlecast._tcp')) {
this.ondeviceup(service.addresses[0], service.fullname.substring(0, service.fullname.indexOf("._googlecast")) + " " + (service.type[0].description ?? ""), '', 'googlecast'); let a = service.txt.filter((u: any) => String(u).startsWith('fn='))
let name = (((a[0] ?? "").substring(3)) != "") ? ((a[0] ?? "").substring(3)) : (service.fullname.substring(0, service.fullname.indexOf("._googlecast")) )
this.ondeviceup(service.addresses[0], name+ " (" + (service.type[0]?.description ?? "") + ")" , '', 'googlecast');
} }
}); });
const Client = require('node-ssdp').Client; const Client = require('node-ssdp').Client;