Last active
August 5, 2016 19:34
-
-
Save JesseWeinstein/cd013b8fc5f843b6ef45788931c7c434 to your computer and use it in GitHub Desktop.
Wikimedia Commons status update script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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