arch bash cakephp dauth devops drupal fosdem foss git golang information age linux lua mail monitoring music n900 netlog openstack php productivity python real life thesis travel uzbl vimeo web2.0

A script that pulls photos from facebook

Fbcmd is pretty cool.
I quickly hacked this script together which pulls all photo albums from friends on facebook, so I have them available where I want. (It should also pull your own albums, but I don't have any so I can't check that)
Maybe there are better ways to do this. I looked at fbfs but it looks a bit weird. I have no idea what the corrupted images fuss is all about.

#!/bin/bash

dir=$HOME/fbphotos
cache=${XDG_CACHE_HOME:-$HOME/.cache}
[ -d $cache ] || mkdir $cache
[ -d $cache ] || exit 2
#fbcmd=`which fbcmd`
fbcmd='php /home/dieter/fbcmd/fbcmd.php'

echo "Fetching info about friends and myself .."
$fbcmd FRIENDS -csv | tail -n '+2' > $cache/fb-users # ID NAME
$fbcmd WHOAMI  -csv >> $cache/fb-users

while read line
do
        uid=`  cut -d ',' -f 1 <<< "$line"`
        uname=`cut -d ',' -f 2 <<< "$line"`
        echo "Fetching list of albums for user $uname ... "
        $fbcmd ALBUMS $uid -csv | tail -n '+2' > $cache/fb-$uid-albums #OWNER_NAME AID NAME SIZE
done < $cache/fb-users

for i in $cache/fb-*-albums
do
        while read line
        do
                oname=`cut -d ',' -f 1 <<< "$line"`
                aid=`  cut -d ',' -f 2 <<< "$line"`
                aname=`cut -d ',' -f 3 <<< "$line"`
                asize=`cut -d ',' -f 4 <<< "$line"`
                echo "Fetching $oname album: $aname"
                $fbcmd APICS $aid $dir -psize=1 -af="$oname-$aname/[pid].jpg" -pic_skip_exists=1
        done < $i
done

Here's a picture from Counting cows I grabbed from Lievens album.

Comments

Dieter,

How do i run this script in windows , I made a php file with this code but it does not run in php.

Varada

my code is in bash. it needs a bash shell. fbcmd is php though.


Name:


E-mail:


URL:


Comment:


What is the first name of the guy blogging here?


This comment form is pretty crude. Make sure mandatory fields are entered correctly.
Basic html tags (a,i,b, etc) are allowed, others are sanitized