forked from primaeval/script.tvguide.fullscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatchup.py
52 lines (47 loc) · 1.48 KB
/
catchup.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
47
48
49
50
51
52
import os
import re
import xbmc
import xbmcgui
import xbmcaddon
import xbmcvfs
from rpc import RPC
def log(x):
xbmc.log(repr(x))
ADDON = xbmcaddon.Addon(id='script.tvguide.fullscreen')
file_name = 'special://profile/addon_data/script.tvguide.fullscreen/catchup.ini'
f = xbmcvfs.File(file_name,"rb")
data = f.read()
f.close()
name_sub = re.findall('(.*?)=(.*)',data)
name_sub = sorted(name_sub, key=lambda x: x[0].lower())
name_sub = [list(i) for i in name_sub]
while True:
actions = ["Add", "Remove"] + ["%s [COLOR dimgrey]%s[/COLOR]" % (x[0],x[1]) for x in name_sub]
d = xbmcgui.Dialog()
action = d.select("Manage",actions)
if action == -1:
break
elif action == 0:
name = d.input("Name")
if not name:
break
url = d.input("Url")
if not url:
break
name_sub.append((name,url))
elif action == 1:
names = ["%s [COLOR dimgrey]%s[/COLOR]" % (x[0],x[1]) for x in name_sub]
which = d.multiselect("Remove",names)
name_sub = [v for i, v in enumerate(name_sub) if i not in which]
else:
new_name = d.input("Name (%s)" % actions[action],name_sub[action-2][0])
if new_name:
name_sub[action-2][0] = new_name
new_url = d.input("Url (%s)" % actions[action],name_sub[action-2][1])
if new_url:
name_sub[action-2][1] = new_url
f = xbmcvfs.File(file_name,"wb")
for (name,url) in name_sub:
s = "%s=%s\n" % (name,url)
f.write(s)
f.close()