line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Entry.pm,v 1.2 2004/03/31 20:28:29 claes Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package WWW::Search::Tv::Sweden::TvDotNu::Entry; |
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
888
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
0
|
|
|
0
|
0
|
|
my ($class, %attr) = @_; |
8
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
9
|
0
|
|
|
|
|
|
bless { |
10
|
|
|
|
|
|
|
description => "", |
11
|
|
|
|
|
|
|
imdb => "", |
12
|
|
|
|
|
|
|
channel => "", |
13
|
|
|
|
|
|
|
showview => "", |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
%attr, |
16
|
|
|
|
|
|
|
}, $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Mutators |
20
|
|
|
|
|
|
|
sub title { |
21
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
22
|
0
|
0
|
|
|
|
|
$self->{title} = shift if @_; |
23
|
0
|
|
|
|
|
|
return $self->{title}; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub channel { |
27
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
28
|
0
|
0
|
|
|
|
|
$self->{channel} = shift if @_; |
29
|
0
|
|
|
|
|
|
return $self->{channel}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub url { |
33
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
34
|
0
|
|
|
|
|
|
return $self->{url}; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub showview { |
38
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
39
|
0
|
0
|
|
|
|
|
$self->{showview} = shift if @_; |
40
|
0
|
|
|
|
|
|
return $self->{showview}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub description { |
44
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
45
|
0
|
0
|
|
|
|
|
$self->{description} = shift if @_; |
46
|
0
|
|
|
|
|
|
return $self->{description}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub imdb { |
50
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
51
|
0
|
0
|
|
|
|
|
$self->{imdb} = shift if @_; |
52
|
0
|
|
|
|
|
|
return $self->{imdb}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# HTML::Parser callbacks |
56
|
|
|
|
|
|
|
sub _entry_start_h { |
57
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return sub { |
60
|
0
|
|
|
0
|
|
|
my ($tagname, $attr) = @_; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if($tagname eq 'a') { |
63
|
0
|
0
|
0
|
|
|
|
if(exists $attr->{href} && $attr->{href} =~ /imdb\.com/) { |
64
|
0
|
|
|
|
|
|
my $imdb = $attr->{href}; |
65
|
0
|
|
|
|
|
|
$imdb =~ s/\n//g; |
66
|
0
|
|
|
|
|
|
$self->imdb($imdb); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _entry_text_h { |
73
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return sub { |
76
|
0
|
|
|
0
|
|
|
my ($text) = @_; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Make text look nicer |
79
|
0
|
|
|
|
|
|
$text =~ s/^\s+//; |
80
|
0
|
|
|
|
|
|
$text =~ s/\n/ /g; |
81
|
0
|
|
|
|
|
|
$text =~ s/\s+$//; |
82
|
0
|
|
|
|
|
|
$text =~ s/\s+/ /; |
83
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if($text =~ /ShowView\s*\|\s*(\d+)\s*\|/i) { # Check for showview |
|
|
0
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->showview($1); |
86
|
|
|
|
|
|
|
} elsif($text =~ /^.vrigt:\s*(.*)$/) { # Check for description |
87
|
0
|
|
|
|
|
|
$self->description($1); |
88
|
|
|
|
|
|
|
} |
89
|
0
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _entry_end_h { |
93
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
0
|
|
|
return sub {}; |
|
0
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# Checkers |
99
|
|
|
|
|
|
|
sub in { |
100
|
0
|
|
|
0
|
0
|
|
my ($self, $start_hour, $start_min, $end_hour, $end_min) = @_; |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
|
my $start_time = ($start_hour * 60) + $start_min; |
103
|
0
|
|
|
|
|
|
my $end_time = ($end_hour * 60) + $end_min; |
104
|
0
|
0
|
|
|
|
|
$end_time += 1440 if $end_time < $start_time; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $entry_start_time = ($self->{start_time}->[0] * 60) + $self->{start_time}->[1]; |
107
|
0
|
0
|
0
|
|
|
|
return 1 if($entry_start_time > $start_time && $entry_start_time < $end_time); |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
0; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# Formating |
113
|
|
|
|
|
|
|
sub start_time { |
114
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
115
|
0
|
|
|
|
|
|
return sprintf("%02d:%02d", $self->{start_time}->[0], $self->{start_time}->[1]); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub end_time { |
119
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
120
|
0
|
|
|
|
|
|
return sprintf("%02d:%02d", $self->{end_time}->[0], $self->{end_time}->[1]); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |