admin管理员组文章数量:1303389
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
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
Share edited Jan 22, 2010 at 20:55 ZoogieZork 11.3k5 gold badges47 silver badges42 bronze badges asked Jan 22, 2010 at 20:44 SimonSimon 1011 silver badge3 bronze badges 2- Wele to StackOverflow! Great first question. – Tyler Carter Commented Jan 22, 2010 at 20:58
- Feel free to upvote this if you want to see this feature added. – Cardinal System Commented Mar 2, 2021 at 3:08
2 Answers
Reset to default 5Youtube 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./feeds/api/videos/faXwJ9TfX9g?alt=json-in-script&callback=processData">
</script>
</body>
</html>
This article has a plete answer, including a second version using user selected IDs at runtime (most examples I found seemed to only have a hardcoded ID).
http://salman-w.blogspot./2010/01/retrieve-youtube-video-title.html
本文标签: javascriptGet artist name and song name by YouTube codeStack Overflow
版权声明:本文标题:javascript - Get artist name and song name by YouTube code - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741692709a2392824.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论