Get video id from youtube url using Android Youtube ApI v3

て烟熏妆下的殇ゞ 提交于 2019-12-04 18:33:30
AniV

Yes, as you already figured this out that it is not that simple to get the video ID of a youtube video because of the inconsistency. You need to include all the possible permutations and combinations in the PHP (or what ever language script) you are going to parse the URL using regular expressions.

This question has been asked previously on SO you can refer that and add your own logic to parse the URL. I am pasting the links of some of them:

Youtube API - Extract video ID

how to get youtube video id from url

JavaScript REGEX: How do I get the YouTube video id from a URL?

https://halgatewood.com/php-get-the-youtube-video-id-from-a-youtube-url

http://www.microtuts.com/c-get-youtube-video-id-from-url-with-regex/

It will return you the video id: watchLink ="https://www.youtube.com/watch?v=s6RPsaco-vA"

 public static String getVideoId(String watchLink){

     return watchLink.substring(watchLink.length() - 11);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!