From Gamboge Duck, 3 Months 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. '
  26.  
  27.  
  28. #curl -s -L "$1"|nawk -v RS='<meta property=' -F '"' '
  29. #  #function get(type){while((getline)>0){if($2=="og:"type)printf(" -> %s\n",$4)}}
  30. #  function get(type) {
  31. #    while((getline)>0)
  32. #      {if($2=="og:"type)
  33. #        printf("%s\n",$4)}
  34. #  }
  35. #
  36. #  $2=="og:image"{ogimage=$4; sub(/\?.*$/, "", ogimage)}
  37. #
  38. #  #$2=="og:type"{printf("%s :: %s",$2,$4)
  39. #  $2=="og:type"{
  40. #    {if($4~/video/) {get("video");exit}}
  41. #    {if($4~/image/) {get("image");exit}}
  42. #    {if($4=="article") {printf("%s\n",ogimage);exit}}
  43. #  }
  44. #'
  45. #
captcha