Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 ' 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

Replies are listed 'Best First'.
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 Tux (Abbot) 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 :)
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.
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(""); 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?


      $ perl -MURI::Title=title -le " print title( shift ) " http://www.yo Emily Brodie & Stephanie on Penn & Teller - Fool Us - YouTube

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://944283]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-06-19 02:07 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.