I got this code to get the youtube id from the links like www.youtube.com/watch?v=xxxxxxx
URL youtubeURL = new URL(link);
youtubeURL.getQuery();
basically this will get me the id easily v=xxxxxxxx
but I noticed sometime youtube links will be like this
http://gdata.youtube.com/feeds/api/videos/xxxxxx
I am getting the links from a feed so do I need to build a regex for that or theres a parser to get that for me ?
Got a better solution from this link.
Use the following method to get the videoId from the link.
Hope this helps.
This was worked for me
Source link