comparison moefetch.sh @ 213:dd95cf01602c

working around limit
author edhoprima@gmail.com <edhoprima@gmail.com>
date Tue, 30 Jun 2009 09:23:02 +0000
parents da4c03c7377c
children a6624fb9b317
comparison
equal deleted inserted replaced
212:da4c03c7377c 213:dd95cf01602c
82 } 82 }
83 83
84 # generate link by transforming xml 84 # generate link by transforming xml
85 Generate_Link() { 85 Generate_Link() {
86 printf "\nFetching xml file\n" 86 printf "\nFetching xml file\n"
87 wget "http://${SITE}/post/index.xml?tags=${TAGS}&offset=0&limit=100000" -O "${TEMP_PREFIX}-xml" -e continue=off 87 TEMPNUM=1001
88 printf "Processing XML file..." 88 _i=1
89 # xslt evilry
90 > "${TEMP_PREFIX}-list" 89 > "${TEMP_PREFIX}-list"
91 xsltproc - "${TEMP_PREFIX}-xml" <<EOF | sed 's/.*\(http.*\)\(\/[a-f0-9]\{32\}\).*\.\([^\.]*\)/\1\2.\3/g' | grep ^http > "${TEMP_PREFIX}-list" 2>/dev/null 90 while [ "${TEMPNUM}" -ge 1000 ]; do
91 wget "http://${SITE}/post/index.xml?tags=${TAGS}&offset=0&limit=1000&page=${_i}" -O "${TEMP_PREFIX}-xml" -e continue=off
92 printf "Processing XML file..."
93 # xslt evilry
94 > "${TEMP_PREFIX}-templist"
95 xsltproc - "${TEMP_PREFIX}-xml" <<EOF | sed 's/.*\(http.*\)\(\/[a-f0-9]\{32\}\).*\.\([^\.]*\)/\1\2.\3/g' | grep ^http > "${TEMP_PREFIX}-templist" 2>/dev/null
92 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 96 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
93 <xsl:output method="xml" indent="yes"/> 97 <xsl:output method="xml" indent="yes"/>
94 <xsl:template match="post"> 98 <xsl:template match="post">
95 <xsl:value-of select="@file_url" /> 99 <xsl:value-of select="@file_url" />
96 </xsl:template> 100 </xsl:template>
97 </xsl:stylesheet> 101 </xsl:stylesheet>
98 EOF 102 EOF
103 TEMPNUM=$(echo $(wc -l < "${TEMP_PREFIX}-templist"))
104 _i=$((_i+1))
105 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list"
106 done
99 NUMFILES=$(echo $(wc -l < "${TEMP_PREFIX}-list")) 107 NUMFILES=$(echo $(wc -l < "${TEMP_PREFIX}-list"))
100 [ "${NUMFILES}" -gt 0 ] || Err_Fatal "Error in processing list or no files can be found with specified tag(s) or site" 108 [ "${NUMFILES}" -gt 0 ] || Err_Fatal "Error in processing list or no files can be found with specified tag(s) or site"
101 echo " ${NUMFILES} file(s) available on server" 109 echo " ${NUMFILES} file(s) available on server"
102 #output file: ${TARGET_DIR}-list 110 #output file: ${TARGET_DIR}-list
103 } 111 }