aboutsummaryrefslogtreecommitdiffstats
path: root/session_manager.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2021-12-21 18:24:55 +0100
committerEddy Pedroni <eddy@0xf7.com>2021-12-21 18:24:55 +0100
commit6eb42e6d4468ad161281125c77a41063f93380e1 (patch)
tree35ad2edeb7058ad60f47affb1b27dfac3fa62bac /session_manager.py
parentc1bfcc6064b3a22c76b986d9339daf6cbd403c80 (diff)
Added session manager, renamed solo-tool.py
Diffstat (limited to 'session_manager.py')
-rw-r--r--session_manager.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/session_manager.py b/session_manager.py
new file mode 100644
index 0000000..057d952
--- /dev/null
+++ b/session_manager.py
@@ -0,0 +1,39 @@
+import json
+
+class SessionManager:
+ def __init__(self, playlist, abController):
+ self._playlist = playlist
+ self._abController = abController
+
+ def addSong(self, path):
+ self._playlist.addSong(path)
+
+ def addLimits(self, aLimit, bLimit):
+ self._abController.addLimits(aLimit, bLimit)
+
+ def loadSession(self, file):
+ jsonStr = file.read()
+ session = json.loads(jsonStr)
+
+ for entry in session:
+ songPath = entry["path"]
+ abLimits = entry["ab_limits"]
+ self._playlist.addSong(songPath)
+
+ if abLimits is not None:
+ for l in abLimits:
+ self._abController.addLimits(l[0], l[1], songPath)
+
+ def saveSession(self, file):
+ songs = self._playlist.getSongs()
+ abLimits = self._abController.getLimits()
+ session = list()
+
+ for s in songs:
+ entry = {
+ "path": s,
+ "ab_limits" : abLimits.get(s)
+ }
+ session.append(entry)
+
+ file.write(json.dumps(session))