better error handling
This commit is contained in:
parent
452450e451
commit
e81a9b6fe0
@ -16,22 +16,27 @@ function main() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fetch(server + '?_=' + Date.now(), { method: "PUT", body: txt });
|
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;
|
sent[mf_url] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function collect() {
|
function collect() {
|
||||||
setTimeout(collect, interval * 1000);
|
setTimeout(collect, interval * 1000);
|
||||||
try {
|
try {
|
||||||
var pd = document.querySelector('ytd-watch-flexy').playerData,
|
var pd = document.querySelector('ytd-watch-flexy');
|
||||||
mu = pd.streamingData.dashManifestUrl || pd.streamingData.hlsManifestUrl,
|
if (!pd)
|
||||||
desc = pd.videoDetails.videoId + ', ' + pd.videoDetails.title;
|
return console.log('[yt-pdh] no video found');
|
||||||
|
|
||||||
if (mu.length)
|
pd = pd.playerData;
|
||||||
send(JSON.stringify(pd), mu, desc);
|
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) {
|
catch (ex) {
|
||||||
console.log("[yt-ipr]", ex);
|
console.log("[yt-pdh]", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
collect();
|
collect();
|
||||||
@ -40,4 +45,4 @@ function main() {
|
|||||||
var scr = document.createElement('script');
|
var scr = document.createElement('script');
|
||||||
scr.textContent = '(' + main.toString() + ')();';
|
scr.textContent = '(' + main.toString() + ')();';
|
||||||
(document.head || document.getElementsByTagName('head')[0]).appendChild(scr);
|
(document.head || document.getElementsByTagName('head')[0]).appendChild(scr);
|
||||||
console.log('[yt-ipr] a');
|
console.log('[yt-pdh] a');
|
||||||
|
Loading…
Reference in New Issue
Block a user