obra / Youtube2Webpage

I learn much better from text than from videos
MIT License
763 stars 25 forks source link

Fails when video download is not webm #3

Closed forivall closed 1 year ago

forivall commented 1 year ago

I was using this on a video that downloaded as mkv rather than webm, and it failed. I only vaguely know perl, so my initial solution was

diff --git a/yt-to-webpage.pl b/yt-to-webpage.pl
index b9a918f..ab2edff 100755
--- a/yt-to-webpage.pl
+++ b/yt-to-webpage.pl
@@ -18,7 +18,7 @@ chdir($slug);
 `yt-dlp --write-auto-subs --write-subs "$url"`;
 my $vtt = `ls *.vtt`;
 chomp($vtt);
-my $video_file = `ls *.webm`;
+my $video_file = `ls *.webm` || `ls *.mkv`;
 chomp($video_file);
 open(my $fh, "<", $vtt);
 my $this_start = 0;

although a better solution would be to use the --print option of yt-dlp to output the filename, like

my $video_file = `yt-dlp --write-auto-subs --write-subs "$url" --print filename`;