| 1 | #ABSTRACT: XML Sitemap Google extension video entry | ||||||||||||||||||||||||||||
| 2 | 22 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 22 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | package WWW::Sitemap::XML::Google::Video; | ||||||||||||||||||||||||||||
| 5 | BEGIN { | ||||||||||||||||||||||||||||
| 6 | 22 | ▶ | $WWW::Sitemap::XML::Google::Video::AUTHORITY = 'cpan:AJGB'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||
| 8 | 22 | $WWW::Sitemap::XML::Google::Video::VERSION = '2.01'; | |||||||||||||||||||||||||||
| 9 | 22 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 22 | ▶ | use WWW::Sitemap::XML::Types qw( Location VideoPlayer Max100CharsStr Max2048CharsStr ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 22 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 22 | has 'content_loc' => ( | |||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => Location, | ||||||||||||||||||||||||||||
| 18 | coerce => 1, | ||||||||||||||||||||||||||||
| 19 | predicate => 'has_content_loc', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 22 | has 'player' => ( | |||||||||||||||||||||||||||
| 24 | is => 'rw', | ||||||||||||||||||||||||||||
| 25 | isa => VideoPlayer, | ||||||||||||||||||||||||||||
| 26 | required => 0, | ||||||||||||||||||||||||||||
| 27 | coerce => 1, | ||||||||||||||||||||||||||||
| 28 | predicate => 'has_player', | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 22 | has 'title' => ( | |||||||||||||||||||||||||||
| 33 | is => 'rw', | ||||||||||||||||||||||||||||
| 34 | isa => Max100CharsStr, | ||||||||||||||||||||||||||||
| 35 | required => 1, | ||||||||||||||||||||||||||||
| 36 | predicate => 'has_title', | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 22 | has 'description' => ( | |||||||||||||||||||||||||||
| 41 | is => 'rw', | ||||||||||||||||||||||||||||
| 42 | isa => Max2048CharsStr, | ||||||||||||||||||||||||||||
| 43 | required => 1, | ||||||||||||||||||||||||||||
| 44 | predicate => 'has_description', | ||||||||||||||||||||||||||||
| 45 | ); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 22 | has 'thumbnail_loc' => ( | |||||||||||||||||||||||||||
| 49 | is => 'rw', | ||||||||||||||||||||||||||||
| 50 | isa => Location, | ||||||||||||||||||||||||||||
| 51 | required => 1, | ||||||||||||||||||||||||||||
| 52 | predicate => 'has_thumbnail_loc', | ||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | sub as_xml { | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
as_xml: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 0 | my $video = XML::LibXML::Element->new('video:video'); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | do { | ||||||||||||||||||||||||||||
| 62 | 0 | my $name = $_; | |||||||||||||||||||||||||||
| 63 | 0 | my $e = XML::LibXML::Element->new("video:$name"); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | $e->appendText( $self->$name ); | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | $video->appendChild( $e ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | } for 'content_loc',grep { | |||||||||||||||||||||||||||
| 70 | 0 | ▶ | eval('$self->has_'.$_) || defined $self->$_() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | } qw( title description thumbnail_loc ); | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ( $self->has_player) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $video->appendChild( $self->player->as_xml ); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | return $video; | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | around BUILDARGS => sub { | ||||||||||||||||||||||||||||
| 81 | 4 | ▶ | my $next = shift; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||
| 82 | 4 | my $class = shift; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 4 | ▶ | if ( @_ == 1 && ! ref $_[0] ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not ref $_[0]
MC/DC0%0/2
@_ == 1 and not ref $_[0]
@_ == 1
not ref $_[0]
Truth table33%1/3
A and not(B)
A= @_ == 1B= not ref $_[0]
| |||||||||||||||||||||||||||||
| 85 | 0 | return $class->$next(loc => $_[0]); | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 4 | return $class->$next( @_ ); | |||||||||||||||||||||||||||
| 89 | 22 | }; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 22 | with 'WWW::Sitemap::XML::Google::Video::Interface'; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 22 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 22 | 1; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | __END__ | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =pod | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 NAME | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | WWW::Sitemap::XML::Google::Video - XML Sitemap Google extension video entry | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 VERSION | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | version 2.01 | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | my $video = WWW::Sitemap::XML::Google::Video->new( | ||||||||||||||||||||||||||||
| 115 | content_loc => 'http://mywebsite.com/video1.flv', | ||||||||||||||||||||||||||||
| 116 | player => { | ||||||||||||||||||||||||||||
| 117 | loc => 'http://mywebsite.com/video_player.swf?video=1', | ||||||||||||||||||||||||||||
| 118 | allow_embed => "yes", | ||||||||||||||||||||||||||||
| 119 | autoplay => "ap=1", | ||||||||||||||||||||||||||||
| 120 | }, | ||||||||||||||||||||||||||||
| 121 | thumbnail_loc => 'http://mywebsite.com/thumbs/1.jpg', | ||||||||||||||||||||||||||||
| 122 | title => 'Video Title 1', | ||||||||||||||||||||||||||||
| 123 | description => 'Video Description 1', | ||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | XML output: | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | <?xml version="1.0" encoding="UTF-8"?> | ||||||||||||||||||||||||||||
| 129 | <video:video> | ||||||||||||||||||||||||||||
| 130 | <video:content_loc>http://mywebsite.com/video1.flv</video:content_loc> | ||||||||||||||||||||||||||||
| 131 | <video:title>Video Title 1</video:title> | ||||||||||||||||||||||||||||
| 132 | <video:description>Video Description 1</video:description> | ||||||||||||||||||||||||||||
| 133 | <video:thumbnail_loc>http://mywebsite.com/thumbs/1.jpg</video:thumbnail_loc> | ||||||||||||||||||||||||||||
| 134 | <video:player_loc allow_embed="yes" autoplay="ap=1">http://mywebsite.com/video_player.swf?video=1</video:player_loc> | ||||||||||||||||||||||||||||
| 135 | </video:video> | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | WWW::Sitemap::XML::Google::Video represents single video entry in sitemap file. | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Class implements L<WWW::Sitemap::XML::Google::Video::Interface>. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =head2 content_loc | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | At least one of L<"player"> and L<"content_loc"> is required. | ||||||||||||||||||||||||||||
| 148 | This should be a I<.mpg>, I<.mpeg>, I<.mp4>, I<.m4v>, I<.mov>, I<.wmv>, I<.asf>, I<.avi>, I<.ra>, I<.ram>, I<.rm>, I<.flv>, | ||||||||||||||||||||||||||||
| 149 | or other video file format, and can be omitted if L<"player"> is specified. However, because Google | ||||||||||||||||||||||||||||
| 150 | needs to be able to check that the Flash object is actually a player for video (as opposed to some other use of Flash, e.g. games and | ||||||||||||||||||||||||||||
| 151 | animations), it's helpful to provide both. | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | isa: L<WWW::Sitemap::XML::Types/"Location"> | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head2 player | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | $video->player({ | ||||||||||||||||||||||||||||
| 158 | loc => 'http://mywebsite.com/video_player.swf?video=1', | ||||||||||||||||||||||||||||
| 159 | allow_embed => "yes", | ||||||||||||||||||||||||||||
| 160 | autoplay => "ap=1", | ||||||||||||||||||||||||||||
| 161 | }); | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | At least one of L<"player"> and L<"content_loc"> is required. | ||||||||||||||||||||||||||||
| 164 | A URL pointing to a Flash player for a specific video. In general, | ||||||||||||||||||||||||||||
| 165 | this is the information in the src element of an <embed> tag | ||||||||||||||||||||||||||||
| 166 | and should not be the same as the content of the <loc> tag. | ||||||||||||||||||||||||||||
| 167 | Since each video is uniquely identified by its content URL (the | ||||||||||||||||||||||||||||
| 168 | location of the actual video file) or, if a content URL is not | ||||||||||||||||||||||||||||
| 169 | present, a player URL (a URL pointing to a player for the video), | ||||||||||||||||||||||||||||
| 170 | you must include either the L<"player_loc"> or | ||||||||||||||||||||||||||||
| 171 | L<"content_loc"> tags. If these tags are omitted and we | ||||||||||||||||||||||||||||
| 172 | can't find this information, we'll be unable to index your video. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | isa: L<WWW::Sitemap::XML::Types/"VideoPlayer"> | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =head2 title | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | The title of the video. | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | isa: L<WWW::Sitemap::XML::Types/"Max100CharsStr"> | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | Required. | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | =head2 description | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | The description of the video. | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | isa: L<WWW::Sitemap::XML::Types/"Max2048CharsStr"> | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | Required. | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head2 thumbnail_loc | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | A URL pointing to the URL for the video thumbnail image file. We can | ||||||||||||||||||||||||||||
| 195 | accept most image sizes/types but recommend your thumbnails are at | ||||||||||||||||||||||||||||
| 196 | least 120x90 pixels in .jpg, .png, or. gif formats. | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | isa: L<WWW::Sitemap::XML::Types/"Location"> | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | Required. | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | =head1 METHODS | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | =head2 as_xml | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | Returns L<XML::LibXML::Element> object representing the C<E<lt>video:videoE<gt>> entry in the sitemap. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | L<https://support.google.com/webmasters/answer/183668> | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | Alex J. G. Burzyński <ajgb@cpan.org> | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | This software is copyright (c) 2014 by Alex J. G. Burzyński <ajgb@cpan.org>. | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 221 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | =cut | ||||||||||||||||||||||||||||