Guest User

indy fotoset riotporn archivar

a guest
Apr 2nd, 2012
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. sizes="o l z m"
  4.  
  5. s=$(wget -q $1 -O -)
  6.  
  7. for size in $sizes
  8.     do
  9.         p=$(echo $s | grep -o "$size: {.*url.*\.jpg', width" | grep -o 'http://farm[1-9].*.jpg')
  10.         if [ ! -z $p ]; then
  11.             break
  12.         fi
  13.     done
  14.  
  15. #picture url empty?
  16. if [ -z $p ]; then
  17.     echo "no picture url found"
  18.    
  19.     #page url not containing string 'sets'?
  20.     if [ -z $(echo $1 | grep 'sets') ]; then
  21.         echo "page doesnt seem to be a set either"
  22.        
  23.     #page url containing 'sets'?   
  24.     else
  25.         arr=($(echo $1 | tr "/" "\n"))
  26.         author=${arr[3]}
  27.         set=${arr[5]}
  28.        
  29.         echo "trying to download complete set $set by $author:"
  30.        
  31.         title=$(echo $s | grep -o "title_div$set.*/h1" | grep -o ">.*<" | tr "<>" "\n")
  32.         description=$(echo $s | grep -o "vsDescription.*<div class=\"vsNumbers\"> [1-9][0-9]*" | grep -o ">.*</div>" | sed 's/<br \/>/\n/g')
  33.         echo $title
  34.        
  35.         dir=$(echo "$title by $author" | tr " /" "_-")
  36.         counter=1
  37.         while [ -d $dir ]; do
  38.             counter=$(( counter+1 ))
  39.             dir=$(echo "$title by $author" | tr " " "_")
  40.             dir="$dir ($counter)"
  41.         done
  42.        
  43.         if [ ! -d $dir ]; then
  44.             echo "creating directory '$dir'"
  45.             mkdir $dir
  46.         fi
  47.        
  48.         cd $dir
  49.        
  50.         echo "$title" > description.txt
  51.         echo $author >> description.txt
  52.         echo $description >> description.txt
  53.        
  54.         links=$(echo $s | grep -o "/photos/$author/[0-9]*/in/set-$set")
  55.         linklist=($(echo $links | tr " " "\n"))
  56.        
  57.         counter=1
  58.         items=${#linklist[@]}
  59.        
  60.         echo "starting to download $items images"
  61.         for link in $links
  62.             do
  63.                 s=$(wget -q "http://www.flickr.com$link" -O -)
  64.  
  65.                 for size in $sizes
  66.                     do
  67.                         p=$(echo $s | grep -o "$size: {.*url.*\.jpg', width" | grep -o 'http://farm[1-9].*.jpg')
  68.                         if [ ! -z $p ]; then
  69.                             break
  70.                         fi
  71.                     done               
  72.                    
  73.                 if [ ! -z $p ]; then
  74.                     echo "$counter $p"
  75.                     wget -q $p
  76.                 else
  77.                     echo "no picture found"
  78.                     break
  79.                 fi
  80.                
  81.                 ((counter=counter+1))
  82.             done
  83.            
  84.         cd ..
  85.        
  86.     fi
  87.    
  88. #picture url available
  89. else
  90.     echo "downloading url: $p"
  91.     wget $p -q
  92. fi
Add Comment
Please, Sign In to add comment