Fix bitrate not getting displayed.

This commit is contained in:
Mars Niermann 2023-03-08 09:57:57 +00:00
parent e6d07ed882
commit aa106319c2

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name QuickDelete
// @namespace https://git.m3.fyi/Marsn3/userscripts
// @version 0.2
// @version 0.3
// @author Marsn3
// @match https://media.m3.fyi/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
@ -29,10 +29,6 @@
.then((response) => response.json())
.then((data) => (apiKey = data.AccessToken)); // Store AccessToken
// Button to refresh the metadata of an item
function refreshButton() {
let el = document.createElement("button");
@ -60,9 +56,12 @@
},
});
// Replace empty image with rotating spinner
this.parentElement.firstChild.firstChild.classList.remove("audiotrack")
this.parentElement.firstChild.firstChild.classList.add("sync", "rotating")
var style = document.createElement('style');
this.parentElement.firstChild.firstChild.classList.remove("audiotrack");
this.parentElement.firstChild.firstChild.classList.add(
"sync",
"rotating"
);
var style = document.createElement("style");
style.innerHTML = `
.rotating {
animation: rotate 1s infinite;
@ -92,7 +91,7 @@
// Bind get function
el.onclick = function () {
let bitrate;
var bitrate = 0;
let url = `${window.origin}/Users/${userid}/Items/${this.parentElement.dataset.id}`;
console.log(`Fetching ${url}`);
@ -102,11 +101,13 @@
headers: {
"X-Emby-Authorization": `MediaBrowser Client="QuickDelete", Device="Chrome", DeviceId="test", Version="10.8.9", Token="${apiKey}"`,
},
}).then((response) => response.json())
.then((data) => (bitrate = data.MediaSources[0].MediaStreams[0].BitRate.toString().substring(0, 3)));;
console.log(bitrate)
// Remove parent to provide feedback and prevent double deletion
alert(`Bitrate: ${bitrate}`)
})
.then((response) => response.json())
.then((data) =>
alert(
`${data.MediaStreams[0].BitRate.toString().substring(0, 3)}kbps`
)
);
};
//Return complete element
return el;