Jump to content

User:Rick Bot/scripts/update byyear

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

# update a by-year FA nomination list
# assumes the following files have been recently updated:
#     featureds
#     formers
#     maindate.all

# get all the articles nominated for the given year 
YEAR="$1"
if [ "$1" = "" ];  then
  YEAR=2007
fi

/usr/bin/curl "http://wiki.riteme.site/w/index.php?title=Wikipedia:Featured_articles_promoted_in_${YEAR}&action=raw" 2>/dev/null | awk >FAnoms.$YEAR '

BEGIN {
  FS="\\|\\|"
  OFS="||"
  while ( getline <"featureds" ) {
    featured[$2] = 1
  }
  while ( getline <"formers" ) {
    former[$2] = 1
  }
  while ( getline <"maindate.all" ) {
    maindate[$3] = $2
  }
}


/^\|\|/ {
  article=$2
  sub("<s>","",article)
  sub("</s>","",article)
  sub("^[ ]*","",article)
  sub("[ ]*$","",article)
  justarticle=article
  sub("\\|.*]]","]]",justarticle)
  sub("^[^[]*[[][[]","",justarticle)
  sub("]].*$","",justarticle)
  if (featured[justarticle] != 1 && former[justarticle] != 1 && justarticle != "Provinces of Thailand" && justarticle != "Pumping lemma" && justarticle != "History of South Carolina") {
    printf "%s", "*** Nom history, but not FA or FFA - " justarticle ": " >"/dev/stderr"
    getline answer <"/dev/stderr"
    if (answer != "") {
      justarticle = answer
      article = "[[" answer "]]"
      $2 = article
    }
  }
  $3 = " " maindate[justarticle] " "
  if (featured[justarticle] == 1) {
    print "|| " article " ||" $3 "||" $4
  } else {
    print "|| <s>" article "</s> ||" $3 "||" $4
    if (former[justarticle] != 1) {
      print article >>"neverFA"
    }
  }
  next
}

{
  print $0
}
'