added excel->json recorder source generation script

This commit is contained in:
Tobias Kurze
2019-11-12 12:32:49 +01:00
parent 5d731c9fba
commit 8b05bb694f
8 changed files with 485 additions and 6 deletions

View File

@@ -0,0 +1,57 @@
from pprint import pprint
import requests
from requests.auth import HTTPBasicAuth
from ics import Calendar
base_url = "https://opencast.bibliothek.kit.edu/recordings/calendars?agentid=CS+30.46+Chemie+Neuer+Hoersaal"
base_url = "https://opencast.bibliothek.kit.edu"
session = requests.session()
session.auth = HTTPBasicAuth("admin", "mz.paziuw!")
config = {'service_urls': {}}
def get_service_url(service_type: str):
if service_type in config['service_urls']:
return config['service_urls'][service_type]
params = {'serviceType': service_type}
url = base_url + "/services/available.json"
res = session.get(url, params=params)
if res.ok:
service = res.json()["services"]["service"]
config["service_urls"][service_type] = service["host"] + \
service["path"]
return service["host"] +service["path"]
return None
def get_calender(rec_id):
params = {'agentid': rec_id}
url = get_service_url('org.opencastproject.scheduler') + "/calendars"
print(url)
res = session.get(url, params=params)
if res.ok:
return Calendar(res.text)
def get_capture_agents():
url = get_service_url("org.opencastproject.capture.admin") + "/agents.json"
res = session.get(url)
if res.ok:
return res.json()["agents"]["agent"]
agents = get_capture_agents()
for a in agents:
print(a['name'])
print(a['state'])
if a['state'] == "capturing":
c = get_calender(a['name'])
print(list(c.timeline.now()))
exit()
c = get_calender('CS 30.46 Chemie Neuer Hoersaal')
print(c.events)
print(list(c.timeline)) # chronological order
print(list(c.timeline.now()))