Extend plugin architecture

Tell us about your wildest feature dreams. Or just harmless suggestions for improvement.
Post Reply
julifos
Junior Member
Junior Member
Posts: 4
Joined: Sun Feb 08, 2009 4:04 pm

Extend plugin architecture

Post by julifos »

I'm looking into Bookpedia. It's cool and potentially very powerful. But not really powerful because it lacks of a useful search function for me (Spain). Casadellibro is a nice physical library, but pure crap searching for ISBNs. This must be a common problem for many countries, I think. These folks only provide ISBN numbers for books they sell or they can acquire for you. But this is absurd and un-usable if I want catalog my own books. I guess you heard this or something similar before :roll:

Plug-ins are OK, if you speak Cocoa.

I speak a couple of programming languages and my favorite one for desktop programming is AppleScript.

Appart of a Xcode template, which is useful for obj-c programmers, why don't you provide a pre-compiled plugin with some instructions for other non-obj-c developers? Specifically, and for example, you can include a special folder from where obj-c tells the system to *run* whatever thing is in there called "plugin" (plus extension). For example, it would run "plugin.sh" or "plugin.pl" or "plugin.py" or... And it would be nice if it could run as well "plugin.scpt" (for AppleScript). But if it can run "plugin.sh" we can allways use "osascript" from inside the shell script... A very simple "sample.sh" would do the job, as a shell script can run most of these languages (python, applescript, ruby, perl...).

You will pass a parameter to this file, the ISBN and you will wait for the answer (a collection of key-values with info about the found results?).

I'm sure there are lots of issues and caveats with this suggestion, but this could easily open your plugin architecture to many or ALL programmers in the Mac OS platform... --> and would make Bookpedia a click'n'go app for me :D
User avatar
Conor
Top Dog
Posts: 5344
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Extend plugin architecture

Post by Conor »

Thank you for the suggestion. Extending the plug-in architecture to be able to handle other types of programming languages is a good idea. But the Cocoa interface is so flexible that it allows for a Cocoa style plug-in to bridge the gap. I have created one for Applescript since this is your preferred language. The source code for the plug-in is available; However, you are interested in the built plug-in that can be [url=bookpedia://www.bruji.com/download?plugins/applescriptplugin.zip]installed here[/url]. Once installed navigate to your Bookpedia data folder ~/Library/Application Support/Bookpedia/Plug-ins/SampleScript.plugin this is the plug-in that was installed. Control click it and use "show package contents" command to continue into the bundle to SampleScript.plugin/Contents/Resources/Search.scpt. Search.scpt is the AppleScript that it uses to search for the book information. Since it has already has been compiled here is the source of that script so that you can modify it and save it, replacing the built in sample Search.scpt.

Code: Select all

-- script is only loaded on program launch, program needs to be relaunched after making changes.

on search_for(search_string)
	return {"A Book", "A DVD"}
end search_for

-- Create an array of two object arrays (key and value pair).
-- imageLocation is the key to a URL for the image
-- or use Image as key to set the image data directly
on details_for(recordNumber)
	if (recordNumber is 0) then
		set image to {"imageLocation", "http://www.bruji.com/bookpedia/images/mainScreenshot.png"}
		set title to {"title", "A Great Book"}
		set author to {"author", "Really Cool Guy"}
	else
		set image to {"imageLocation", "http://www.bruji.com/dvdpedia/images/mainScreenshot.png"}
		set title to {"title", "Excellent Software"}
		set author to {"author", "Okay Guy"}
	end if
	return {image, title, author}
end details_for
You will need to add a global variable to the script to set in search_for so that you can know what ISBN to look for in details_for. In your case with the ISBN there will only be one result, so you can load the details already in search_for and just return that global variable in details_for. In the regular cases you would keep a global variable with a list of the result titles and URLs to download further details for each if requested.

The keys to build the return array are mostly what you would think they are, the source code contains a constant.h file that lists them all, but they can also be found here.

The script is also called "Script" in the search site pop up, to change the name to something more descriptive change the PluginSearchName attribute in the info.plist inside the plug-in.
julifos
Junior Member
Junior Member
Posts: 4
Joined: Sun Feb 08, 2009 4:04 pm

Re: Extend plugin architecture

Post by julifos »

This is exactly what I was looking for. I am aware that Cocoa has native access to apple-events but it's a terrific monster for me :!:

I know that supporting websites which don't offer some kind of API are hard to support, but it's now for me a "must do" if I want a as-fast-as-possible catalog process...

Whenever I finish the stuff, I'll test the workflow, purchase a copy of Bookpedia (I'm in the test phase and this is the important thing to decide to use Bookpedia or a Filemaker database) come back and share whatever I have (I have the basics, must now parse the HTML...)

Many thanks!!!
julifos
Junior Member
Junior Member
Posts: 4
Joined: Sun Feb 08, 2009 4:04 pm

Re: Extend plugin architecture

Post by julifos »

OK, here is the hare:

http://homepage.mac.com/julifos/soft/goodies/mcu.zip

Only supports ISBN searches in the Ministerio de Cultura of Spain database (contains around 1 million books published from 1972).

And one more thing... Instead of (or "best than") Casadellibro (after some research), you could include for Spanish books BNE (Biblioteca Nacional de España - National Library of Spain), which provides a Z39.50 interface:

http://www.bne.es/esp/servicios/infoz3950.htm

Server: sigb.bne.es
Port: 2200

Works like a charm, but it's crap compared against my (still untested) plugin, which should be able to find most of titles :D

Some sample input ISBNs to be found by "MCU":
9788467511857
9788420670713
84-88893-28-0
8450507685
8484591255

--> the script is open-sourced

Now I'm going for the second step: purchase Bookpedia. Now it's a user-friendly app for me ;-)

Conor, many thanks1
User avatar
Conor
Top Dog
Posts: 5344
Joined: Sat Jul 03, 2004 12:58 pm
Contact:

Re: Extend plugin architecture

Post by Conor »

That is a very nice plug-in and quite a lot of AppleScript. I had to comment one line in order to use it since I don't have Smile app on my computer. Once the line that asks Smile to record the search was commented it worked. Thank you for sharing it with other users and making it open source. You are a proliferate programmer you have created a lot of useful software at Pescado Software. Quite interesting how you have the flashed linked to a streaming radio station, I did not know that was possible?
julifos
Junior Member
Junior Member
Posts: 4
Joined: Sun Feb 08, 2009 4:04 pm

Re: Extend plugin architecture

Post by julifos »

Ooops! Debugging issues. I'll comment that line as well ;-)

I think I could add support for author/title searching as well, but it will be much faster for the regular user to enter the ISBN if he is using Bookpedia to catalog real books. Otherwise (if it's for entertainment purposes, you can allways use the real search engine)...

I'll comment that line, re-package and send to support@... as stated in the plugins page.

Cheers and thanks again!


* no real radio station, if you are talking about http://www.pescadosweb.com/, just some concat mp3 files :wink:
Post Reply