Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
So you're using which returns a WebService::GData::YouTube::Feed::Video which says in SYNOPSIS to use
foreach my $video (@$videos) { say $video->video_id; say $video->title; say $video->content; say $video->view_count; say $video->favorite_count; say $video->duration; }
You're after thumbnails and there is a

A grep thumbnails returns

lib/WebService/GData/YouTube/Doc/GeneralOverview.pod 254: my $thumbs =$video->thumbnails; lib/WebService/GData/YouTube/Feed/ 158:sub thumbnails { 633:=head3 thumbnails t/56-WebService-GData-YouTube-Feed-Video-instance.t 91:ok( @{ $entry->thumbnails } == 5, 'number of thumbnails is right.' +); 93:ok($entry->thumbnails->[0]->url eq ' +LE/default.jpg','thumbnail is properly set.');

So thumbnails returns a list, and there is an example of usage in WebService::GData::YouTube::Doc::GeneralOverview , a sub display_video which contains

my $thumbs =$video->thumbnails; foreach my $thumb (@$thumbs) { say $thumb->url; say $thumb->time; say $thumb->width; say $thumb->height; }

So there you go

#!/usr/bin/perl -- use strict; use warnings; use feature qw/ say /; use Carp::Always; use WebService::GData::YouTube; use WebService::GData::Error; ## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr +-ce -nibc -i=4 -pt=0 "-nsak=*" Main( @ARGV ); exit( 0 ); sub Main { my $query = shift or die qq{\nUsage: $0 "Robert Palmer"\n\n}; my $yt = WebService::GData::YouTube->new(); $yt->query()->q( $query )->limit( 10, 2 ); $yt->query()->maxresults( 20 ); my $videos = $yt->search_video(); display_videos( $videos ); } sub display_videos { my $videos = shift; foreach my $video ( @$videos ) { display_video( $video, 'justthumbs' ); } } sub display_video { my $video = shift; my $justthumbs = shift; say 'Video Id:', $video->video_id; say 'Title:', $video->title; if( not $justthumbs ) { say 'Description:', $video->description; say 'Updated:', $video->updated; say 'Published:', $video->published; say 'Uploaded:', $video->uploaded; say 'Favorite Count:', $video->favorite_count; say 'View Count:', $video->view_count; say 'Duration:', $video->duration; say 'Keywords:', $video->keywords; say 'Author Name:', $video->author->[0]->name; say 'Author Uri:', $video->author->[0]->uri; say 'Geo Location:', $video->location; say 'Denied Countries:', $video->denied_countries; say 'Media Player URL:', $video->media_player; say 'Is Private:', $video->is_private; #content say $video->content->type( 'flash' )->[0] ->url; #retrieve the flash application url say $video->content->format( 1 )->[0]->url; #3gpp rtsp #loop over it: my $contents = $video->content; foreach my $content ( @$contents ) { say $content->url; say $content->type; say $content->duration; say $content->format; } say $video->rating->num_dislikes; say $video->rating->num_likes; } ## end if( not $justthumbs ) my $thumbs = $video->thumbnails; foreach my $thumb ( @$thumbs ) { for my $att( qw/ url time width height /){ my $val = $thumb->$att; $val = '' if not defined $val; say "$att: $val"; } #~ say $thumb->url; #~ say $thumb->time; #~ say $thumb->width; #~ say $thumb->height; } } ## end sub display_video

In reply to Re^3: explore a complexe hash structure return by Webservices::GData::YouTube by Anonymous Monk
in thread explore a complexe hash structure return by Webservices::GData::YouTube by roidlagratte

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (2)
    As of 2018-02-24 09:04 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (310 votes). Check out past polls.