We don't make any guarantees about our URL formats for watch pages.
They're not part of any supported API, and they might change or new
formats for the URL might roll out at any time.
That being said, most watch page URLs nowadays have a v=VIDEO_ID URL
query parameter in them, and the easiest way to parse that would
probably just to use a URL parser that will tokenize the URL's query
parameters properly and check for the value of the "v" parameter.
Here's a page dedicated to a discussion of parsing URL query
parameters from Java:
http://stackoverflow.com/questions/1667278/parsing-query-strings-in-java
If you want a regex, /[?&;]v=([^?&;]+)/ would probably be my
recommendation, though I'm sure you could do better. Again, this
depends on the video id being in the v= URL parameter, which I can't
guarantee will always be the case for all URLs.
Cheers,
-Jeff Posnick, YouTube API Team
groups.google.com/group/youtube-api-gdata | apiblog.youtube.com |
@YouTubeDev
On Jan 6, 6:23 am, miguel_dev <miguel.alvarado.1...@gmail.com> wrote:
> Hi ,
>
> I want to store the video IDs of the videos that have been shown in my
> website, to do this I need to strip away the video url just to store the
> video ID. The issue is that I have read some solution to this using regular
> expressions, one fo the solutions suggested by Jarek Wilkiewicz was to use
> this PHP regular expression $pattern = '/[^=]+=([^?]+)/'; , but this
> expression doesn't cover all the possible formats to show a YouTube video.
>
> So my questions are :
>
> - Are there any specific formats for the urls to show a video? Where can I
> check this?
> - If that is not the case, can anyone help me to find out a regular
> expression in Java that covers all the possible formats to show a video in
> Youtube urls?
>
> Thanks in advance for any help!!!
--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment