1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# source: http://www.4geeksfromnet.com/2011/01/wallbase-download-wallpapers-the-easy-way.html
# 
# This script gets the beautiful wallpapers from http://wallbase.cc
# This script is brought to you by [email protected]
# and at present is actively maintained by MacEarl
#
#
# Revision 2.2
# 1. Source Cleanup by Axa-Ru
# 2. Fixed Download Code for new System
# 3. Improved the check for already downloaded Files (much faster <img src="http://www.4geeksfromnet.com/wp-includes/images/smilies/icon_wink.gif" alt=";)" class="wp-smiley"> )
#
#
# Revision 2.1
# 1. Added a Feature to download "Your Favorites"
# 2. Added a Feature to download "user created collections"
# 3. Rewrote the check for already downloaded Files
#    (You now can rename or remove Wallpapers and they dont get downloaded again.
#     Eg. If you don''t like a wallpaper, just delete it and it won''t get downloaded again.
#     To re-enable the download of a specific Wallpaper you need to remove the
#     Wallpaper number from the file "downloaded.txt")
#
#
# Revision 2.0
# Contributed by MacEarl
# 1. Rewritten code for new Wallbase System
#
#
# Revision 1.2.1
# Contributed by MacEarl
# 1. Added Login Check for new Wallpapers
#
#
# Revision 1.2
# Contributed by MacEarl
# 1. Added a login feature to download NSFW content/category
#
#
# Revision 1.1.1
# Contributed by Hab
# 1. Updated mkdir option with -p flag
#
#
# Revision 1.1
# Contributed by MacEarl
# 1. Added a Search Function
# 2. Added a check for already existing Files
# 3. Fixed a bug (imageshack mirrored files)
#
#
# Revision 1.0
# Contributed by MacEarl
# 1. Added the much needed fixes for NSFW category
# 2. Updated the script with more options
# 3. Modified the script
#
#
#
# Wallpapers can be sorted according to
#
###############################
### Section 1 :: Resolution ###
###############################
#
# Resolution
#   Accepted values are 0 => All Standard
#       800x600 | 1024x768 | 1280x960 | 1280x1024 | 1400x1050 | 1600x1200 | 2560x2048
#   Widescreen
#       1024x600 | 1280x800 | 1366x768 | 1440x900 | 1600x900 | 1680x1050 | 1920x1080 | 1920x1200 | 2560x1440 | 2560x1600
#
#################################
### Section 2 :: Aspect Ratio ###
#################################
#
# Aspect Ratio
#   Accepted values are 0 => All
#   1.33 => 4:3
#   1.25 => 5:4
#   1.77 => 16:9
#   1.60 => 16:10
#   1.70 => Netbook
#   2.50 => Dual
#   3.20 => Dual Wide
#   0.99 => Portrait
#
###############################
### Section 3 :: Category   ###
###############################
#
# Category : SFW, Sketchy, NSFW
# Each being toggled by a 1/0 value
#   So to get only SFW use 100
#   To get all categories use 111
#   To get Sketchy and NSFW use 011
#
###############################
### Section 4 :: Topic      ###
###############################
#
# Topic : Anime/Manga, Wallpapers/General, High Resolution Images
#   To get Anime/Manga use 1
#   To get Wallpapers/General use 2
#   To get HR Images use 3
#   To get all use 123
#   To get only HR and WP use 23 and so on
#
###############################
### Section 5 :: Size       ###
###############################
#
# Size: at least and Exactly width x height
#   To get at least desired Resolution use gteq
#   To get exactly desired Resolution use eqeq
#
###############################
### Section 6 :: THPP       ###
###############################
#
# Thumbnails per page.
#  Accepted values are 20, 32, 40, 60
#
###############################
### Section 7 :: Location   ###
###############################
#
# The download location Foldername of desired Location e.g. "Wallpapers"
#
###############################
### Section 8 :: Best of    ###
###############################
#
# Best of:
#  All time = 0
#  3Months  = 3m
#  2Months  = 2m
#  1Month   = 1m
#  2Weeks   = 2w
#  1Week    = 1w
#  3Days    = 3d
#  1Day     = 1d
#
###############################
### Section 9 :: Type       ###
###############################
#
# Random                    = 1
# Toplist                   = 2
# Newest                    = 3
# Search                    = 4
# Favourites                = 5
# User created collections  = 6
#
###############################
### Section 10 :: Order     ###
###############################
#
# Date                  = date
# Amount of Views       = views
# Number of Favorites   = favs
# Relevancie            = relevance
#
###############################
### Section 11 :: OrderType ###
###############################
#
# The following two Options are possible:
#  Ascending    = asc
#  Descending   = desc
#
###############################
### Section 12 :: Search    ###
###############################
# Define your Search Query like this:
#  ./wallbase.sh Mario
#  For longer Search Queries you need to set QUERY manually
#  For Example set QUERY="Link OR Zelda OR Legend of Zelda OR OoT"
#  Accepted Operators are "AND" and "OR"
#
###############################
### Section 13 :: Login  ######
###############################
# Due to changes in the wallbase.cc "Policy"
#  you now need to login to see NSFW Content
#  Please provide your Username and Password below
#  to download NSFW content
#  It is also needed if you want to download "your own Favorites" (Duh!)
#
###############################
### Section 14 :: Collection###
###############################
# This Option is used for downloading your Favorites (You need an account for the same)
#  and to download Collections created by other users
#  Set the value to "-1" to download your Favorites in your "Home" Collection.
#  To download User Collections or different Favorite Collections open the desired
#  Collection in your Browser and copy the following part
#  1. For your Favorites: http://wallbase.cc/user/favorites/"#number_of_the_collection"
#  2. For user created collections: http://wallbase.cc/user/collection/"#number_of_the_collection"
#  You only need the number which is shown at the end of the URL
#
###############################
### Needed for NSFW/New     ###
###############################
 
