Changeset 186

Show
Ignore:
Timestamp:
11/06/06 18:00:30 (7 years ago)
Author:
max
Message:

Tidied options handling.

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • grabbers/rex

    r106 r186  
    33# "Rex" 
    44 
    5 my $version  = '3.3.5'; 
     5my $version  = '3.3.6'; 
    66 
    77# An Australian TV Guide Grabber (a.k.a. tv_grab_au) 
     
    5454# 2.5.0   : Feature: altered/added --ignore-cache, --nowrite-cache, and 
    5555#                    --rebuild-cache options; exit on unknown option 
    56 # 3.0.0   : Shepherd compatibility 
     56# 3.0.0   : Shepherd compliance 
    5757# 3.1.0   : Feature: --ready option 
    5858# 3.2.0   : Feature: gzip compression, report KB downloaded 
     
    6666# 3.3.3   : Bugfix : more regexp tweaking; fixed premiere tag 
    6767# 3.3.4   : Bugfix : tweaked Rex's name in XMLTV output 
     68# 3.3.5   : Bugfix : support opt_channels (HDTV in Shepherd) 
     69# 3.3.6   : Bugfix : neater options parsing 
    6870 
    6971use strict; 
     
    106108my $firstfetch; 
    107109my $debug = 0; 
    108 my $opt; 
     110my $opt = { }; 
    109111my $channels = {}; 
    110112my $opt_channels = {}; 
     
    130132get_command_line_options(); 
    131133 
    132 print "Ignoring --config-file option.\n" if ($opt->{configfile}); 
    133  
    134 exit 0 if ($opt->{ver}) or ($opt->{ready}); 
     134print "Ignoring --config-file option.\n" if ($opt->{'config-file'}); 
     135 
     136exit 0 if ($opt->{version}); 
    135137 
    136138help() if ($opt->{help}); 
     
    148150build_channel_map(); 
    149151 
    150 if ($opt->{show_channels}) 
     152if ($opt->{'show-channels'}) 
    151153{ 
    152154  show_channels(); 
     
    154156} 
    155157 
    156 if ($debug or $opt->{show_config}) 
     158if ($debug or $opt->{'show-config'}) 
    157159{ 
    158160  show_config(); 
    159   exit 0 if ($opt->{show_config}); 
     161  exit 0 if ($opt->{'show-config'}); 
    160162} 
    161163 
     
    465467sub restore_cache 
    466468{ 
    467   unless ($opt->{ignore_cache} or $opt->{rebuild_cache}) 
     469  unless ($opt->{'ignore-cache'} or $opt->{'rebuild-cache'}) 
    468470  { 
    469471    if (-r $cache_file) 
     
    902904sub get_command_line_options 
    903905{ 
    904   GetOptions( 'help'            => \$opt->{help}, 
    905               'debug'           => \$debug, 
    906               'days=i'          => \$opt->{days}, 
    907               'offset=i'        => \$opt->{offset}, 
    908               'show-channels'   => \$opt->{show_channels}, 
    909               'output=s'        => \$opt->{output}, 
    910               'rebuild-cache'   => \$opt->{rebuild_cache}, 
    911               'ignore-cache'    => \$opt->{ignore_cache}, 
    912               'nowrite-cache'   => \$opt->{nowrite_cache}, 
    913               'dump-cache'      => \$opt->{dump_cache}, 
    914               'test'            => \$opt->{test}, 
    915               'show-config'     => \$opt->{show_config}, 
    916               'warper'          => \$opt->{warper}, 
    917               'cache-file=s'    => \$cache_file, 
    918               'stats=i'         => \$opt->{stats}, 
    919               'region=i'        => \$opt->{region}, 
    920               'channels_file=s' => \$opt->{channels_file}, 
    921               'version'         => \$opt->{ver}, 
    922               'desc'            => \$opt->{desc}, 
    923               'ready'           => \$opt->{ready}, 
    924               'config-file=s'   => \$opt->{configfile} 
    925              ); 
     906  GetOptions($opt, qw( 
     907                        help 
     908                        debug 
     909                        output=s 
     910                        days=i 
     911                        offset=i 
     912                        region=i 
     913                        show-config 
     914                        show-channels 
     915                        rebuild-cache 
     916                        ignore-cache 
     917                        nowrite-cache 
     918                        dump-cache 
     919                        cache-file=s 
     920                        config-file=s 
     921                        channels_file=s 
     922                        stats=i 
     923                        test 
     924                        desc 
     925                        version 
     926                        warper 
     927                    )); 
     928  $debug = $opt->{debug};    
    926929 
    927930  if (@ARGV) 
     
    944947          "Webwarping : " . is_set($opt->{warper}) . "\n" . 
    945948          "Cache file : $cache_file"; 
    946     print ' (not reading)' if ($opt->{ignore_cache} or $opt->{rebuild_cache}); 
    947     print ' (not updating)' if ($opt->{test} or $opt->{ignore_cache} or $opt->{nowrite_cache}); 
     949    print ' (not reading)' if ($opt->{'ignore-cache'} or $opt->{'rebuild-cache'}); 
     950    print ' (not updating)' if ($opt->{test} or $opt->{'ignore-cache'} or $opt->{'nowrite-cache'}); 
    948951    print "\n" . 
    949952          "Output file: " . ($opt->{output} ? $opt->{output} : "None") . "\n" . 
  • status

    r184 r186  
    22shepherd        shepherd            0.2.32 
    33grabber         yahoo7widget        1.57 
    4 grabber         rex                 3.3.5-r2 
     4grabber         rex                 3.3.6 
    55grabber         abc_website         1.58 
    66grabber         abc2_website        1.58