Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get artist name and song name by YouTube code

On my website, people are able to drop their YouTube code link Like faXwJ9TfX9g

How do I get the name of the artist and name of the song, with a simple Javascript.

Input  :  faXwJ9TfX9g   by User
Output :  Name of artist
Output :  Name of the Song
Output :  Length of the Song

Best regards,

Simon Buijs Zwaag Netherlands

like image 263
Simon Avatar asked Jan 22 '10 20:01

Simon


People also ask

How can I find a song name from YouTube?

Often, YouTube videos will give the song information in the video's description box. You will just need to click on the “show more” box and scroll down to the section detailing “Music in this video.” It will show the name of the song and the artist at the very least, and often, it will have a link to it on YouTube.

Can Shazam listen to YouTube?

To listen to a Shazam in YouTube Music on your Android device, tap the More button next to a Shazam, then choose Open in YouTube Music. YouTube Music is not available in Shazam on iPhone, iPad, or iPod touch.

How can I find the original artist of a song?

All users have to do is hold up their phone to the source of the music while the song is playing and tap a single button within the Shazam app. Shazam will listen in on the song and provide you with all the relevant info you'd need to know like the artist, title, and album. It's extraordinarily accurate.

How can I track the name of an unknown song?

Music identifier websites will help you name that tune Wondering what song is playing? Popular music-identification apps such as Shazam and SoundHound are valuable tools that quickly name unknown songs as they play.


1 Answers

Youtube videos don't have tags for artist and song title (like mp3 files do, for example). So, AFAIK the best you can do is get the video title. You could go further and parse it to get the artist and song name, but I don't think this is something you'd want to do. Using the Data API here's what you can do:

<html>
<head>
<script type="text/javascript">
  function processData(data) {
    var title = data.entry.title.$t;
    var duration = data.entry.media$group.media$content[0].duration;
  }
</script>
</head>
  <body>
    <script 
      type="text/javascript" 
      src="http://gdata.youtube.com/feeds/api/videos/faXwJ9TfX9g?alt=json-in-script&callback=processData">
    </script> 
  </body>
</html>
like image 164
emil.p.stanchev Avatar answered Oct 13 '22 11:10

emil.p.stanchev