# See Section 14
# Enter your Username
USER=yourusername
# Enter your password
PASS=yourpassword
 
###############################
### End needed for NSFW/New ###
###############################
 
###############################
### Configuration Options   ###
###############################
 
# Define the maximum number of wallpapers that you would like to download MAX_RANGE=26460
MAX_RANGE=240
# For accepted values of resolution see Section 1
RESOLUTION=0
# For accepted values of aspect ratio see Section 2
ASPECTRATIO=0
# For accepted values of category see Section 3
CATEGORY=001
# For accepted values of topic see Section 4
TOPIC=123
# For accepted values for SIZE see Section 5
SIZE=gteq
# For accepted Thumbnails per page see Section 6
THPP=60
# For download location see Section 7
LOCATION=/location/to_your/wallpapers_folder
# Best of : see Section 8
TIME=0
# For Types see Section 9
TYPE=1
# For order Options see Section 10
ORDER=relevance
# See Section 11
ORDER_TYPE=desc
# See Section 12
QUERY="$1"
# See Section 13
COLLECTION=-1
 
###############################
## End Configuration Options ##
###############################
 
mkdir -p $LOCATION
cd "$LOCATION"
 
if [ $CATEGORY == 001 ] || [ $CATEGORY == 011 ] || [ $CATEGORY == 111 ] || [$TYPE == 3 ] || [$TYPE == 5 ] || [$TYPE == 6 ] ; then
    if [ $USER == yourusername ] ; then
        echo "Please check the needed Options for NSFW/New Content (username and password)"
        echo ""
        echo "For further Information see Section 14"
        echo ""
        echo "Press any key to exit"
        read
        exit
    fi
    echo "username=$USER&pass=$PASS&nopass_email=Type+in+your+e-mail+and+press+enter&nopass=0&1=1" > login
    wget --keep-session-cookies --save-cookies=cookies.txt --referer=http://wallbase.cc/start/ --post-file=login http://wallbase.cc/user/login
    wget --keep-session-cookies --load-cookies=cookies.txt --save-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/user/adult_confirm/1
    rm index.html
fi
 
