Listing data is transfered between modules as an ordered set of five-tuples, in the following format:
[channel] | [start time] | [end time] | [title] | [description] |
Time values are on the form YYYYMMDDHHMMSS TIMEZONE
.
Example:
TV3 | 20030503182500 CEST | 20030503185000 CEST | Simpsons | Amerikansk tecknad komediserie.[9782262] |
It is not unusual that shows lack a description, so the case when description is undefined must be handled by the applications involved.
If you are going to develop stuff in the Televinken framework, it might be useful to know what files are involved where. In the following figure, the components to the left of the dashed line represents the programs you execute. The others are part of the "inner workings" of Televinken.
The import utility, fetch_listings.pl
will ask every
import module it knows about what channels it knows about, and import
those. Overlaps (for example both svt.pm and dagenstv.pm knows how to
fetch SVT1) are dealt with by just accepting the first successful
import. If an import fails, the next one that knows about the channel
we are trying to fetch will be asked.
When done, fetch_listings.pl
will write the listing to
storage via listing_storage.pm
. This is actually just a
wrapper around one or more of the storage modules. This approach has
two advantages I can think of; First, I don't have to rewrite every
cgi script if I should want to change storage system. Secondly, I can
use several storage modules for different purposes. The default
configuration is to use the flat_file.pm
storage module
for storing and fetching, but also use xmltv.pm
for just
storage.
That should have explained fetch_listings.pl
and
listing_storage.pm
, and to some extent
import_modules/*
and storage_modules/*
. What
else is hidden in the tarball?
*.cgi
tvdiv.pm
tvinst.pm
fetch_listings.pl
talks to the import modules, in the
cleverly named directory import_modules/
.
Each import module implements the following:
new
channels
source($channel)
fetchchannel($channel)
When I started gathering listings for several days ahead, some
changes where made. Each module that knows how to get listings for
several day must have a sub named multiple_dates
, and
fetchchannel
is then fetchchannel($channel,
$date)
(with $date
on the form YYYY-MM-DD).
If you want to create your own import module, I recommend using one of
the current as a skeleton. A usually start with
import_modules/tv4.pm
when I write a new one. I usually
go through these steps:
$host
,$importid
etc. with more
suitable data.get_webpage($host,$port,$doc)
. Terribly
uneffective memory-wise, but it seems to work in real life. Then, I
do the following:
<B>18:30</B>
) and replace it with a
linefeed, the time and some kind of separator.remove_overlap
can be useful, some
sources has overlapping shows.
So far, only one source use HTTP POST instead of HTTP GET. Check
import_modules/eskilstunakuriren.pm
if you need an
example.
All scripts will talk to listing_storage.pm
, which is a
wrapper for one or more storage modules. These modules implement the
following:
new
store_sources
fetch_sources
store
fetch