Friday, October 7th, 2005 at 6:11 AM
In working on the caching back end for my SpotlightSiteSearch capabilities, I found it necessary to store a searchable copy of all the relevant photo data that Flickr has. Since the possibility exists that the photo database may be searched many times a day, often with several hits in quick succession, it would be much better to put the load on my own database server rather than bother Flickr over and over. To that end, I wrote up a small script that asks Flickr for a list of all photos* and inserts the relevant data into a MySQL database. Much like MySQLicious, Duplicatr mirrors your Flickr photo information to a given database. While the original images still reside at Flickr, you’ll have fast local access to your photo information, thus simultaneously lightening the load on Flickr’s servers and speeding up your search queries.
Right now, the information stored about each photo includes the photo ID, server, secret, title, description, public flag, date taken and date posted, tags (space separated), comment count, and a link to the general photo page. More may be added in the future by request.
Requirements:
- PHP 4.3.0 or greater (built with 4.3.11)
- MySQL (built with 4.0.21)
- A Flickr account
(To map the photo information to a full URL, see Flickr’s short but sweet URL documentation)
* For the moment, you’re limited to 500 photos. See the TODO section ;-)
Installation:
1) Create a MySQL database or use an existing one (PHPMyAdmin will do just fine).
2) The default table name is ‘flickr’. This can be tweaked in the code quite easily.
3) Run the CREATE TABLE statement (found near the top of the script) in PHPMyAdmin to build the table scructure.
4) Fill in your Flickr User ID or email address so the script knows whose photos to grab.
5) Fill in your MySQL details (host, MySQL username/password, etc.)
6) Access the script via a web browser and let it run!
Comments, suggestions, and bug reports are all welcome in this post as well as in the eerily quiet forums.
This entry was posted
on Friday, October 7th, 2005 at 6:11 am and is filed under Programming.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, trackback from your own site, or
Stumble it!.
fmTuner: Last.fm for WordPress
ADB Mouse Conversion
iPod Super
Hi, nice work! i just installed your script on my server and it’s running great. Why the 500 pict limit? Maybe you could create 2 other tables to store the tags info: tags(tag_name) and photo_tag(photo_id,tag_name).
Greetings, Jaime
Cómo ahorrarse unos dolares y guardar tus fotos online con Flickr
Flickr es genial. Puedes subir tus fotos (ve las mÃÂas), guardarlas en la resolución que quieras, escribir comentarios, recibir comentarios, generar contactos con otras personas, etc, etc. Obviamente, y como todo servicio que ha de pertenecer a la We…
The 500 pic limit is there at the moment because Flickr sends data paginated. They send 500 photos per page, and also tell you the page number. So, to do more, I’d have to add code to keep track of pages and totals, as well as request further pages. It’s something I hope to do soon. Do you need it right now? I could work on it if need be :-) If so, I’d need a Flickr user ID to test it on, as I don’t have near 500 photos. Anyone is welcome to comment on that, as any user ID will work.
hi, it’s me again :)
one suggestion from a little problem I detected when re-run the php script: the photos get ‘duplicatrs’ on the mysql table! One easy solution -it worked for me- is putting one primary key on the table, I set to PK the ‘photopage’ attribute and when execute again, there wasn’t any duplicates on the table.
I must re-run the script frecuently because i don’t have a pro flickr account, so my limit of photos is 200. With your script I can still see the pictures i have on flickr, from my server instead of flickr’s website :)
Jaime