FlickrGrab is an Io program to download all photos of a flickr user in original size if available. I created FlickrGrab using Io.
I also wrote a perl version after this version because Io changed and so my script became incompatible, so here is the perl version:
SGML Flickr := Object clone do( PhotoCount := 0 run := method(username, pagecount, directory, for (run, 1, pagecount, self grab(username, run, directory)) writeln(self PhotoCount .. " photos successfully downloaded") ) getPhotoId := method(src, id := src split("_") at(0) split("/") return id at(id size-1) ) grab := method(username, pagenumber, destDirectory, userpageHtml := URL with("http://flickr.com/photos/" .. username .. "/page" .. pagenumber .. "/") fetch asHTML ImageLinks := userpageHtml elementsWithNameAndClass("img", "pc_img") map(attributes at("src")) ImageLinks foreach(ImageSrc, photoID := self getPhotoId(ImageSrc) photoSingleEntryHtml := URL with("http://flickr.com/photos/" .. username .. "/" .. photoID .. "/sizes/o/") fetch asHTML SingleEntryImageLinks := photoSingleEntryHtml elementsWithName("img") map(attributes at("src")) SingleEntryImageLinks foreach(ImageSrc, if ((ImageSrc split(photoID) size)==2, write("grabbing " .. ImageSrc .. "...") photoExt := ImageSrc split(".") photoExt := "." .. photoExt at(photoExt size -1) File with(destDirectory .. "/" .. photoID .. photoExt) setContents(URL with(ImageSrc) fetch) write("done.\n") self PhotoCount = self PhotoCount + 1 ) ) ) ) ) run("schipplock", 118, "./photos")
I also wrote a perl version after this version because Io changed and so my script became incompatible, so here is the perl version:
#!/usr/bin/perl -w use strict; my $document = `wget -q -O /tmp/doc "http://flickr.com/photos/schipplock/" && cat /tmp/doc && rm /tmp/doc`; my @lines = split(/\n/, $document); my @page_numbers = 0; my $max_page = 0; for (my $run=0;$run<(@lines);$run++) { my @page_split = split(/\/page/, $lines[$run]) if (index($lines[$run], "/page")!=-1); my @number_split = split(/\//, $page_split[1]) if (index($lines[$run], "/page")!=-1); push @page_numbers, $number_split[0] if (index($lines[$run], "/page")!=-1); } for (my $run=0;$run<(@page_numbers);$run++) { if ($page_numbers[$run] > $max_page) { $max_page = $page_numbers[$run]; } } print "max pages: $max_page\n"; for (my $run=1;$run<=$max_page;$run++) { print "Page $run: "; my $page = `wget -q -O /tmp/doc "http://www.flickr.com/photos/schipplock/page$run/" && cat /tmp/doc && rm /tmp/doc`; my @lines = split(/\n/, $page); for (my $irun=0;$irun<(@lines);$irun++) { if (index($lines[$irun], "class=\"photo_container pc_m\"")!=-1) { my @f_split = split(/\/photos\/schipplock\//, $lines[$irun]); my @s_split = split(/\/"/, $f_split[1]); my $photo_id = $s_split[0]; my $photo_page = `wget -q -O /tmp/doc "http://www.flickr.com/photos/schipplock/$photo_id/sizes/o/" && cat /tmp/doc && rm /tmp/doc`; my @p_split = split(/\n/, $photo_page); for (my $iirun=0;$iirun<(@p_split);$iirun++) { if (index($p_split[$iirun], "Download this version")!=-1) { my @url_split = split(/href="/, $p_split[$iirun+1]); my @value_split = split(/">/, $url_split[1]); my $url = $value_split[0]; my @filename_split = split(/\//, $value_split[0]); my $filename = $filename_split[(@filename_split)-1]; print "url: $url\n"; print "filename: $filename\n"; qx|wget -q -O /mnt/photos/flickr/$filename "$url"|; print "*"; } } } } print "\n"; }
FlickrGrab
Copyright (C) Andreas Schipplock
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Support for FlickrGrab
The easiest and most transparent way to get support is to use the mailing list provided by google. Just subscribe and mail your question or problem. Me or another nice guy or girl then is going to help you as much as possible. Just keep in mind that the primary language used there is english.
