Solved

regex hrlp required for extracting ID from few video services

Posted on 2014-04-29
4
416 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 15

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 15

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now