Differences between current version and predecessor to the previous major change of KnowledgeBase/Scripts/e621.

Other diffs: Previous Revision, Previous Author

Newer page: version 8 Last edited on Sunday, 12 September 2010 18:49:06 by CyberLeo
Older page: version 7 Last edited on Monday, 26 July 2010 2:52:10 by CyberLeo Revert
@@ -2,9 +2,9 @@
 # <post> : Emit the file download url for a given post 
 e621_post_to_link() { 
  post="${1}" 
  [ "${post}" ] || return 1 
- wget -qO- "http://www. e621.net/post/show/${post}" | sed -e '/class ="original-file-\(\|un\)changed" /!d; s/^.* href="//g; s/ " class= ".*$//g
+ wget -qO- "http://e621.net/post/show/${post}" | sed -e '/<li>Size: <a href =/!d; s/^.*<a[^h] *href="\([^ "]*\) " .*$/\1 /' 
 
  
 # <post> [filename] : Download the given post, optionally specifying a name 
 # if the name lacks an extension, use that of the original url 
@@ -17,18 +17,18 @@
  if echo "${file}" | grep -vq "\." 
  then 
  file="${file}.${ext}" 
  fi 
- wget -O "${file}" --referer="http://www. e621.net/post/show/${post}" "${url}" 
+ wget -O "${file}" --referer="http://e621.net/post/show/${post}" "${url}" 
  sleep 0.5 
 
  
 # <pool> : Emit a list of posts in this pool 
 # does not yet handle multipage pools 
 e621_pool_posts() { 
  pool="${1}" 
  [ "${pool}" ] || return 1 
- wget -qO- "http://www. e621.net/pool/show/${pool}" | sed -e '/class="plid"/!d; s/^. *\#pl //g; s/< \/span. *$ //g ; s/^.*\/ \([^\/ ]*\)$/\1/g
+ wget -qO- "http://e621.net/pool/show/${pool}" | cat tmp | sed -e '/<span class="*\(thumb \| thumb \| thumb\) *" /!d ; s/^.* id="p \([0-9 ]*\)".* $/\1/' 
 
  
 # <pool> [start_count] : Download an entire pool, naming the files sequentially 
 e621_download_pool() { 

current version

# <post> : Emit the file download url for a given post
e621_post_to_link() {
  post="${1}"
  [ "${post}" ] || return 1
  wget -qO- "http://e621.net/post/show/${post}" | sed -e '/<li>Size: <a href=/!d; s/^.*<a[^h]*href="\([^"]*\)" .*$/\1/'
}

# <post> [filename] : Download the given post, optionally specifying a name
#  if the name lacks an extension, use that of the original url
e621_download_post() {
  post="${1}"
  [ "${post}" ] || return 1
  url="$(e621_post_to_link "${post}")"
  eval $(echo "${url}" | sed -e 's/\?.*$//; s/^.*\///g; s/^\(.*\.\([^.]*\)\)$/file="\1" ext="\2"/')
  file="${2:-${file}}"
  if echo "${file}" | grep -vq "\."
  then
    file="${file}.${ext}"
  fi
  wget -O "${file}" --referer="http://e621.net/post/show/${post}" "${url}"
  sleep 0.5
}

# <pool> : Emit a list of posts in this pool
#  does not yet handle multipage pools
e621_pool_posts() {
  pool="${1}"
  [ "${pool}" ] || return 1
  wget -qO- "http://e621.net/pool/show/${pool}" | cat tmp | sed -e '/<span class="*\(thumb \| thumb \| thumb\)*"/!d; s/^.* id="p\([0-9]*\)".*$/\1/'
}

# <pool> [start_count] : Download an entire pool, naming the files sequentially
e621_download_pool() {
  pool="${1}"
  [ "${pool}" ] || return 1
  count="${2:-0}"
  e621_pool_posts "${pool}" | while read post
  do
    name="$(printf "%02u" "${count}")"
    e621_download_post "${post}" "${name}"
    count=$(( ${count} + 1 ))
  done
}