diff options
Diffstat (limited to 'blib/script')
-rw-r--r-- | blib/script/.exists | 0 | ||||
-rwxr-xr-x | blib/script/webx_type | 60 |
2 files changed, 60 insertions, 0 deletions
diff --git a/blib/script/.exists b/blib/script/.exists new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/blib/script/.exists diff --git a/blib/script/webx_type b/blib/script/webx_type new file mode 100755 index 0000000..88c6f93 --- /dev/null +++ b/blib/script/webx_type @@ -0,0 +1,60 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use 5.010; + +sub checktype_filename { + # reads in 1kb of selected file, or returns undef if can't open, + # then checks contents + + my($filename) = @_; + my $fh = IO::File->new($filename) || return; + my $data; + $fh->sysread($data, 1024); + $fh->close; + return $data; +} + + +sub personal_check { + my ($read) = @_; + if ($read =~ m/V_VP9/) { + return "WebM V9 detected."; + } + elsif ($read =~ m/V_VP8/) { + return "WebM V8 detected."; + } + elsif ($read =~ m/WEBPVP8L/) { + return "WebP V8 (Lossless) detected."; + } + elsif ($read =~ m/WEBPVP8/) { + return "WebP V8 (Not Lossless) detected."; + } + elsif ($read =~ m{google/video-file}) { + # Guess which mime is impossible to find info for? + # I happen to know that iPhone's can't play it. + return "WebM google/video-file."; + } + else { + return; + } +} + +for (my $i = 0; $i < @ARGV; $i++) { + if (! -e $ARGV[$i]) { + warn "$ARGV[$i] doesn't exist or is not a file."; + next; + } + + my $read = checktype_filename($ARGV[$i]). "\n"; + my $matched = personal_check($read); + + if ($matched) { + say "$ARGV[$i]: $matched"; + #say "$matched"; + } + else { + say "$ARGV[$i]: $read"; + } +} |