blob: 0896b2209b1f6c74b788ba6226ff95db32989299 (
plain)
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
|
import json
def loadSession(file, playlist, abController):
jsonStr = file.read()
session = json.loads(jsonStr)
playlist.clear()
abController.clear()
for entry in session:
songPath = entry["path"]
abLimits = entry["ab_limits"]
playlist.addSong(songPath)
if abLimits is not None:
for l in abLimits:
abController.storeLimits(l[0], l[1], songPath)
def saveSession(file, playlist, abController):
songs = playlist.getSongs()
session = list()
for s in songs:
entry = {
"path": s,
"ab_limits" : abController.getStoredLimits(s)
}
session.append(entry)
file.write(json.dumps(session))
|