mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
better error handling
This commit is contained in:
parent
452450e451
commit
e81a9b6fe0
|
@ -16,22 +16,27 @@ function main() {
|
|||
return;
|
||||
|
||||
fetch(server + '?_=' + Date.now(), { method: "PUT", body: txt });
|
||||
console.log('[yt-ipr] yeet %d bytes, %s', txt.length, desc);
|
||||
console.log('[yt-pdh] yeet %d bytes, %s', txt.length, desc);
|
||||
sent[mf_url] = 1;
|
||||
}
|
||||
|
||||
function collect() {
|
||||
setTimeout(collect, interval * 1000);
|
||||
try {
|
||||
var pd = document.querySelector('ytd-watch-flexy').playerData,
|
||||
mu = pd.streamingData.dashManifestUrl || pd.streamingData.hlsManifestUrl,
|
||||
desc = pd.videoDetails.videoId + ', ' + pd.videoDetails.title;
|
||||
var pd = document.querySelector('ytd-watch-flexy');
|
||||
if (!pd)
|
||||
return console.log('[yt-pdh] no video found');
|
||||
|
||||
if (mu.length)
|
||||
send(JSON.stringify(pd), mu, desc);
|
||||
pd = pd.playerData;
|
||||
var mu = pd.streamingData.dashManifestUrl || pd.streamingData.hlsManifestUrl;
|
||||
if (!mu || !mu.length)
|
||||
return console.log('[yt-pdh] no manifest found');
|
||||
|
||||
var desc = pd.videoDetails.videoId + ', ' + pd.videoDetails.title;
|
||||
send(JSON.stringify(pd), mu, desc);
|
||||
}
|
||||
catch (ex) {
|
||||
console.log("[yt-ipr]", ex);
|
||||
console.log("[yt-pdh]", ex);
|
||||
}
|
||||
}
|
||||
collect();
|
||||
|
@ -40,4 +45,4 @@ function main() {
|
|||
var scr = document.createElement('script');
|
||||
scr.textContent = '(' + main.toString() + ')();';
|
||||
(document.head || document.getElementsByTagName('head')[0]).appendChild(scr);
|
||||
console.log('[yt-ipr] a');
|
||||
console.log('[yt-pdh] a');
|
||||
|
|
Loading…
Reference in a new issue