• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 443
  • Last Modified:

regex hrlp required for extracting ID from few video services

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
Gurpreet Singh Randhawa
Asked:
Gurpreet Singh Randhawa
  • 2
  • 2
1 Solution
 
Pravin AsarPrincipal Systems EngineerCommented:
<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
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
does that work for all or the specific ones
0
 
Pravin AsarPrincipal Systems EngineerCommented:
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
 
Gurpreet Singh RandhawaWeb DeveloperAuthor Commented:
working on it
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now