Jump to content

User:Rick Bot/scripts/get featureds

From Wikipedia, the free encyclopedia
#!/bin/bash

PAGE="http://wiki.riteme.site/w/index.php?title=Wikipedia:Featured_articles&action=raw"
if [ "$1" != "" ]; then
  PAGE="${PAGE}&oldid=$1"
fi

# get the current featureds
/usr/bin/curl "$PAGE" 2>/dev/null | awk '

/^[[][[]Category:/ {
  nextfile
}

/[Aa]rchaeology/ {
  started=1
}

/Mathematics/ {
  started=1
}

(started == "") {
  next
}

/[[][[]/ {
  split($0,arts,"[[][[]")
  for (art in arts) {
    if (art == 1 )  {
      continue
    }
    fa = arts[art]
    sub("]].*","",fa)
    sub("[|].*","",fa)
    if ( substr(fa,1,1) == "#" ) {
      next
    }
    if (fa ~ /^Image:/) {
      next
    }
    if (fa ~ /^WP:/) {
      next
    }
    if (fa ~ /^[Ww]ikipedia:/) {
      next
    }
    if (fa ~ /^[Tt]emplate:/) {
      next
    }
    if (fa ~ /^[Mm]edia[Ww]iki:/) {
      next
    }
    if (fa ~ /^[Hh]elp:/) {
      next
    }
    if (fa == "Main Page") {
      next
    }
    if (fa == "be bold") {
      next
    }
    if (fa ~ /^..:/) {
      next
    }
    print "FEATURED||" fa
  }
}' >featureds