line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::GData::YouTube::Feed::PlaylistLink; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
18
|
use WebService::GData 'private'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
19
|
|
4
|
2
|
|
|
2
|
|
11
|
use base 'WebService::GData::Feed::Entry'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1307
|
|
5
|
2
|
|
|
2
|
|
11
|
use WebService::GData::Constants qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
962
|
|
6
|
2
|
|
|
2
|
|
14
|
use WebService::GData::YouTube::Constants qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
499
|
|
7
|
2
|
|
|
2
|
|
12
|
use WebService::GData::YouTube::StagingServer (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
36
|
|
8
|
2
|
|
|
2
|
|
10
|
use WebService::GData::Node::Atom::Category(); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
26
|
|
9
|
2
|
|
|
2
|
|
21
|
use WebService::GData::Collection(); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1874
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.01_03; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $PROJECTION = WebService::GData::YouTube::Constants::PROJECTION; |
14
|
|
|
|
|
|
|
our $BASE = WebService::GData::YouTube::Constants::BASE_URI; |
15
|
|
|
|
|
|
|
if(WebService::GData::YouTube::StagingServer->is_on){ |
16
|
|
|
|
|
|
|
$BASE = STAGING_BASE_URI; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
our $PLAYLISTS_URI = $BASE . $PROJECTION . '/users/default/playlists/'; |
19
|
|
|
|
|
|
|
#####READ############## |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub __init { |
22
|
0
|
|
|
0
|
|
|
my ( $this, $feed, $req ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
return $this->SUPER::__init( $feed, $req ) if ref $feed eq 'HASH'; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
$this->SUPER::__init( {}, $feed ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub count_hint { |
31
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
32
|
0
|
|
|
|
|
|
$this->{_feed}->{'yt$countHint'}->{'$t'}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub playlist_id { |
36
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
37
|
0
|
0
|
|
|
|
|
if ( @_ == 1 ) { |
38
|
0
|
|
|
|
|
|
$this->{_feed}->{'yt$playlistId'}->{'$t'} = $_[0]; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
$this->{_feed}->{'yt$playlistId'}->{'$t'}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub is_private { |
44
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
0
|
|
|
|
if ( exists $this->{_feed}->{'yt$private'} || ( @_ == 1 && !$this->{_private} ) ) { |
|
|
|
0
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$this->{_private} = new WebService::GData::YouTube::YT::Private(); |
48
|
0
|
|
|
|
|
|
$this->_entity->child( $this->{_private} ); |
49
|
0
|
|
|
|
|
|
delete $this->{_feed}->{'yt$private'}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
return ( exists $this->{_private} ) ? 1 : 0; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
private urldecode => sub { |
58
|
|
|
|
|
|
|
my ($string) = shift; |
59
|
|
|
|
|
|
|
$string =~ tr/+/ /; |
60
|
|
|
|
|
|
|
$string =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; |
61
|
|
|
|
|
|
|
return $string; |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub keywords { |
65
|
0
|
|
|
0
|
1
|
|
my ( $this, $keywords ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
|
if ($keywords) { |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#reset tags |
70
|
0
|
|
|
|
|
|
my $old = $this->{_category}; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$this->{_category} = new WebService::GData::Collection(); |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$this->_entity->swap( $old,$this->{_category}); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
my @tags = split( /,/, $keywords ); |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
foreach (@tags) { |
79
|
0
|
|
|
|
|
|
push @{ $this->category }, |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
new WebService::GData::Node::Atom::Category( |
81
|
|
|
|
|
|
|
term => $_, |
82
|
|
|
|
|
|
|
scheme => 'http://gdata.youtube.com/schemas/2007/tags.cat' |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @terms; |
88
|
0
|
|
|
|
|
|
push @terms, urldecode( $_->term ) |
89
|
0
|
|
|
|
|
|
foreach ( @{ $this->category->scheme('tags.cat') } ); |
90
|
0
|
|
|
|
|
|
return join ',', @terms; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
#####WRITE########### |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub delete { |
96
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
97
|
0
|
|
|
|
|
|
$this->{_request}->delete( $PLAYLISTS_URI . $this->playlist_id ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub save { |
101
|
0
|
|
|
0
|
1
|
|
my $this = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
my $content = XML_HEADER . $this->serialize; |
104
|
0
|
|
|
|
|
|
my $ret; |
105
|
0
|
0
|
|
|
|
|
if ( $this->playlist_id ) { |
106
|
0
|
|
0
|
|
|
|
$ret = |
107
|
|
|
|
|
|
|
$this->{_request}->update( $this->get_link('edit') |
108
|
|
|
|
|
|
|
|| $PLAYLISTS_URI . $this->playlist_id, $content ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
else { |
111
|
0
|
|
|
|
|
|
$ret = $this->{_request}->insert( $PLAYLISTS_URI, $content ); |
112
|
|
|
|
|
|
|
} |
113
|
0
|
|
|
|
|
|
return $ret; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub add_video { |
117
|
0
|
|
|
0
|
1
|
|
my ($this,$video_id) = @_; |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
$this->id($video_id); |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $content = XML_HEADER. $this->serialize; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
return $this->{_request}->insert('http://gdata.youtube.com/feeds/api/playlists/'.$this->playlist_id,$content); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#sub delete_video { |
128
|
|
|
|
|
|
|
# my ($this,%params) = @_; |
129
|
|
|
|
|
|
|
# if($params{videoId}) { |
130
|
|
|
|
|
|
|
# $params{playListVideoId}=$this->_find_playlist_video_id($params{videoId}); |
131
|
|
|
|
|
|
|
# } |
132
|
|
|
|
|
|
|
# $this ->{_request}->delete('http://gdata.youtube.com/feeds/api/playlists/'.$this->playlistId.'/'.$params{playListVideoId},0); |
133
|
|
|
|
|
|
|
#} |
134
|
|
|
|
|
|
|
# sub set_video_position { |
135
|
|
|
|
|
|
|
# my ($this,%params) = @_; |
136
|
|
|
|
|
|
|
# if($params{videoId}) { |
137
|
|
|
|
|
|
|
# $params{playListVideoId}=$this->_find_playlist_video_id($params{videoId}); |
138
|
|
|
|
|
|
|
# } |
139
|
|
|
|
|
|
|
# $this->{_request}->update('http://gdata.youtube.com/feeds/api/playlists/'.$this->playlistId.'/'.$params{playListVideoId},"$params{position}"); |
140
|
|
|
|
|
|
|
# } |
141
|
|
|
|
|
|
|
# sub _find_playlist_video_id { |
142
|
|
|
|
|
|
|
# my ($this,$videoid) = @_; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# my $id=""; |
145
|
|
|
|
|
|
|
# if(!$this->{videosInPlaylist}){ |
146
|
|
|
|
|
|
|
# $this->get_videos; |
147
|
|
|
|
|
|
|
# } |
148
|
|
|
|
|
|
|
# foreach my $vid (@{$this->{videosInPlaylist}}){ |
149
|
|
|
|
|
|
|
# if($vid->videoId eq $videoid){ |
150
|
|
|
|
|
|
|
# $id= (split(':',$vid->id))[-1]; |
151
|
|
|
|
|
|
|
# } |
152
|
|
|
|
|
|
|
# } |
153
|
|
|
|
|
|
|
# return $id; |
154
|
|
|
|
|
|
|
# } |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
"The earth is blue like an orange."; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |