Skip to content

Instantly share code, notes, and snippets.

@JesseWeinstein
Last active August 5, 2016 19:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JesseWeinstein/cd013b8fc5f843b6ef45788931c7c434 to your computer and use it in GitHub Desktop.
Save JesseWeinstein/cd013b8fc5f843b6ef45788931c7c434 to your computer and use it in GitHub Desktop.
Wikimedia Commons status update script
import internetarchive.api as iaapi
import humanize
w=iaapi.get_item('wikimediacommons')
def extract(x):
s = x.identifier.split('-',1)
date = s[1] if '-' in s[1] else s[1][:4]+'-'+s[1][4:]
return ' |-\n | ' + ' || '.join((date, '{{IA id|'+x.identifier+'}}', str(x.files_count), humanize.naturalsize(x.item_size)))
rows=map(extract, w.contents())
output = """
{| class="wikitable sortable"
! Date !! Identifier !! Files !! Size
%s
|}""" % ('\n'.join(rows))
print(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment