From 934fd7f7c56cb22173d32dcd7ffb1389cddd2011 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 3 Sep 2022 17:13:08 -0400 Subject: initial commit --- blib/arch/.exists | 0 blib/arch/auto/webx_type/.exists | 0 blib/bin/.exists | 0 blib/lib/.exists | 0 blib/lib/auto/webx_type/.exists | 0 blib/lib/webx_type.pm | 60 ++++++++++++++++++++ blib/man1/.exists | 0 blib/man1/webx_type.1p | 0 blib/man3/.exists | 0 blib/man3/webx_type.3pm | 117 +++++++++++++++++++++++++++++++++++++++ blib/script/.exists | 0 blib/script/webx_type | 60 ++++++++++++++++++++ 12 files changed, 237 insertions(+) create mode 100644 blib/arch/.exists create mode 100644 blib/arch/auto/webx_type/.exists create mode 100644 blib/bin/.exists create mode 100644 blib/lib/.exists create mode 100644 blib/lib/auto/webx_type/.exists create mode 100644 blib/lib/webx_type.pm create mode 100644 blib/man1/.exists create mode 100644 blib/man1/webx_type.1p create mode 100644 blib/man3/.exists create mode 100644 blib/man3/webx_type.3pm create mode 100644 blib/script/.exists create mode 100755 blib/script/webx_type (limited to 'blib') diff --git a/blib/arch/.exists b/blib/arch/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/arch/auto/webx_type/.exists b/blib/arch/auto/webx_type/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/bin/.exists b/blib/bin/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/lib/.exists b/blib/lib/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/lib/auto/webx_type/.exists b/blib/lib/auto/webx_type/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/lib/webx_type.pm b/blib/lib/webx_type.pm new file mode 100644 index 0000000..9d1d6cb --- /dev/null +++ b/blib/lib/webx_type.pm @@ -0,0 +1,60 @@ +package webx_type; + +use 5.010; +use strict; +use warnings; + +=head1 NAME + +webx_type - Tells you some info about webm/webp files. + +=head1 VERSION + +Version 0.01 + +=cut + +our $VERSION = '0.01'; + + +=head1 SYNOPSIS + +$ webx_type + +=head1 USAGE + +webx_type + +Files can be any file and the script will return the bytes it read if it cannot detect using magic bytes in the file header. If it can use the magic bytes, then it tells you what file type it is. + +=head1 RETURNED INFO + +For webm: VP8, VP9, or google/video-file. +For webp: Whether the file is Lossless or not. + +=head1 AUTHOR + +Jake Thoughts, C<< >> + +=head1 BUGS + +Please report any bugs or feature requests to the author. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc webx_type + +=head1 LICENSE AND COPYRIGHT + +This software is Copyright (c) 2022 by Jake Thoughts. + +This is free software, licensed under: + + The GNU General Public License, Version 3, June 2007 + + +=cut + +1; # End of webx_type diff --git a/blib/man1/.exists b/blib/man1/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/man1/webx_type.1p b/blib/man1/webx_type.1p new file mode 100644 index 0000000..e69de29 diff --git a/blib/man3/.exists b/blib/man3/.exists new file mode 100644 index 0000000..e69de29 diff --git a/blib/man3/webx_type.3pm b/blib/man3/webx_type.3pm new file mode 100644 index 0000000..237cd6e --- /dev/null +++ b/blib/man3/webx_type.3pm @@ -0,0 +1,117 @@ +.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +. ds C` +. ds C' +'br\} +.\" +.\" Escape single quotes in literal strings from groff's Unicode transform. +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" +.\" If the F register is >0, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.\" +.\" Avoid warning from groff about undefined register 'F'. +.de IX +.. +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} +. \} +.\} +.rr rF +.\" ======================================================================== +.\" +.IX Title "webx_type 3" +.TH webx_type 3 "2022-09-03" "perl v5.36.0" "User Contributed Perl Documentation" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.if n .ad l +.nh +.SH "NAME" +webx_type \- Tells you some info about webm/webp files. +.SH "VERSION" +.IX Header "VERSION" +Version 0.01 +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +$ webx_type +.SH "USAGE" +.IX Header "USAGE" +webx_type +.PP +Files can be any file and the script will return the bytes it read if it cannot detect using magic bytes in the file header. If it can use the magic bytes, then it tells you what file type it is. +.SH "RETURNED INFO" +.IX Header "RETURNED INFO" +For webm: \s-1VP8, VP9,\s0 or google/video\-file. +For webp: Whether the file is Lossless or not. +.SH "AUTHOR" +.IX Header "AUTHOR" +Jake Thoughts, \f(CW\*(C`\*(C'\fR +.SH "BUGS" +.IX Header "BUGS" +Please report any bugs or feature requests to the author. +.SH "SUPPORT" +.IX Header "SUPPORT" +You can find documentation for this module with the perldoc command. +.PP +.Vb 1 +\& perldoc webx_type +.Ve +.SH "LICENSE AND COPYRIGHT" +.IX Header "LICENSE AND COPYRIGHT" +This software is Copyright (c) 2022 by Jake Thoughts. +.PP +This is free software, licensed under: +.PP +.Vb 1 +\& The GNU General Public License, Version 3, June 2007 +.Ve diff --git a/blib/script/.exists b/blib/script/.exists new file mode 100644 index 0000000..e69de29 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"; + } +} -- cgit v1.2.3