.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Options 3pm" .TH Options 3pm "2012-06-10" "perl v5.14.2" "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" XMLTV::Options \- Command\-line parsing for XMLTV grabbers .SH "DESCRIPTION" .IX Header "DESCRIPTION" Utility library that implements command-line parsing and handles a lot of functionality that is common to all \s-1XMLTV\s0 grabbers. .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" All these functions are exported on demand. .SH "USAGE" .IX Header "USAGE" .IP "\fBParseOptions\fR" 4 .IX Item "ParseOptions" ParseOptions shall be called by a grabber to parse the command-line options supplied by the user. It takes a single hashref as a parameter. The entries in the hash configure the behaviour of ParseOptions. .Sp .Vb 10 \& my( $opt, $conf ) = ParseOptions( { \& grabber_name => \*(Aqtv_grab_test\*(Aq, \& version => \*(Aq$Id: Options.pm,v 1.24 2012/06/10 11:43:56 knowledgejunkie Exp $\*(Aq, \& description => \*(AqSweden (tv.swedb.se)\*(Aq, \& capabilities => [qw/baseline manualconfig apiconfig lineups/], \& stage_sub => \e&config_stage, \& listchannels_sub => \e&list_channels, \& list_lineups_sub => \e&list_lineups, \& get_lineup_sub => \e&get_lineup, \& } ); .Ve .Sp ParseOptions returns two hashrefs: .RS 4 .IP "\(bu" 4 A hashref with the values for all command-line options in the format returned by Getopt::Long (See \*(L"Storing options in a hash\*(R" in Getopt::Long). This includes both options that the grabber must handle as well as options that ParseOptions handles for the grabber. .IP "\(bu" 4 A hashref to the data loaded from the configuration file. See XMLTV::Configure for the format of \f(CW$conf\fR. .RE .RS 4 .Sp ParseOptions handles the following options automatically without returning: .IP "\-\-help" 4 .IX Item "--help" .PD 0 .IP "\-\-capabilities" 4 .IX Item "--capabilities" .IP "\-\-version" 4 .IX Item "--version" .IP "\-\-description" 4 .IX Item "--description" .IP "\-\-preferredmethod" 4 .IX Item "--preferredmethod" .PD Handled automatically if the preferredmethod capability has been set and the preferredmethod option has been specified in the call to ParseOptions. .RE .RS 4 .Sp ParseOptions also takes care of the following options without returning, by calling the stage_sub, listchannels_sub, list_lineups_sub and get_lineup_sub callbacks supplied by the grabber: .IP "\-\-configure" 4 .IX Item "--configure" .PD 0 .IP "\-\-configure\-api" 4 .IX Item "--configure-api" .IP "\-\-stage" 4 .IX Item "--stage" .IP "\-\-list\-channels" 4 .IX Item "--list-channels" .IP "\-\-list\-lineups" 4 .IX Item "--list-lineups" .IP "\-\-get\-lineup" 4 .IX Item "--get-lineup" .RE .RS 4 .PD .Sp ParseOptions will thus only return to the grabber when the grabber shall actually grab data. .Sp If the \-\-output option is specified, \s-1STDOUT\s0 will be redirected to the specified file. .Sp The grabber must check the following options on its own: .IP "\-\-days" 4 .IX Item "--days" .PD 0 .IP "\-\-offset" 4 .IX Item "--offset" .IP "\-\-quiet" 4 .IX Item "--quiet" .IP "\-\-debug" 4 .IX Item "--debug" .RE .RS 4 .PD .Sp and any other options that are grabber specific. This can be done by reading \&\f(CW$opt\fR\->{days} etc. .RE .IP "\fBChanging the behaviour of ParseOptions\fR" 4 .IX Item "Changing the behaviour of ParseOptions" The behaviour of ParseOptions can be influenced by passing named arguments in the hashref. The following arguments are supported: .RS 4 .IP "grabber_name" 4 .IX Item "grabber_name" Required. The name of the grabber (e.g. tv_grab_se_swedb). This is used when printing the synopsis. .IP "description" 4 .IX Item "description" Required. The description for the grabber. This is returned in response to the \-\-description option and shall say which region the grabber returns data for. Examples: \*(L"Sweden\*(R", or \*(L"Sweden (tv.swedb.se)\*(R" if there are several grabbers for a region or country). .IP "version" 4 .IX Item "version" Required. This shall be a cvs Id field. .IP "capabilities" 4 .IX Item "capabilities" Required. The capabilities that the grabber shall support. Only capabilities that XMLTV::Options knows how to handle can be specified. Example: .Sp .Vb 1 \& capabilities => [qw/baseline manualconfig apiconfig/], .Ve .Sp Note that XMLTV::Options guarantees that the grabber supports the manualconfig and apiconfig capabilities. The capabilities share and cache can be specified if the grabber supports them. XMLTV::Options will then automatically accept the command-line parameters \-\-share and \-\-cache respectively. .IP "stage_sub" 4 .IX Item "stage_sub" Required. A coderef that takes a stage-name and a configuration hashref as a parameter and returns an xml-string that describes the configuration necessary for that stage. The xml-string shall follow the xmltv\-configuration.dtd. .IP "listchannels_sub" 4 .IX Item "listchannels_sub" Required. A coderef that takes a configuration hash as returned by XMLTV::Configure::LoadConfig as the first parameter and an option hash as returned by ParseOptions as the second parameter, and returns an xml-string containing a list of all the channels that the grabber can deliver data for using the supplied configuration. Note that the listsub shall not use any channel-configuration from the hashref. .IP "load_old_config_sub" 4 .IX Item "load_old_config_sub" Optional. Default undef. A coderef that takes a filename as a parameter and returns a configuration hash in the same format as returned by XMLTV::Configure::LoadConfig. load_old_config_sub is called if XMLTV::Configure::LoadConfig fails to parse the configuration file. This allows the grabber to load configuration files created with an older version of the grabber. .IP "list_lineups_sub" 4 .IX Item "list_lineups_sub" Optional. A coderef that takes a configuration hash as returned by XMLTV::Configure::LoadConfig as the first parameter and an option hash as returned by ParseOptions as the second parameter, and returns an xml-string containing a list of all the channel lineups that the grabber can deliver data for using the supplied configuration. Note that the listsub shall not use any channel-configuration from the hashref. The xml-string shall follow the xmltv\-lineups.xsd schema. .IP "get_lineup_sub" 4 .IX Item "get_lineup_sub" Optional. A coderef that returns an xml-string describing the configured lineup. The xml-string shall follow the xmltv\-lineups.xsd schema. .IP "preferredmethod" 4 .IX Item "preferredmethod" Optional. A value to return when the grabber is called with the \&\-\-preferredmethod parameter. Example: .Sp .Vb 11 \& my( $opt, $conf ) = ParseOptions( { \& grabber_name => \*(Aqtv_grab_test\*(Aq, \& version => \*(Aq$Id: Options.pm,v 1.24 2012/06/10 11:43:56 knowledgejunkie Exp $\*(Aq, \& description => \*(AqSweden (tv.swedb.se)\*(Aq, \& capabilities => [qw/baseline manualconfig apiconfig preferredmethod/], \& stage_sub => \e&config_stage, \& listchannels_sub => \e&list_channels, \& preferredmethod => \*(Aqallatonce\*(Aq, \& list_lineups_sub => \e&list_lineups, \& get_lineup_sub => \e&get_lineup, \& } ); .Ve .IP "defaults" 4 .IX Item "defaults" Optional. Default {}. A hashref that contains default values for the command-line options. It shall be in the same format as returned by Getopt::Long (See \*(L"Storing options in a hash\*(R" in Getopt::Long). .IP "extra_options" 4 .IX Item "extra_options" Optional. Default []. An arrayref containing option definitions in the format accepted by Getopt::Long. This can be used to support grabber-specific options. The use of grabber-specific options is discouraged. .RE .RS 4 .RE .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2005,2006 Mattias Holmlund. .PP This program is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .PP This program is distributed in the hope that it will be useful, but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of \&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the \&\s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, \s-1MA\s0 02110\-1301, \s-1USA\s0.