Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emijrp/c9003dd11de06bd3d760e5d2261f77ac to your computer and use it in GitHub Desktop.
Save emijrp/c9003dd11de06bd3d760e5d2261f77ac 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