From 934fd7f7c56cb22173d32dcd7ffb1389cddd2011 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 3 Sep 2022 17:13:08 -0400 Subject: initial commit --- bin/webx_type | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 bin/webx_type (limited to 'bin') diff --git a/bin/webx_type b/bin/webx_type new file mode 100755 index 0000000..88c6f93 --- /dev/null +++ b/bin/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"; + } +} -- cgit v1.2.3