Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- sizes="o l z m"
- s=$(wget -q $1 -O -)
- for size in $sizes
- do
- p=$(echo $s | grep -o "$size: {.*url.*\.jpg', width" | grep -o 'http://farm[1-9].*.jpg')
- if [ ! -z $p ]; then
- break
- fi
- done
- #picture url empty?
- if [ -z $p ]; then
- echo "no picture url found"
- #page url not containing string 'sets'?
- if [ -z $(echo $1 | grep 'sets') ]; then
- echo "page doesnt seem to be a set either"
- #page url containing 'sets'?
- else
- arr=($(echo $1 | tr "/" "\n"))
- author=${arr[3]}
- set=${arr[5]}
- echo "trying to download complete set $set by $author:"
- title=$(echo $s | grep -o "title_div$set.*/h1" | grep -o ">.*<" | tr "<>" "\n")
- description=$(echo $s | grep -o "vsDescription.*<div class=\"vsNumbers\"> [1-9][0-9]*" | grep -o ">.*</div>" | sed 's/<br \/>/\n/g')
- echo $title
- dir=$(echo "$title by $author" | tr " /" "_-")
- counter=1
- while [ -d $dir ]; do
- counter=$(( counter+1 ))
- dir=$(echo "$title by $author" | tr " " "_")
- dir="$dir ($counter)"
- done
- if [ ! -d $dir ]; then
- echo "creating directory '$dir'"
- mkdir $dir
- fi
- cd $dir
- echo "$title" > description.txt
- echo $author >> description.txt
- echo $description >> description.txt
- links=$(echo $s | grep -o "/photos/$author/[0-9]*/in/set-$set")
- linklist=($(echo $links | tr " " "\n"))
- counter=1
- items=${#linklist[@]}
- echo "starting to download $items images"
- for link in $links
- do
- s=$(wget -q "http://www.flickr.com$link" -O -)
- for size in $sizes
- do
- p=$(echo $s | grep -o "$size: {.*url.*\.jpg', width" | grep -o 'http://farm[1-9].*.jpg')
- if [ ! -z $p ]; then
- break
- fi
- done
- if [ ! -z $p ]; then
- echo "$counter $p"
- wget -q $p
- else
- echo "no picture found"
- break
- fi
- ((counter=counter+1))
- done
- cd ..
- fi
- #picture url available
- else
- echo "downloading url: $p"
- wget $p -q
- fi
Add Comment
Please, Sign In to add comment