Re: Google Backend attached
- From: Lee Willis <lee leewillis co uk>
- To: Don Smith <donsmith77 optonline net>
- Cc: dashboard-hackers gnome org
- Subject: Re: Google Backend attached
- Date: Fri, 06 Feb 2004 20:53:59 +0000
On Wed, 2004-02-04 at 19:49, Don Smith wrote:
> Here's the google backend, that uses webservices.
I had some problems compiling your patch, which I fixed up, and re-wrote
some bits to make the code simpler to read. The revised
backend-google.cs is attached.
> There is a catch
> however. Google limits each dev tag to 1000 searches per day so right
> now it looks like each person would have to register for there own tag.
> I saw something similar on the rhythmbox backend so i'm hoping this is
> okay.
It's not really the same, the Amazon APIs used by the rhythmbox
backends:
(a) Don't force the use of a valid dev tag
(b) Don't put a limit on how many queries can be carried out per day for
a given dev tag.
I'm note sure therefore about how useful the google APIs actually are ..
Anyway - thanks for the work - it's really quite useful [If you have a
tag!]
Lee
//
// backend-google.cs: Google backend.
//
// Authors:
// Don Smith
//
using System;
using System.IO;
using System.Xml;
using System.Collections;
using System.Net;
namespace Dashboard {
class Google : BackendSimple {
public override bool Startup ()
{
this.Name = "Google";
this.Category = "General";
try {
// Subscribe to artist clues
this.SubscribeToClues ("keyword");
this.Initialized = true;
return true;
} catch {
return false;
}
}
protected override ArrayList ProcessClueSimple (Clue clue)
{
int max_results=10;
string dev_key="INSERT DEV TAG HERE";
int start_result=0;
bool dupe_filter=true;
bool safe_search=true;
if (! this.Initialized)
return null;
if (clue.Text.Length == 0)
return null;
ArrayList results = new ArrayList();
GoogleSearchResult gsr;
GoogleSearchService searchService = new GoogleSearchService();
try {
gsr=searchService.doGoogleSearch(dev_key,
clue.Text,
start_result,
max_results,
dupe_filter,
"",
safe_search,
"", "", "");
} catch {
return null;
}
for (int i=0; i < max_results; i++) {
BackendResult GoogleResult = new BackendResult();
GoogleResult.AddItem(new BackendResultItem("GoogleResult",
gsr.resultElements[i].title,
"text",
"html",
gsr.resultElements[i].URL ));
results.Add(GoogleResult);
}
if (results.Count > 0) {
return results;
} else {
return null;
}
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]