Monday, 30 July 2012

JSON Video Search YouTube, Vimeo, MySpace, DailyMotion, MetaCafe, SoundCloud

Camideo Video Search API - JavaScript, jQuery Example


In this tutorial we will try to show you how to use our Camideo Video Search API and it's JSON feed using JavaScript, jQuery.

Technologies used in this article:
  • JavaScript
  • jQuery
  • HTML

In this example we are going to parse video feed from YouTube, Vimeo, MySpace, Dailymotion, MetaCafe, SoundCloud. For more detailed description about Camideo Video Search JSON feed you may read our Camideo Video Search API documentation. 

1. Create the Search Form in HTML

 

First we have to create a HTML page where we will take the inputs. There are two inputs that we are going to take from user: Search Criteria and Source.

<title> New Document </title><br />
<div>Keywords : <input id="q" name="q" type="text" /></div>
<div>Source   : <select id="source" name="source">
                        <option value="youtube">YouTube</option>
                        <option value="vimeo">Vimeo</option>
                        <option value="myspace">MySpace</option>
                        <option value="metacafe">MetaCafe</option>
                        <option value="dailymotion">DailyMotion</option>
                        <option value="soundcloud">SoundCloud</option>
                    </select>
</div>
<div>
     <input onclick="getCamideoFeed();" type="button" value="Search" />
     <br />
     <div id="response"></div>
</div>

2. Include jQuery and Make Call 

You might need a API key to make a call. Please use our Key Generation Tool to get one. Once you have that you can make a call to our API. So our index.html will look like:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    function getCamideoFeed(){
        var q = $("#q").val();
        var source = $("#source").val();

        var url = 'http://www.camideo.com/api/?key=API_KEY&source=' + source + '&q='
                    + q + '&response=json&page=1';

        $.getJSON(url, function(data) {
                //do your parsing..
            });
    }
  </script>
 </head>

 <body>
  <div>Keywords : <input type="text" name="q"></div>
    <div>Source   : <select name="source">
                        <option value="youtube">YouTube</option>
                        <option value="vimeo">Vimeo</option>
                        <option value="myspace">MySpace</option>
                        <option value="metacafe">MetaCafe</option>
                        <option value="dailymotion">DailyMotion</option>
                        <option value="soundcloud">SoundCloud</option>
                    </select>
    </div>
    <div><input type="button" value="Search" onclick="getCamideoFeed();">
    <div id="response"></div>
 </body>
</html>

3. Cheking for error in JSON Output

We might have encountered an error in our call. So it's better to check for error and show user a message in case of error. We will add these lines in our getCamideoFeed() method:

if(data.Camideo.Error){
    $("#response").html(data.Camideo.Error.description)
}

4. Everything is fine. Let's parse the feed

Now we have error free feed. Let's modify our getCamideoFeed() to show the videos.

$.each(data.Camideo.videos, function(i, object) {
    if(source == "metacafe" || source == "myspace"){
        $("#response").append('<div class="thumb">' +
            '<embed flashVars="playerVars=autoPlay=no" src="' + object.embedCode + '" width="390" height="290" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_' + object.videoId + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>' +
            '</div> <!-- thumb ends -->' +
            '<div class="videoDetails">' +
            '<div class="videoTitle">' +
                '<a target="_blank" href="' + object.link + '" title="' + object.title + '" rel="nofollow">' +
                    '<h2>' + object.title + '</h2>' +
                '</a>' +
            '</div>' +
            '<div class="videoDesc">' +
                object.description +
            '</div>' +
            '<div>' +
                'Uploaded by ' +
                    '<a class="videoAuthor" href="' + object.authorLink + '" rel="nofollow" target="_blank" title="' + object.author + '">' +
                        object.author +
                    '</a> | ' +
                'Length ' +
                    '<span class="videoWhiteText">' +
                        object.duration +
                    '</span> | ' +
                    '<span class="videoWhiteText">' +
                        object.views +
                    '</span> views' +
            '</div>');
    }else{
        $("#response").append('<div class="thumb">' +
            '<iframe type="text/html" width="390" height="290" src="' + object.embedCode + '"' +
            'frameborder="0"></iframe>' +
            '</div> <!-- thumb ends -->' +
            '<div class="videoDetails">' +
            '<div class="videoTitle">' +
                '<a target="_blank" href="' + object.link + '" title="' + object.title + '" rel="nofollow">' +
                    '<h2>' + object.title + '</h2>' +
                '</a>' +
            '</div>' +
            '<div class="videoDesc">' +
                object.description +
            '</div>' +
            '<div>' +
                'Uploaded by ' +
                    '<a class="videoAuthor" href="' + object.authorLink + '" rel="nofollow" target="_blank" title="' + object.author + '">' +
                        object.author +
                    '</a> | ' +
                'Length ' +
                    '<span class="videoWhiteText">' +
                        object.duration +
                    '</span> | ' +
                    '<span class="videoWhiteText">' +
                        object.views +
                    '</span> views' +
            '</div>');
    }
});

