Unattended export through a script
Hello,
I would like to create a script that would run on a linux server (without GUI) and that would export (in Bibtex format) all zotero entries of some public zotero group library to a file. Preferably the script should be portable (Windows / Linux).
That would be used to connect our new zotero managed DB to a legacy website requiring bibtex files. The script should ideally be run each time the content changes, or simply every day. Hence the need to run it on a server. Also the script needs to update a secure location on our web site directory, so it needs special privileges and need to be secured itself. Result of running the script should be the same as when a zotero user selects in its zotero firefox pane the given public group library, clicks "export library", and selects the bibtex format and UTF-8 encoding.
Reading through the dev doc http://www.zotero.org/support/dev/start, I guess I should start by looking at the REST API documentation http://www.zotero.org/support/dev/server_api, but I'd prefer having some general, high-level, advices on how to proceed before embarking into potentially not-the-easiest-possible path... (Also does the REST API give access to an export-to-bibtex functionality?)
So I'd be happy to read any advice concerning which general approach to take; which programming language to use (anything from javascript to C++ or Java including Perl, Python etc. is possible). Code snippets for a fast-start would be much appreciated!
I would like to create a script that would run on a linux server (without GUI) and that would export (in Bibtex format) all zotero entries of some public zotero group library to a file. Preferably the script should be portable (Windows / Linux).
That would be used to connect our new zotero managed DB to a legacy website requiring bibtex files. The script should ideally be run each time the content changes, or simply every day. Hence the need to run it on a server. Also the script needs to update a secure location on our web site directory, so it needs special privileges and need to be secured itself. Result of running the script should be the same as when a zotero user selects in its zotero firefox pane the given public group library, clicks "export library", and selects the bibtex format and UTF-8 encoding.
Reading through the dev doc http://www.zotero.org/support/dev/start, I guess I should start by looking at the REST API documentation http://www.zotero.org/support/dev/server_api, but I'd prefer having some general, high-level, advices on how to proceed before embarking into potentially not-the-easiest-possible path... (Also does the REST API give access to an export-to-bibtex functionality?)
So I'd be happy to read any advice concerning which general approach to take; which programming language to use (anything from javascript to C++ or Java including Perl, Python etc. is possible). Code snippets for a fast-start would be much appreciated!
By allowing the script to run on the client side, would I be able to somehow easily access the Bibtex export function that is already embedded into zotero?
I tried:
wget -O- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib\&style=apa | less
which works.
But:
wget -O- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib\&style=bibtex
--2011-01-07 19:01:09-- https://api.zotero.org/groups/1/collections/42ZCTF3U/items?content=bib&style=bibtex
Resolving api.zotero.org... 209.51.184.206
Connecting to api.zotero.org|209.51.184.206|:443... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2011-01-07 19:01:14 ERROR 500: Internal Server Error.
Is bibtex not supported yet? The doc mentions, if I understood correctly, that styles in the Zotero Style Repository may be used, and bibtex is listed in http://www.zotero.org/styles...
But even if you wanted to use it, from the API docs: Default styles are the styles at the top of the page.
So one way to go for me, correct me if I'm wrong, would be to write a script that:
1) download the references from the group library in atom format using a simple HTML "get";
2) change these to bibtex, maybe using the csl provided in the zotero styles repository.
Achieving 1) should be easy using standard libraries but I'm not sure about 2).
A few questions:
- What do you mean by "not recommended" when talking about using the bibtex csl style in the repository?
- Any alternative implementation suggestion in mind?
- Would zotero people recommend me to rather wait for the forthcoming "arbitrary style support"? (One question naturally linked is: when?, but I guess that's hard to say. The other linked question is the difficulty of writing the code sketched above.)
- If any one has got some code snippet to get me started or pointers to good libraries I could use (esp. for 2)), it would most certainly be helpful.
There is little in the way of example code out there for working with the Atom data-- but it is fairly self-explanatory (if limited).