---
name: "XMLTV::Grab_XML"
section: "3pm"
platform: "linux"
package: "libxmltv-perl"
version: "1.4.0-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/XMLTV::Grab_XML"
---

# XMLTV::Grab\_XML(3pm)

Perl extension to fetch raw XMLTV data from a site

## NAME

XMLTV::Grab\_XML - Perl extension to fetch raw XMLTV data from a site

## SYNOPSIS

```
    package Grab_XML_rur;
    use base 'XMLTV::Grab_XML';
    sub urls_by_date( $ ) { my $pkg = shift; ... }
    sub country( $ ) { my $pkg = shift; return 'Ruritania' }
    # Maybe override a couple of other methods as described below...
    Grab_XML_rur->go();
```

## DESCRIPTION

This module helps to write grabbers which fetch pages in XMLTV format from some website and output the data.  It is not used for grabbers which scrape human-readable sites.

It consists of several class methods (package methods).  The way to use it is to subclass it and override some of these.

## METHODS

- XMLTV::Grab\_XML-\>**date\_init()**

  Called at the start of the program to set up Date::Manip.  You might want to override this with a method that sets the timezone.

- XMLTV::Grab\_XML-\>**urls\_by\_date()**

  Returns a hash mapping YYYYMMDD dates to a URL where listings for that date can be downloaded.  This method is abstract, you must override it.

  Arguments: the command line options for --config-file and --quiet.

- XMLTV::Grab\_XML-\>xml\_from\_data(data)

  Given page data for a particular day, turn it into XML.  The default implementation just returns the data unchanged, but you might override it if you need to decompress the data or patch it up.

- XMLTV::Grab\_XML-\>**configure()**

  Configure the grabber if needed.  Arguments are --config-file option (or undef) and --quiet flag (or undef).

  This method is not provided in the base class; if you don't provide it then attempts to --configure will give a message that configuration is not necessary.

- XMLTV::Grab\_XML-\>nextday(day)

  Bump a YYYYMMDD date by one.  You probably shouldn't override this.

- XMLTV::Grab\_XML-\>**country()**

  Return the name of the country you're grabbing for, used in usage messages.  Abstract.

- XMLTV::Grab\_XML-\>**usage\_msg()**

  Return a command-line usage message.  This calls `country()`, so you probably need to override only that method.

- XMLTV::Grab\_XML-\>**get()**

  Given a URL, fetch the content at that URL.  The default implementation calls **XMLTV::Get\_nice::get\_nice()** but you might want to override it if you need to do wacky things with http requests, like cookies.

  Note that while this method fetches a page, `xml_from_data()` does any further processing of the result to turn it into XML.

- XMLTV::Grab\_XML-\>**go()**

  The main program.  Parse command line options, fetch and write data.

  Most of the options are fairly self-explanatory but this routine also calls the XMLTV::Memoize module to look for a **--cache** argument. The functions memoized are those given by the `cachables()` method.

- XMLTV::Grab\_XML-\>**cachables()**

  Returns a list of names of functions which could reasonably be memoized between runs.  This will normally be whatever function fetches the web pages - you memoize that to save on repeated downloads.  A subclass might want to add things to this list if it has its own way of fetching web pages.

- XMLTV::Grab\_XML-\>**remove\_early\_stop\_times()**

  Checks each stop time and removes it if it's before the start time.

  Argument: the XML to correct Returns: the corrected XML

## AUTHOR

Ed Avis, ed@membled.com

## SEE ALSO

[**perl**(1)](/perl/1.md), **XMLTV**(3).
