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.

  1. #!/bin/bash
  2.  
  3. dir=$HOME/fbphotos
  4. cache=${XDG_CACHE_HOME:-$HOME/.cache}
  5. [ -d $cache ] || mkdir $cache
  6. [ -d $cache ] || exit 2
  7. #fbcmd=`which fbcmd`
  8. fbcmd='php /home/dieter/fbcmd/fbcmd.php'
  9.  
  10. echo "Fetching info about friends and myself .."
  11. $fbcmd FRIENDS -csv | tail -n '+2' > $cache/fb-users # ID NAME
  12. $fbcmd WHOAMI -csv >> $cache/fb-users
  13.  
  14. while read line
  15. do
  16. uid=` cut -d ',' -f 1 <<< "$line"`
  17. uname=`cut -d ',' -f 2 <<< "$line"`
  18. echo "Fetching list of albums for user $uname ... "
  19. $fbcmd ALBUMS $uid -csv | tail -n '+2' > $cache/fb-$uid-albums #OWNER_NAME AID NAME SIZE
  20. done < $cache/fb-users
  21.  
  22. for i in $cache/fb-*-albums
  23. do
  24. while read line
  25. do
  26. oname=`cut -d ',' -f 1 <<< "$line"`
  27. aid=` cut -d ',' -f 2 <<< "$line"`
  28. aname=`cut -d ',' -f 3 <<< "$line"`
  29. asize=`cut -d ',' -f 4 <<< "$line"`
  30. echo "Fetching $oname album: $aname"
  31. $fbcmd APICS $aid $dir -psize=1 -af="$oname-$aname/[pid].jpg" -pic_skip_exists=1
  32. done < $i
  33. done

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

Trackback URL for this post:

http://dieter.plaetinck.be/trackback/71
Submitted by Dieter_be on Tue, 08/18/2009 - 17:36. categories [ ]

How do I run this script in windows?

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

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. Beside the tag style "<foo>" it is also possible to use "[foo]". PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Security question, designed to stop automated spam bots