updated git and svn scripts
[xrzperl.git] / findvideos
blob2850500d64a2b57a965244fe37a3936e2ef8d705
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 my $PROGRAM_DIR = $0;
10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
12 unshift @INC,
13 map "$PROGRAM_DIR$_",qw{modules lib ../modules ..lib};
16 my %OPTS;
17 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man/;
19 if(@ARGV)
21 require Getopt::Long;
22 require MyPlace::Usage;
23 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
24 MyPlace::Usage::Process(\%OPTS,$VERSION);
26 use List::Util qw(shuffle);
28 my @dirs;
29 my @options;
30 while(@ARGV) {
31 $_ = shift @ARGV;
32 if(-d $_) {
33 push @dirs,$_;
35 else {
36 push @options,$_;
37 last;
40 push @options,@ARGV if(@ARGV);
41 my $option = "";
42 $option = join(" ",@options) if(@options);
44 push @dirs,'.' unless(@dirs);
45 my @videos;
46 open FI,'-|','find','-L',@dirs,'-type','f';#,'-printf','%P\n';
47 while(<FI>) {
48 chomp;
49 push @videos,$_ if(/\.(?:rmvb|rm|avi|mkv|asf|3gp|flv|wmv|mp4)$/i);
51 close FI;
52 my $index = 0;
53 @videos = shuffle(@videos);
54 my $count = @videos;
55 foreach(@videos) {
56 $index++;
57 print STDERR ":[$index|$count] $_\n";
58 print $_,"\n";
61 __END__
63 =pod
65 =head1 NAME
67 playvideo - PERL script
69 =head1 SYNOPSIS
71 playvideo [options] ...
73 =head1 OPTIONS
75 =over 12
77 =item B<--version>
79 Print version infomation.
81 =item B<-h>,B<--help>
83 Print a brief help message and exits.
85 =item B<--manual>,B<--man>
87 View application manual
89 =item B<--edit-me>
91 Invoke 'editor' against the source
93 =back
95 =head1 DESCRIPTION
97 ___DESC___
99 =head1 CHANGELOG
101 2010-09-08 duel <duel@myplace.hell>
103 * file created.
105 =head1 AUTHOR
107 duel <duel@myplace.hell>
109 =cut
111 # vim:filetype=perl