Skip to content

Instantly share code, notes, and snippets.

@Heath123
Created October 18, 2023 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Heath123/a10470382b369aca64492c4afae70e8c to your computer and use it in GitHub Desktop.
Save Heath123/a10470382b369aca64492c4afae70e8c to your computer and use it in GitHub Desktop.
Panopto downloader (messy code but it works)
(async () => {
async function fetchDeliveryInfo(deliveryId, tid, invocationId, options) {
if ((!window.location.href.includes("/Pages/")) || (!deliveryId)) {
alert("Not a Panopto page!");
throw new Error("Not a Panopto page!");
}
const url = window.location.href.split("/Pages/")[0] + '/Pages/Viewer/DeliveryInfo.aspx';
const params = new URLSearchParams();
if (deliveryId !== undefined) {
params.append('deliveryId', deliveryId);
}
if (tid !== undefined) {
params.append('tid', tid);
}
if (invocationId !== undefined) {
params.append('invocationId', invocationId);
}
params.append('isLiveNotes', (!!options.isLiveNotes).toString());
params.append('refreshAuthCookie', (!!options.refreshAuthCookie).toString());
params.append('isActiveBroadcast', (!!options.isActiveBroadcast).toString());
params.append('isEditing', (!!options.isEditing).toString());
params.append('isKollectiveAgentInstalled', (!!options.isKollectiveAgentInstalled).toString());
params.append('isEmbed', (!!options.isEmbed).toString());
params.append('responseType', 'json');
const requestInit = {
method: "POST",
headers: {}
};
requestInit.body = params;
const response = await fetch(url, requestInit);
if (response.status === 200) {
const responseData = await response.json();
if (responseData.ErrorCode) {
throw responseData;
}
return responseData;
} else {
throw response;
}
}
const url2 = (await fetchDeliveryInfo((new URLSearchParams(window.location.search)).get("id"), undefined, undefined, { isLiveNotes: false, refreshAuthCookie: true, isActiveBroadcast: false, isEditing: false, isKollectiveAgentInstalled: false, isEmbed: false })).Delivery.PodcastStreams[0].StreamUrl;
const div = document.createElement("div");
div.id = "dlOverlay";
div.innerHTML = `<div style="position: fixed;top: 0;left: 0;height: 100vh;width: 100vw;background: rgba(0, 0, 0, 0.75);backdrop-filter: blur(10px);z-index: 9999999;display: flex;justify-content: center;align-items: center;"><a href="${url2}" target="_blank" onclick="document.getElementById('dlOverlay').remove()"><button style="font-size: 200%;border: none;border-radius: 15px;padding: 10px;">Click to download video in new tab</button></a></div>`;
document.body.appendChild(div);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment