Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

How I can get a Youtube Video Title using it's Link

by prince26121991 (Novice)
on Dec 19, 2011 at 17:33 UTC ( #944283=perlquestion: print w/ replies, xml ) Need Help??
prince26121991 has asked for the wisdom of the Perl Monks concerning the following question:

Well Hi to all of you guys I m a new user here n beginner of perl Dont know much more about perl That's why m here to gain some knowledge so here is my first query If I have A YOUTUBE link 'http://www.youtube.com/watch?v=Video ID' Now I just want to extract the name of this video from youtube page Is it possible by using perl If yes than How & which module I have to install for it Thanks

Comment on How I can get a Youtube Video Title using it's Link
Re: How I can get a Youtube Video Title using it's Link
by Anonymous Monk on Dec 19, 2011 at 17:38 UTC
Re: How I can get a Youtube Video Title using it's Link
by TJPride (Pilgrim) on Dec 19, 2011 at 20:37 UTC
    LWP::Simple to download the page, then a little pattern matching to extract the title? Untested because I don't have LWP::Simple on this computer.

    use LWP::Simple; use strict; use warnings; my ($movie, $content, $title); $movie = 'eRw69htzQnU'; $content = get("http://www.youtube.com/watch?v=eRw69htzQnU"); die "Couldn't load movie." if !defined $content; if ($content =~ m/<title>(.*?)<\/title>/s) { $title = $1; $title =~ s/^\s+//; $title =~ s/\s+- YouTube\s+$//; print $title; }

      Guess what. This doesn't work.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

      URI::Title

      $ perl -MURI::Title=title -le " print title( shift ) " http://www.yo +utube.com/watch?v=eRw69htzQnU Emily Brodie & Stephanie on Penn & Teller - Fool Us - YouTube
Re: How I can get a Youtube Video Title using it's Link
by Tux (Monsignor) on Dec 19, 2011 at 23:39 UTC

    Also note that the way the video is linked/embedded changes over time. About a year ago, the best program to fetch youtube movies was clive. It was written in perl, which it was keeping up-to-date and kinda always worked. When it stopped working I switched to youtube-dl. It is written in python. Sorry to curse in this church. You could probably fetch clive and try if it now works for you. If it doesn't, you can fix it. It is open source.


    Enjoy, Have FUN! H.Merijn
      get-flash-videos, written in perl, still works, its updated frequently :) https://github.com/monsieurvideo/get-flash-videos/blob/master/lib/FlashVideo/Site/Youtube.pm
OT: "its" vs. "it's"
by educated_foo (Vicar) on Dec 20, 2011 at 13:38 UTC
    If you want to correctly use "its" vs. "it's" (you didn't), remember that "it's" means "it is," and "its" means "belonging to it."
      ..."it's" means "it is"...

      So "It's been raining all day" means "It is been raining all day"? ;)

        Good point. In this case, "it's" is a contraction of "it has".

      So you looked at the almost totally unpunctuated OP and that was what caught your (you're? yore? Eeyore?) eye? I guess it could have been worse; at least there were capitals (capitols?) at the beginnings of teh sentences.     sigh

        Word is The.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://944283]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2014-09-02 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (18 votes), past polls