Solved

regex hrlp required for extracting ID from few video services

Posted on 2014-04-29
4
425 Views
Last Modified: 2014-05-20
Hi,

I am using couple of video services to diplay the videos to the users, now i have written some static code which will just fetch the id of the video url and play it in my video defined tag..

I am looking for regex for dailymotion, google video, livevideo, myspace, vimeo to extract the ID and give it to me, so i can use it

now there are few things, there is no one static url which can be used, it has different links to use the same id, so regex is becoming difficult to handle.

Like for vimeo i am using this code:

http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}
http://video.google.com.au/videoplay?docid=
http://livevideo.com/flvplayer/embed/
http://www.livevideo.com/flvplayer/embed/
http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=
http://www.dailymotion.com/swf/

Open in new window


the above is code which is i am using with the embed tag to play the videos.
0
Comment
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 500 total points
ID: 40033587
<cfoutput>
    <cfset theUrl = "http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}" />
    <!--- Uses CF function --->
    <cfset theUrl = listRest(theUrl, "?")>
    <cfloop list="#theUrl#" index="URLPiece" delimiters="&">
        Key: #listFirst(urlPiece, "=")# Value: #listLast(urlPiece, "=")# <br />
    </cfloop>
</cfoutput>


You can do this in Javascript also.

Here is simple function and usage example in Javascript

<html>
      <script type="text/javascript">
      function getParameterByName(location,name) {
          name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
          var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location);
          return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
      }
      alert (getParameterByName("http://www.vimeo.com/moogaloop.swf?clip_id={Just need the ID to play it}","clip_id"));
      </script>
      
</html>
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 40033875
does that work for all or the specific ones
0
 
LVL 28

Expert Comment

by:Pravin Asar
ID: 40034410
Should work.

I noticed following url have no query parameters

http://livevideo.com/flvplayer/embed/
http://www.livevideo.com/flvplayer/embed/
http://www.dailymotion.com/swf/


So I do not know, how you will be able to get the video source file name
0
 
LVL 16

Author Comment

by:Gurpreet Singh Randhawa
ID: 40040070
working on it
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question