4 * archive.org uses the solr engine:
5 * more about solr here:
6 * http://lucene.apache.org/solr/
9 var archiveOrgSearch = function ( iObj ) {
10 return this.init( iObj );
12 archiveOrgSearch.prototype = {
13 // Archive.org constants:
14 downloadUrl : 'http://www.archive.org/download/',
15 detailsUrl : 'http://www.archive.org/details/',
17 * Inititalize the archiveOrgSearch class.
18 * archiveOrgSearch inherits the baseSearch class
20 init:function( options ) {
21 var baseSearch = new baseRemoteSearch( options );
22 for ( var i in baseSearch ) {
23 if ( typeof this[i] == 'undefined' ) {
24 this[i] = baseSearch[i];
26 this['parent_' + i] = baseSearch[i];
31 * Gets the search results from the api query
33 getSearchResults:function() {
35 this.parent_getSearchResults();
37 js_log( 'f:getSearchResults for:' + $j( '#rsd_q' ).val() );
38 // build the query var
39 var q = $j( '#rsd_q' ).val();
40 // @@todo check advanced options: include audio and images media types
41 // for now force (Ogg video) & url based license
42 q += ' format:(Ogg video)';
43 q += ' licenseurl:(http\\:\\/\\/*)';
45 'q': q, // just search for video atm
46 'fl':"description,title,identifier,licenseurl,format,license,thumbnail",
48 'rows' : this.cp.limit,
49 'start' : this.cp.offset
53 'url':this.cp.api_url,
56 _this.addResults( data );
57 _this.loading = false;
62 * Adds the search results to the local resultsObj
64 addResults:function( data ) {
66 if ( data.response && data.response.docs ) {
68 this.num_results = data.response.numFound;
70 for ( var resource_id in data.response.docs ) {
71 var resource = data.response.docs[resource_id];
73 // @@todo we should add .ogv or oga if video or audio:
74 'titleKey' : resource.identifier + '.ogg',
75 'resourceKey': resource.identifier,
76 'link' : _this.detailsUrl + resource.identifier,
77 'title' : resource.title,
78 'poster' : _this.downloadUrl + resource.identifier + '/format=thumbnail',
79 'poster_ani' : _this.downloadUrl + resource.identifier + '/format=Animated+Gif',
82 'desc' : resource.description,
83 'src' : _this.downloadUrl + resource.identifier + '/format=Ogg+video',
84 'mime' : 'application/ogg',
85 // Set the license: (rsd is a pointer to the parent remoteSearchDriver )
86 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ),
90 this.resultsObj[ resource_id ] = rObj;
95 * Gets some media metadata via a archive.org special entry point "avinfo"
97 addResourceInfoCallback:function( rObj, callback ) {
100 'data': { 'avinfo' : 1 },
101 'url':_this.downloadUrl + rObj.resourceKey + '/format=Ogg+video'
102 }, function( data ) {
103 if ( data['length'] )
104 rObj.duration = data['length'];
106 rObj.width = data['width'];
107 if ( data['height'] )
108 rObj.height = data['height'];
114 * Returns html to embed a given result Object ( rObj )
116 getEmbedHTML: function( rObj , options ) {
117 js_log( 'getEmbedHTML:: ' + rObj.poster );
120 var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
121 if ( rObj.duration ) {
122 var src = rObj.src + '?t=0:0:0/' + seconds2npt( rObj.duration );
126 if ( rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' || rObj.mime == 'video/ogg' ) {
127 return '<video ' + id_attr + ' src="' + src + '" poster="' + rObj.poster + '" type="video/ogg"></video>';