Add startup, search and play timing marks plus yt-dlp duration logs
This commit is contained in:
@@ -143,6 +143,9 @@ const CHANNEL_LIMIT = 60;
|
||||
function runYtdlp(args, { signal } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(YTDLP, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
||||
const t0 = Date.now();
|
||||
const kind = String(args.find((a) => /^ytsearch|^https?:/.test(String(a))) || args[0] || '')
|
||||
.replace(/^ytsearch\d*:.*/, 'search').replace(/^https?:\/\/[^/]+\/watch.*/, 'video').slice(0, 40);
|
||||
// Kill the download when the requesting client goes away — otherwise an
|
||||
// aborted/retried save leaves yt-dlp running to completion (8 copies of
|
||||
// one video were found pulling in parallel after the client retried).
|
||||
@@ -158,6 +161,7 @@ function runYtdlp(args, { signal } = {}) {
|
||||
child.stderr.on('data', (d) => { err += d; });
|
||||
child.on('error', (e) => reject(new Error('yt-dlp not found: ' + e.message)));
|
||||
child.on('close', (code) => {
|
||||
console.log(`[ytdlp] ${kind} ${Date.now() - t0}ms ${code === 0 ? 'ok' : 'fail'}`);
|
||||
if (code !== 0) reject(new Error(err.trim() || 'yt-dlp exited with code ' + code));
|
||||
else resolve(out);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user