-
Notifications
You must be signed in to change notification settings - Fork 0
/
eventReceiver.py
executable file
·46 lines (32 loc) · 992 Bytes
/
eventReceiver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
import sys, time, os, socket
import pickle
import pandoraUtils
if __name__ == "__main__":
# Read event type from command arguments
if len(sys.argv) < 2:
pandoraUtils.log("Error reading event type from command arguments")
event_type = sys.argv[1]
# Read parameters from input
params = {}
for s in sys.stdin.readlines():
param, value = s.split("=", 1)
params[param.strip()] = value.strip()
# Handle specific events
if event_type == "songstart":
info = {}
info["song"] = params["title"]
info["artist"] = params["artist"]
info["album"] = params["album"]
info["stationCount"] = params["stationCount"]
info["stationName"] = params["stationName"]
stations = []
for i in range(0, int(params["stationCount"])):
stations.append(params["station"+str(i)])
info["stations"] = stations
pandoraUtils.setShared(info)
elif event_type == "songfinish":
pass
elif event_type == "usergetstations":
pass
pandoraUtils.parseAndWrite()