TVDB: better handling of first run
[nonametv.git] / lib / NonameTV / DataStore / Dummy.pm
blob7a12b6beb4819b386584e11bb916fb1353784f72
1 package NonameTV::DataStore::Dummy;
3 use strict;
5 use Carp;
7 =head1 NAME
9 NonameTV::DataStore::Dummy
11 =head1 DESCRIPTION
13 Dummy-interface to the datastore for NonameTV. Prints debugging
14 information to STDOUT. Does not touch the database for StartBatch,
15 AddProgramme and EndBatch. All other requests are sent to the
16 database unmodified.
18 =cut
20 use base 'NonameTV::DataStore';
22 sub new
24 my $proto = shift;
25 my $class = ref($proto) || $proto;
26 my $self = $class->SUPER::new( @_ );
27 bless ($self, $class);
29 return $self;
32 sub DESTROY
34 my $self = shift;
38 sub StartBatch
40 my( $self, $batchname ) = @_;
42 print "StartBatch $batchname\n";
43 $self->{currbatch} = $batchname;
44 $self->{currbatchname} = $batchname;
45 $self->{last_end} = "1970-01-01 00:00:00";
48 sub EndBatch
50 my( $self, $success ) = @_;
52 print "EndBatch $success\n";
53 delete $self->{currbatch};
56 sub AddProgramme
58 my( $self, $data ) = @_;
60 print "AddProgramme $data->{start_time} $data->{title}\n";
61 print "End: $data->{end_time}\n" if exists( $data->{end_time} );
62 print "Desc: $data->{description}\n" if exists( $data->{description} );
63 print "Episode: $data->{episode}\n" if exists( $data->{episode} );
65 die "You must call StartBatch before AddProgramme"
66 unless exists $self->{currbatch};
68 if( $self->{last_end} gt $data->{start_time} )
70 print STDERR $self->{currbatchname} .
71 " Starttime must be later than or equal to last endtime: " .
72 $self->{last_end} . " -> " . $data->{start_time} . "\n";
73 return;
76 $self->{last_end} = $data->{start_time};
78 if( defined( $data->{end_time} ) )
80 if( $data->{start_time} ge $data->{end_time} )
82 print STDERR $self->{currbatchname} .
83 " Stoptime must be later than starttime: " .
84 $data->{start_time} . " -> " . $data->{end_time} . "\n";
85 return;
87 $self->{last_end} = $data->{end_time};
90 $data->{batch_id} = $self->{currbatch};
92 if( defined( $data->{category} ) )
94 my $cat = join "++", @{$data->{category}};
95 $data->{category} = $cat;
96 print "Category: $data->{category}\n";
98 else
100 delete( $data->{category} );
105 =head1 COPYRIGHT
107 Copyright (C) 2004 Mattias Holmlund.
109 =cut