1 # -*- coding: ascii -*-
2 ###########################################################################
3 # clive, command line video extraction utility.
5 # Copyright 2009 Toni Gundogdu.
7 # This file is part of clive.
9 # clive is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU General Public License as published by the Free
11 # Software Foundation, either version 3 of the License, or (at your option)
14 # clive is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 # You should have received a copy of the GNU General Public License along
20 # with this program. If not, see <http://www.gnu.org/licenses/>.
21 ###########################################################################
27 eval("use Term::ReadKey");
28 my $TermReadKey = int( !$@
);
30 use clive
::Error
qw(CLIVE_REGEXP);
32 use constant DEFAULT_TERM_WIDTH
=> 80;
33 use constant MBDIV
=> 0x100000;
36 return DEFAULT_TERM_WIDTH
38 my ($width) = Term
::ReadKey
::GetTerminalSize
();
44 return $bytes / MBDIV
;
57 $str = sprintf( "%02ds", $secs );
59 elsif ( $secs < 100 * 60 ) {
60 $str = sprintf( "%02dm%02ds", $secs / 60, $secs % 60 );
62 elsif ( $secs < 48 * 3600 ) {
63 $str = sprintf( "%02dh%02dm", $secs / 3600, ( $secs / 60 ) % 60 );
65 elsif ( $secs < 100 * 86400 ) {
66 $str = sprintf( "%dd%02dh", $secs / 86400, ( $secs / 3600 ) % 60 );
69 $str = sprintf( "%dd", $secs / 86400 );
77 if ($rate >= 1024*1024*1024) {
78 $rate /= 1024*1024*1024;
81 elsif ($rate >= 1024*1024) {
91 my ( $regexps, $results, $content ) = @_;
92 while ( my ( $key, $re ) = each( %{$regexps} ) ) {
93 $$results->{$key} = $1 if $$content =~ /$re/;
94 if ( !$$results->{$key} ) {
95 clive
::Log
->instance->err( CLIVE_REGEXP
, "no match: `$re'" );
105 my ( $scheme, $authority, $path, $query, $fragment )
107 =~ m{(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?}o;
109 return split( /\./, $authority );
114 chomp( my $ln = <STDIN
> );
132 while ( my ( $from, $to ) = each(%conv_table) ) {
133 $str =~ s/$from/$to/g;
140 # While all the women came and went.