29 Nov 2009

[New toy] Download HD wallpaper

Last night I went around the Internet to find some good wallpapers for my 1650*1050 laptop screen, then I found a good place with many wps divided into many types, and ready to be downloaded. One problem everyone will get is they just provide link to download 1 wallpaper at a time, so this script came out :).
I'm actually not a programmer, I write script just to make thing work, then it works, that's all. If someone can make it better, please let me know.
At the end, enjoy!
update 1: python script
#/usr/bin/env python
# hungnv coded
# Usage: hdwp.py then choose type
import os
types = ['abstract', 'computer', 'nature', 'travel', 'cars', 'celerbrities', 'animal']
def _getlink(bi, num, prefix):
        address = 'http://www.hdwallpapers.net/gallery/wallpapers/'
        final = (address + '%s' + '/%s%s%s.zip') %(bi, bi, prefix, num)
        return final
def downloader(_xx_):
        link = _getlink(x, i, _xx_)
        print 'Link is: %s' %link
        osvn = 'wget '+_getlink(x, i, _xx_)+' '
        os.system(osvn)
if __name__=='__main__':
        for i in range(len(types)):
                print i+1,'.',types[i]
        x = raw_input('Choose which type of wp you want to download: ')            
        if x in types:
                for i in range(1,108):
                        if i < 10:
                                _pref = '_000'
                                downloader(_pref)
                        elif i > 9 and i < 100:
                                _pref = '_00'
                                downloader(_pref)
                        else:
                                _pref = '_0'
                                downloader(_pref)
        else:
                print 'plz choose type again'
exit()
 Usage: copy and save it whatever name you want, chmod +x then run, enter your choice, wait until it finished. Update 0: I modified to make it sorter.

#/bin/bash

#Script to Download HD wallpaper from http://www.hdwallpapers.net

#hungnv@opensource.com.vn

url="http://www.hdwallpapers.net/gallery/wallpapers/"

pref="_00"

pref1="_000"

pref2="_0"

x[1]="abstract"

x[2]="cars"

x[3]="celeb"

x[4]="computer"

x[5]="animal"

x[6]="nature"

x[7]="travel"

echo -e "\t\t\n           1. Abstract

   2. Cars

   3. Celerbities

   4. Computer

   5. Animal

   6. Nature

   7. Travel

   " 

read -p 'Enter type of wallpaper you want to download: ' type

#for j in $(seq 1 7)

for ((j=0; j&lt;8; j++))
 do
 if [ $type -eq $j ]
 then
  echo Your photo is being downloaded...
  for ((i=1; i&lt;109; i++))
   do
    if [ $i -lt 10 ] 
    then
     wget -O ${x[`echo $j`]}_$i.zip $url${x[`echo $j`]}/${x[`echo $j`]}$pref1$i.zip
      if test ! -s  "${x[`echo $j`]}_$i.zip" 
       then rm -f "${x[`echo $j`]}_$i.zip"
      fi
    elif [ $i -lt 100 ] 
    then
     wget -O ${x[`echo $j`]}_$i.zip $url${x[`echo $j`]}/${x[`echo $j`]}$pref$i.zip
      if test ! -s  "${x[`echo $j`]}_$i.zip" 
       then rm -f "${x[`echo $j`]}_$i.zip"
      fi
    else
     wget -O ${x[`echo $j`]}_$i.zip $url${x[`echo $j`]}/${x[`echo $j`]}$pref2$i.zip
      if test ! -s  "${x[`echo $j`]}_$i.zip" 
       then rm -f "${x[`echo $j`]}_$i.zip"
      fi
    fi
   done
 fi
done
exit 0

No comments:

Disqus