Update script to include regular expression and display bitrate with media name in alert

This commit is contained in:
Mars Niermann 2023-03-08 12:02:25 +00:00
parent 2b00d8b546
commit 20d0d9af5c

View file

@ -18,6 +18,7 @@
const password = "absw3712mcS"; const password = "absw3712mcS";
const userid = "e55a6ca076a14cb5a6ca9cfaa75498c1"; const userid = "e55a6ca076a14cb5a6ca9cfaa75498c1";
const baseURL = window.origin; const baseURL = window.origin;
const re = /\[(.*)\]/;
var apiKey = "38346c399d57454da3bdbf47ba716765"; var apiKey = "38346c399d57454da3bdbf47ba716765";
// Authorize user // Authorize user
@ -94,7 +95,6 @@
// Bind get function // Bind get function
el.onclick = function () { el.onclick = function () {
var bitrate = 0;
let url = `${window.origin}/Users/${userid}/Items/${this.parentElement.dataset.id}`; let url = `${window.origin}/Users/${userid}/Items/${this.parentElement.dataset.id}`;
console.log(`Fetching ${url}`); console.log(`Fetching ${url}`);
@ -108,8 +108,10 @@
.then((response) => response.json()) .then((response) => response.json())
.then((data) => .then((data) =>
// Display bitrate // Display bitrate
alert( alert(
`${data.MediaStreams[0].BitRate.toString().substring(0, 4)}kbps | ${data.MediaStreams[0].BitRate.toString().length}` `${data.MediaStreams[0].BitRate.toString().substring(0, 4)}kbps | ${data.MediaStreams[0].BitRate.toString().length} | ${re.exec(data.Path)[1]
}`
) )
); );
}; };