Skip to content

Commit

Permalink
Merge pull request #377 from rebeccacremona/skip-if-no-video
Browse files Browse the repository at this point in the history
Skip video summary production if yt-dlp fails silently
  • Loading branch information
rebeccacremona authored Nov 4, 2024
2 parents 1209079 + b50e332 commit ce63fc4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Scoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ export class Scoop {

const dlpOptions = [
'--dump-json', // Will return JSON meta data via stdout
'--no-simulate', // Forces download despites `--dump-json`
'--no-simulate', // Forces download despite `--dump-json`
'--no-warnings', // Prevents pollution of stdout
'--no-progress', // (Same as above)
'--write-subs', // Try to pull subs
Expand Down Expand Up @@ -1008,6 +1008,10 @@ export class Scoop {
}
}

if (!metadataParsed.length) {
throw new Error('yt-dlp reported success (returned 0) but produced no metadata.')
}

// Merge parsed metadata into a single JSON string and clean it before saving it
const metadataAsJSON = JSON
.stringify(metadataParsed, null, 2)
Expand All @@ -1028,6 +1032,10 @@ export class Scoop {
//
// Generate summary page
//
if ((videoSaved || metadataSaved || subtitlesSaved) === false) {
this.log.warn('yt-dlp reported success (returned 0), but produced no output.')
return
}
try {
const html = nunjucks.render('video-extracted-summary.njk', {
url: this.url,
Expand Down

0 comments on commit ce63fc4

Please sign in to comment.