Created
January 8, 2016 19:14
-
-
Save saerdnaer/bce64e9c3e406bee0829 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from collections import OrderedDict | |
import json | |
def main(): | |
#https://engelsystem.de/31c3/?p=shifts_json_export&key=7ae550dcafee0f084dc4e76d6d3088ca | |
#&start_day=2014-12-27&start_time=00%3A00&end_day=2014-12-30&end_time=23%3A59 | |
#&rooms[]=25&rooms[]=20&rooms[]=7&rooms[]=26&rooms[]=12&rooms[]=10&rooms[]=8&rooms[]=9&rooms[]=13&rooms[]=2&rooms[]=3&rooms[]=19&rooms[]=21&rooms[]=18&rooms[]=6&rooms[]=4&rooms[]=22&rooms[]=5&rooms[]=16&rooms[]=17&rooms[]=15&rooms[]=24&rooms[]=14&rooms[]=32&rooms[]=33&rooms[]=28&rooms[]=34&rooms[]=11&rooms[]=31&rooms[]=23 | |
#&types[]=34&types[]=33&types[]=11&types[]=12 | |
#&types[]=4&filled[]=1&filled[]=0&export=user_shifts | |
''' | |
Howto build this URL: | |
* get API Key: | |
* go to https://engelsystem.de/32c3/?p=users&action=view | |
* click JSON Export button | |
* get https://engelsystem.de/32c3/?p=shifts_json_export&key=XXXX | |
* build filter | |
* goto https://engelsystem.de/32c3/?p=user_shifts | |
* select | |
* 27. till 30. December | |
* Haal 1, 2, G, 6, VOC? | |
* occupied and free slots | |
* click 'Filter' | |
* convert URL from address bar to something more readable, eg, with http://urldecode.org | |
https://engelsystem.de/32c3/?p=user_shifts&start_day=2015-12-27&start_time=00:00&end_day=2015-12-30&end_time=23:59&rooms[]=30&rooms[]=32&rooms[]=33&rooms[]=31&rooms[]=40&types[]=15&types[]=18&filled[]=1&filled[]=0&new_style=1 | |
combine both urls and append &export=user_shifts : | |
https://engelsystem.de/32c3/?p=shifts_json_export&key=XXXXXX&start_time=00:00&end_day=2015-12-30&end_time=23:59&rooms[]=30&rooms[]=32&rooms[]=33&rooms[]=31&rooms[]=40&types[]=15&types[]=18&filled[]=1&filled[]=0&export=user_shifts | |
wget <URL> -o engelsystem_export.32C3.json | |
create https://c3voc.de/wiki/intern:32c3:av and https://c3voc.de/wiki/intern:32c3:engel | |
''' | |
verbose = True and False | |
with open('engelsystem_export.32C3.json') as file: | |
engelsystem_json = file.read() | |
engelsytem_export = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(engelsystem_json) | |
shifts = dict() | |
angeltypes = OrderedDict() | |
for shift in engelsytem_export: | |
shifts[shift['SID']] = shift | |
for type in shift['angeltypes']: | |
if type['name'] not in angeltypes: | |
angeltypes[type['name']] = OrderedDict() | |
for angel in type['angels']: | |
if angel not in angeltypes[type['name']]: | |
angeltypes[type['name']][angel] = [] | |
angeltypes[type['name']][angel].append(shift['SID']) | |
#print json.dumps(shifts, indent=2) | |
for type, angels in angeltypes.iteritems(): | |
print "\n=== %s (%d Personen)" % (type, len(angels)) | |
for a in sorted(angels, key=lambda x: len(angels[x]), reverse=True): | |
print " * %s: %d" %(a, len(angels[a])) | |
if verbose and shifts[angels[a][0]]['PSID'] is not None: | |
#print " * " + ", ".join([ shifts[sid]['PSID'] for sid in angels[a] ]) | |
for sid in angels[a]: | |
print " * %s [[https:%s|%s]]" % (shifts[sid]['PSID'], shifts[sid]['URL'], shifts[sid]['title']) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment