From Innocent Finch, 2 Weeks ago, written in Plain Text.
  1. #!/bin/sh
  2.  
  3. curl -s -L "$1"|nawk -v RS='<meta ' -F '"' '
  4.  
  5.   BEGIN{
  6.     while((getline)>0)
  7.       {buf[NR]=$0
  8.       {if($2=="og:type") ogtype=$4}
  9.       {if($2=="og:video") ogvideo=$4}
  10.       {if($2=="og:image") ogimage=$4}}
  11.   }
  12.  
  13.   END{
  14.       {if(ogtype=="video.other")
  15.           {if(ogvideo) {printf("%s\n",ogvideo);exit}
  16.           else
  17.           {if(ogimage) {sub(/\?.*$/, "", ogimage); printf("%s\n",ogimage); exit}}}
  18.       }
  19.  
  20.       {if(ogtype=="article")
  21.           {if(ogimage)
  22.             {sub(/\?.*$/, "", ogimage); printf("%s\n",ogimage); exit}}
  23.       }
  24.   }
  25. '
captcha