5. Download Source Code


Friday, 20 July 2012

Camideo - Camideo Video Search Widgets

We have developed few widgets so that you can search

Camideo Video Search API

without visiting our site. These widgets will do the search for you and redirect you to our result page where you can see all your favourite video and songs from

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

 

 

At

Camideo

, we have added opensearch xml so that you can add

Camideo Video Search Engine

to your browser's default search engines. Opensearch xml is a way for websites and search engines to publish search results in a standard and accessible format. For more information you may visit Wiki - OpenSearch

 

  1. In the address bar type http://www.camideo.com
  2. Press TAB to select

    Camideo

    as you search engine
  3. Type anything you want to search in the address bar
  4. You will be taken to the video search result page where you can play your favourite video and songs from

    YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

 
Add Camideo Opensearch for Chrome

 

  1. Visit http://www.camideo.com
  2. Click on down arrow in the search engine section and select Add "Camideo.com"
  3. Type anything you want to search in the search bar
  4. You will be taken to the video search result page where you can play your favourite video and songs from

    YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

 
Add Camideo Opensearch for Firefox

 


 

 

We have developed a Chrome extension for

Camideo Video Search Engine

. All you have to do is to click this link

Camideo Video Search

from your Chrome browser and Add this widget to Chorme. Once added you can type in the search query in the Search box and select appropriate source like

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe or SoundCloud.

from the dropdown and click on Search. A new tab will open with the search result where you can play your favourite video and songs from

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

 
Add Camideo Extension for Chrome

 


 

 

We have developed a Firefox addon for

Camideo Video Search Engine

. All you have to do is to click this link

Camideo Video Search

from your Firefox browser and Add this addon to Firefox. Once added you can type in the search query in the Search box and select appropriate source like

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe or SoundCloud.

from the dropdown and click on Search. The current tab will be loaded with the search result where you can play your favourite video and songs from

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

 
Add Camideo Addon for Firefox

 

Camideo - Video Search API - YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud

We provide uniform JSON feed for online video and song search from

YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud.

Here we are going to describe in details how to access and use this JSON feed.
To get started you might need to get a

API KEY

. All you need a valid email address to generate the key. Please follow the link and enter you valid email address and clear the verification code to ensure human activity. We will generate the Camideo API Key and mail it to. If you have lost it, then you can use this link to regenerate it. We will send your lost API key.

API Call


Once you have the API Key, you can make a call to Camideo Video Search API like:
					http://camideo.com/api/?key=<API KEY>
						&q=chocolate&source=youtube&page=1&response=json
					
				

API Parameters


The above code sample shows the basic call you can make to our API. However, each search source has it's own specific search filters which you can use to drill down to a more specific search. For source specific search filter please have a look at the appropriate one:
Below we are describing the basic search filters that we have used in the above code sample.
key: This is the API key. You can generate the key using our key generation tool. You need to supply this key in each and every call.
q: This is the search words. It can be anything like "chocolate", or may be like "chocolate+rain", "chocolate rain", "chocolate%20rain". These are the words that our search engine will look for in the video title, description or in author name.
source: This is where you want to search. For example "source=youtube" will search in YouTube videos. Currently we are supporting the following search sources:
  • YouTube
  • Vimeo
  • MySpace
  • Dailymotion
  • MetaCafe
  • SoundCloud
