Skip to content

Instantly share code, notes, and snippets.

function getMediaTitle(media) {
let parts = media.Part;
for (let k = 0; k < parts.length; k++) {
if (!parts[k].hasOwnProperty("Stream")) continue;
let streams = parts[k].Stream;
for (let l = 0; l < streams.length; l++) {
if (streams[l].streamType == 1 && streams[l].hasOwnProperty("displayTitle")) {
const format = streams[l].displayTitle.match(".* \\((.*)\\)$");
if (format != null) return format[1] + " " + media.container;
else return media.container;