comparison bin/moefetch @ 302:b90ebadbfd5d

Forgot the other wget.
author Edho Arief <edho@myconan.net>
date Thu, 09 Feb 2012 09:12:18 +0700
parents 36bc27bb32ff
children 21b86001b0c5
comparison
equal deleted inserted replaced
301:36bc27bb32ff 302:b90ebadbfd5d
32 # Leave empty to use whatever folder you're running this at 32 # Leave empty to use whatever folder you're running this at
33 BASE_DIR= 33 BASE_DIR=
34 34
35 # not user modifiable from here 35 # not user modifiable from here
36 36
37 useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0"
38
37 # useless welcome message. Also version 39 # useless welcome message. Also version
38 msg_welcome() { 40 msg_welcome() {
39 echo "moefetch ${_version} 41 echo "moefetch ${_version}
40 Copyright (c) 2009-2012 edogawaconan <edho@myconan.net> 42 Copyright (c) 2009-2012 edogawaconan <edho@myconan.net>
41 " 43 "
112 Generate_Link() { 114 Generate_Link() {
113 echo " 115 echo "
114 Fetching XML file" 116 Fetching XML file"
115 tempnum=1000 117 tempnum=1000
116 iternum=1 118 iternum=1
117 useragent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0"
118 > "${TEMP_PREFIX}-list" 119 > "${TEMP_PREFIX}-list"
119 while [ "${tempnum}" -ge 1000 ]; do 120 while [ "${tempnum}" -ge 1000 ]; do
120 url="http://${SITE}/post/index.xml?tags=$(get_cleantags "${TAGS}")&offset=0&limit=1000&page=${iternum}" 121 url="http://${SITE}/post/index.xml?tags=$(get_cleantags "${TAGS}")&offset=0&limit=1000&page=${iternum}"
121 [ ${_use_login} -eq 1 ] && url="${url}&login=${LOGIN_USER}&password_hash=${LOGIN_PASS}" 122 [ ${_use_login} -eq 1 ] && url="${url}&login=${LOGIN_USER}&password_hash=${LOGIN_PASS}"
122 wget --quiet "${url}" -O "${TEMP_PREFIX}-xml" --referer="http://${SITE}/post" --user-agent="${useragent}" -e continue=off || Err_Fatal "Failed download catalog file" 123 wget --quiet "${url}" -O "${TEMP_PREFIX}-xml" --referer="http://${SITE}/post" --user-agent="${useragent}" -e continue=off || Err_Fatal "Failed download catalog file"
302 if [ "$(grep -c . "${TEMP_PREFIX}-newlist")" -eq 0 ]; then 303 if [ "$(grep -c . "${TEMP_PREFIX}-newlist")" -eq 0 ]; then
303 echo "No new file" 304 echo "No new file"
304 else 305 else
305 printf "Downloading files... " 306 printf "Downloading files... "
306 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" 307 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}"
307 wget -e continue=on -i "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" 308 wget -e continue=on -i "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" --referer="http://${SITE}/post" --user-agent="${useragent}"
308 fi 309 fi
309 } 310 }
310 311
311 # initialize base variables and initial command check 312 # initialize base variables and initial command check
312 init() 313 init()