if [ $TYPE == 1 ] ; then
 
    for (( count= 0; count< "$MAX_RANGE"; count=count+"$THPP" ));
        do
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/random/$TOPIC/$SIZE/$RESOLUTION/$ASPECTRATIO/$CATEGORY/$THPP
        URLSFORIMAGES="$(cat $THPP | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $THPP
        done
 
else
 
if [ $TYPE == 2 ] ; then
 
    for (( count= 0; count< "$MAX_RANGE"; count=count+"$THPP" ));
        do
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/toplist/$count/$TOPIC/$SIZE/$RESOLUTION/$ASPECTRATIO/$CATEGORY/$THPP/$TIME
        URLSFORIMAGES="$(cat $TIME | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $TIME
        done
 
else
 
if [ $TYPE == 3 ] ; then
 
    for (( count= 0; count< "$MAX_RANGE"; count=count+"$THPP" ));
        do
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/search/$count/$TOPIC/$SIZE/$RESOLUTION/$ASPECTRATIO/$CATEGORY/$THPP
        URLSFORIMAGES="$(cat $THPP | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $THPP
        done
 
else
 
if [ $TYPE == 4 ] ; then
 
    echo "query=$QUERY&board=$TOPIC&nsfw=$CATEGORY&res=$RESOLUTION&res_opt=$SIZE&aspect=$ASPECTRATIO&orderby=$ORDER&orderby_opt=$ORDER_TYPE&thpp=$THPP&section=wallpapers&1=1" > data
    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc/ --post-file=data http://wallbase.cc/search/
    URLSFORIMAGES="$(cat index.html | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
    rm index.html
 
    (( nsfw_sfw=(10#$CATEGORY / 100) ))
    (( nsfw_sketchy=(10#$CATEGORY % 100 / 10) ))
    (( nsfw_nsfw=(10#$CATEGORY % 10) ))
 
    for (( count= $THPP; count< "$MAX_RANGE"; count=count+"$THPP" ));
        do
        rm data
        echo "query=$QUERY&board=$TOPIC&res_opt=$SIZE&res=$RESOLUTION&aspect=$ASPECTRATIO&nsfw_sfw=$nsfw_sfw&nsfw_sketchy=$nsfw_sketchy&nsfw_nsfw=$nsfw_nsfw&thpp=$THPP&orderby=$ORDER&orderby_opt=$ORDER_TYPE&section=wallpapers&1=1" > data
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc/search --post-file=data http://wallbase.cc/search/$count
        URLSFORIMAGES="$(cat $count | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $count
        done
    rm data
 
else
 
if [ $TYPE == 5 ] ; then
    for (( count= 0; count< "$MAX_RANGE"; count=count+"32" ));
        do
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/user/favorites/$COLLECTION/$count
        URLSFORIMAGES="$(cat $count | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $count
        done
 
else
 
if [ $TYPE == 6 ] ; then
    for (( count= 0; count< "$MAX_RANGE"; count=count+"32" ));
        do
        wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc http://wallbase.cc/user/collection/$COLLECTION/1/$count
        URLSFORIMAGES="$(cat $count | grep -o "http:.*" | cut -d " " -f 1 | grep wallpaper)"
        for imgURL in $URLSFORIMAGES
            do
            img="$(echo $imgURL | sed 's/.\{1\}$//')"
            number="$(echo $img | sed  's .\{29\}  ')"
            if cat downloaded.txt | grep "$number" >/dev/null
                then
                    echo "File already downloaded!"
                else
                    echo $number >> downloaded.txt
                    wget --keep-session-cookies --load-cookies=cookies.txt --referer=wallbase.cc $img
                    cat $number | egrep -o "http:.*(gif|png|jpg)" | egrep "wallbase2|imageshack.us|ovh.net" | wget --keep-session-cookies --load-cookies=cookies.txt --referer=http://wallbase.cc/wallpaper/$number -i -
                    rm $number
            fi
            done
        rm $count
        done
else
 
echo error in TYPE please check Variable
 
fi
fi
fi
fi
fi
fi
 
rm "1" "cookies.txt" "login"