From Tiny Motmot, 1 Week ago, written in Plain Text.
  1. #!/bin/awk -f
  2. # desc: resolve actual file path for imgur.com
  3. # usage: imgur URL
  4.  
  5. BEGIN{
  6.   RS="<meta "; FS="\""
  7.   curl=sprintf("curl -sL %s", ARGV[1]);
  8.   while((curl | getline)>0)
  9.     {buf[NR]=$0
  10.     {if($2=="og:type") ogtype=$4}
  11.     {if($2=="og:video") ogvideo=$4}
  12.     {if($2=="og:image") ogimage=$4}}
  13.   exit
  14. }
  15.  
  16. END{
  17.     {if(ogtype=="video.other")
  18.         {if(ogvideo) {printf("%s\n",ogvideo);exit}
  19.         else
  20.         {if(ogimage) {sub(/\?.*$/, "", ogimage); printf("%s\n",ogimage); exit}}}
  21.     }
  22.  
  23.     {if(ogtype=="article")
  24.         {if(ogimage)
  25.           {sub(/\?.*$/, "", ogimage); printf("%s\n",ogimage); exit}}
  26.     }
  27. }
captcha