46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
dirs = ["/usr/share/streamtuner2", "/usr/local/share/streamtuner2", sys.path[0], "."]
self.share = [d for d in dirs if os.path.exists(d)][0]
# settings from last session
last = self.load("settings")
if (last):
self.update(last)
# store defaults in file
else:
self.save("settings")
self.firstrun = 1
# some defaults
def defaults(self):
self.browser = "sensible-browser"
self.play = {
"audio/mp3": "audacious ", # %u for url to .pls, %g for downloaded .m3u
"audio/ogg": "audacious ",
"audio/aac": "amarok -l ",
"audio/x-pn-realaudio": "vlc --one-instance",
"audio/*": "totem ",
"*/*": "vlc --one-instance %srv",
}
self.record = {
|
>
|
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
dirs = ["/usr/share/streamtuner2", "/usr/local/share/streamtuner2", sys.path[0], "."]
self.share = [d for d in dirs if os.path.exists(d)][0]
# settings from last session
last = self.load("settings")
if (last):
self.update(last)
self.migrate()
# store defaults in file
else:
self.save("settings")
self.firstrun = 1
# some defaults
def defaults(self):
self.browser = "sensible-browser"
self.play = {
"audio/mpeg": "audacious ", # %u for url to .pls, %g for downloaded .m3u
"audio/ogg": "audacious ",
"audio/aac": "amarok -l ",
"audio/x-pn-realaudio": "vlc --one-instance",
"audio/*": "totem ",
"*/*": "vlc --one-instance %srv",
}
self.record = {
|
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
for key,value in with_new_data.items():
if type(value) == dict:
self[key].update(value)
else:
self[key] = value
# descends into sub-dicts instead of wiping them with subkeys
# check for existing filename in directory list
def find_in_dirs(self, dirs, file):
for d in dirs:
if os.path.exists(d+"/"+file):
return d+"/"+file
|
>
>
>
>
>
>
>
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
for key,value in with_new_data.items():
if type(value) == dict:
self[key].update(value)
else:
self[key] = value
# descends into sub-dicts instead of wiping them with subkeys
# update old setting names
def migrate(self):
# 2.1.1
if "audio/mp3" in self.play:
self.play["audio/mpeg"] = self.play["audio/mp3"]
del self.play["audio/mp3"]
# check for existing filename in directory list
def find_in_dirs(self, dirs, file):
for d in dirs:
if os.path.exists(d+"/"+file):
return d+"/"+file
|