Mercurial > ec-dotfiles
comparison moefetch.sh @ 231:4c0fd276665e
- for some reason I broke the getopts logic again. Fixed
author | edhoprima |
---|---|
date | Sat, 13 Mar 2010 20:42:01 +0000 |
parents | e922fb1e858f |
children | 5438d80244a3 |
comparison
equal
deleted
inserted
replaced
230:e922fb1e858f | 231:4c0fd276665e |
---|---|
124 __iternum=1 | 124 __iternum=1 |
125 > "${TEMP_PREFIX}-list" | 125 > "${TEMP_PREFIX}-list" |
126 while [ "${__tempnum}" -ge 1000 ]; do | 126 while [ "${__tempnum}" -ge 1000 ]; do |
127 __url="http://${SITE}/post/index.xml?tags=$(get_cleantags "${TAGS}")&offset=0&limit=1000&page=${__iternum}" | 127 __url="http://${SITE}/post/index.xml?tags=$(get_cleantags "${TAGS}")&offset=0&limit=1000&page=${__iternum}" |
128 [ ${_use_login} -eq 1 ] && __url="${__url}&login=${LOGIN_USER}&password_hash=${LOGIN_PASS}" | 128 [ ${_use_login} -eq 1 ] && __url="${__url}&login=${LOGIN_USER}&password_hash=${LOGIN_PASS}" |
129 wget "${__url}" -O "${TEMP_PREFIX}-xml" -e continue=off || Err_Fatal "Failed download catalog file" | 129 wget --quiet "${__url}" -O "${TEMP_PREFIX}-xml" -e continue=off || Err_Fatal "Failed download catalog file" |
130 printf "Processing XML file... " | 130 printf "Processing XML file... " |
131 # xslt evilry | 131 # xslt evilry |
132 xsltproc - "${TEMP_PREFIX}-xml" <<EOF | sed 's/.*\(http.*\)\(\/[a-f0-9]\{32\}\).*\.\([^\.]*\)/\1\2.\3/g' | grep ^http > "${TEMP_PREFIX}-templist" | 132 xsltproc - "${TEMP_PREFIX}-xml" <<EOF | sed 's/.*\(http.*\)\(\/[a-f0-9]\{32\}\).*\.\([^\.]*\)/\1\2.\3/g' | grep ^http > "${TEMP_PREFIX}-templist" |
133 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | 133 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
134 <xsl:output method="xml" indent="yes"/> | 134 <xsl:output method="xml" indent="yes"/> |
305 # start downloading the images | 305 # start downloading the images |
306 Fetch_Images() { | 306 Fetch_Images() { |
307 if [ "$(echo $(wc -l < "${TEMP_PREFIX}-newlist"))" -eq 0 ]; then | 307 if [ "$(echo $(wc -l < "${TEMP_PREFIX}-newlist"))" -eq 0 ]; then |
308 echo "No new file" | 308 echo "No new file" |
309 else | 309 else |
310 printf "Starting wget... " | 310 printf "Downloading files... " |
311 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | 311 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" |
312 wget -e continue=on -bi "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" | 312 wget -e continue=on -i "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" |
313 fi | 313 fi |
314 } | 314 } |
315 | 315 |
316 # initialize base variables and initial command check | 316 # initialize base variables and initial command check |
317 init() | 317 init() |
343 shift | 343 shift |
344 SITE= | 344 SITE= |
345 TAGS= | 345 TAGS= |
346 __has_pass=0 | 346 __has_pass=0 |
347 __has_user=0 | 347 __has_user=0 |
348 while getopts "s:(site)n(noclean)u:(user)p:(password)" opt | 348 x=1 |
349 while getopts "s:nu:p:" opt | |
349 do | 350 do |
350 case "$opt" in | 351 case "$opt" in |
351 s) SITE="$OPTARG";; | 352 s) SITE="$OPTARG";; |
352 n) NOCLEAN=1;; | 353 n) NOCLEAN=1;; |
353 p) | 354 p) |
357 u) | 358 u) |
358 LOGIN_USER="$OPTARG" | 359 LOGIN_USER="$OPTARG" |
359 __has_user=1 | 360 __has_user=1 |
360 ;; | 361 ;; |
361 esac | 362 esac |
362 done | 363 x=$OPTIND |
364 done | |
365 shift $(($x-1)) | |
366 if [ "$1" = -- ]; then shift; fi | |
363 TAGS="$@" | 367 TAGS="$@" |
364 [ -n "${SITE}" ] || SITE=${DEFAULT_SITE} | 368 [ -n "${SITE}" ] || SITE=${DEFAULT_SITE} |
365 [ -n "${TAGS}" ] || Err_Fatal "No tag specified" | 369 [ -n "${TAGS}" ] || Err_Fatal "No tag specified" |
366 # Get base folder - default, current folder or fallback to ${HOME} | 370 # Get base folder - default, current folder or fallback to ${HOME} |
367 [ -n "${BASE_DIR}" ] || BASE_DIR=${PWD} | 371 [ -n "${BASE_DIR}" ] || BASE_DIR=${PWD} |