page: Number of page you are in. e.g. page=1 will give you the first set of results and page=2 will give you the next set and so on. This can be used for pagination in you result.
response: This defines the response format. Currently we support only JSON response. So the output string you will be getting is a JSON string. You can use any programming language to parse this JSON feed. We will provide a uniform JSON feed for all the sources. So you don't have to worry about different sources and a single parsing code can be used to parse them all. For more information you may take a look at following sample codes:

JSON Output


We will provide a JSON output for all your search queries. For example, if you make a call like :
					http://camideo.com/api/?key=<API KEY>
						&q=El+Nakam&source=vimeo&page=1&response=json
					
				
You will get the output as follows:
					{"Camideo":
										{
										"totalResults":"1",
										"itemsPerPage":"10",
										"startIndex":"1",
										"videos":
											[{
											"videoId" : "45558546",
											"title" : "El Nakam!!",
											"link" : "http://vimeo.com/45558546",
											"description" : "my final project in shenkar school of arts.

animation & story: yonatan popper
original theme music: Assa Raviv & Itamar Fintzi

guided by Guy Harlap & Itamar Daube.

its a short animation trailer, for a movie that doesn't exists.
the animation is mostly classic: frame by frame animation

great thanks to: smadar & tal hunziker, max & eti popper, ido gildin, Idan Epshtien,
Elad Tayar, Daniel Goldfarb and nina limarev",
											"author" : "yonatan popper",												
											"author-link" : "https://vimeo.com/user7744618",
											"duration" : "00:03:22",
											"embedCode" : "http://player.vimeo.com/video/45558546",
											"views" : "10895",
											"published" : "2012-07-11 02:22:08"
										}]
							}
					}	
					
				
totalResults: Number of results returned by the search you have made. This can be used to paginate the results or to get an idea about result count. This is a indicative number.
itemsPerPage: Number of maximum items in this page. This may not equal to the number of actual results in that page. As you can see from the above example that even though itemsPerPage = 10, but we have received only one result.
startIndex: This is the start index of the first video in the result JSON. For page=1 it will always be 1. But for subsequent pages it will vary based on the itemsPerPage parameter. For example if itemsPerPage=10,then in 2nd page startIndex will be 11.
videos: Array containing the actual search results.
videoId: This is the Video ID specified by the respective source. This can be used to identify the video uniquely.
title: This is the Video Title specified by the respective source.
description: Video description as specified by the author in the original source. Formatted for JSON like new lines replaced by <br>, single-quote by &#39; etc.
author: This is the Video Autohor Display Name specified by the respective source.
author-link: Direct link to the author profile in the source.
duration: Video duration in HH:MM:SS format.
embedCode: Code for embedding this video as supported by the source. Please note that MySpace and MetaCafe does not support iFrame integration and hence for those two sources you might need to use object embedding options. For all other sources you can directly put this embedCode as iFrame src parameter. e.g.
				<iframe src="http://player.vimeo.com/video/45558546"  
					type="text/html" width="390" height="290" frameborder="0"></iframe>
			
or
				<embed flashVars="playerVars=autoPlay=no" 
				src="http://player.vimeo.com/video/45558546" width="390" height="290" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
			
duration: Video duration in HH:MM:SS format.
views: Number of view in it's original source.
published: Published date time in the original source.

Error Codes


We provide the following error codes for your reference:
				{"Camdieo":{"Error":{"code":"1000", 
				"description" : "Invalid key specified or key is missing."}}}

			
				{"Camdieo":{"Error":{"code":"1001", 
				"description" : "Invalid response type specified."}}}

			
				{"Camdieo":{"Error":{"code":"1002", 
				"description" : "Invalid source specified."}}}

			
				{"Camdieo":{"Error":{"code":"1003", 
				"description" : "Invalid search criteria specified."}}}

			
				{"Camdieo":{"Error":{"code":"1004", 
				"description" : "Sorry! Could not fetch results."}}}

			

Monday, 2 July 2012

Camideo





At Camideo.com you can search and play videos, songs from YouTube, Vimeo, MySpace, Dailymotion, MetaCafe and SoundCloud in one go. So this is a one place search for all your favorite videos and songs.


That's not all, you can use 

Camideo Video Search API

 to make calls to those sites and search content. You will get a uniformly formatted JSON feed from Camideo. So you don't have to worry about parsing different feeds from different sources. A full documentation on how to use this API is coming soon. Please keep checking this place for more update.