7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
|
import cgi as urlparse |
|
10 |
import os |
import os |
11 |
|
|
12 |
|
|
17 |
import urllib |
import urllib |
18 |
import urllib2 |
import urllib2 |
19 |
|
|
20 |
#import pprint |
# import pprint |
21 |
|
|
22 |
from xml.dom.minidom import parseString |
from xml.dom.minidom import parseString |
23 |
|
|
24 |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
25 |
__key__ = __addon__.getSetting('xbmckey').lower() |
__key__ = __addon__.getSetting('xbmckey').lower() |
26 |
__backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ |
__backend__ = "https://todic.dk/xbmc.php?xbmckey=" + __key__ |
27 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
28 |
datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/') |
datapath = xbmc.translatePath( |
29 |
|
'special://profile/addon_data/plugin.video.todic/') |
30 |
|
|
31 |
ADDON_PATH = __addon__.getAddonInfo('path') |
ADDON_PATH = __addon__.getAddonInfo('path') |
32 |
SkinMasterPath = os.path.join(ADDON_PATH, 'skins' ) + '/' |
SkinMasterPath = os.path.join(ADDON_PATH, 'skins') + '/' |
33 |
MySkinPath = (os.path.join(SkinMasterPath, '720p')) + '/' |
MySkinPath = (os.path.join(SkinMasterPath, '720p')) + '/' |
34 |
MySkin = 'main.xml' |
MySkin = 'main.xml' |
35 |
|
|
36 |
|
|
37 |
class TodicMovieDialog(xbmcgui.WindowXMLDialog): |
class TodicMovieDialog(xbmcgui.WindowXMLDialog): |
|
def __new__(cls): |
|
|
return super(TodicMovieDialog, cls).__new__(cls, "main.xml", ADDON_PATH) |
|
38 |
|
|
39 |
def __init__(self): |
def __new__(cls): |
40 |
super(TodicMovieDialog, self).__init__() |
return super(TodicMovieDialog, cls).__new__(cls, "main.xml", ADDON_PATH) |
41 |
|
|
42 |
def onClick( self, controlId ): |
def __init__(self): |
43 |
print "OnClick: " + str(controlId) |
super(TodicMovieDialog, self).__init__() |
|
|
|
|
if (controlId == 50): |
|
|
self.close() |
|
|
play_real_video(self.url, self.name) |
|
44 |
|
|
45 |
if ( controlId == 98 ): |
def onClick(self, controlId): |
46 |
self.close() |
print "OnClick: " + str(controlId) |
47 |
|
|
48 |
|
if (controlId == 50): |
49 |
|
self.close() |
50 |
|
play_real_video(self.url, self.name) |
51 |
|
|
52 |
def onInit(self): |
if (controlId == 98): |
53 |
|
self.close() |
54 |
|
|
55 |
print "ONINIT" |
def onInit(self): |
|
self.getControl( 1 ).setLabel( self.name); |
|
|
self.getControl( 2 ).setLabel( self.moviegroups ) |
|
|
self.getControl( 3 ).setLabel( self.description ) |
|
|
self.getControl( 10 ).setLabel( self.playlength ) |
|
|
self.getControl( 11 ).setLabel( self.codecdetails ) |
|
56 |
|
|
57 |
|
print "ONINIT" |
58 |
|
self.getControl(1).setLabel(self.name) |
59 |
|
self.getControl(2).setLabel(self.moviegroups) |
60 |
|
self.getControl(3).setLabel(self.description) |
61 |
|
self.getControl(10).setLabel(self.playlength) |
62 |
|
self.getControl(11).setLabel(self.codecdetails) |
63 |
|
|
64 |
orig_img_width = self.getControl(40).getWidth() |
orig_img_width = self.getControl(40).getWidth() |
65 |
self.starwidth = ( float(self.imdbrating) / 10.0) * orig_img_width; |
self.starwidth = (float(self.imdbrating) / 10.0) * orig_img_width |
66 |
self.getControl(40).setWidth( int(self.starwidth) ) |
self.getControl(40).setWidth(int(self.starwidth)) |
67 |
|
|
68 |
def setUrl( self, url): |
def setUrl(self, url): |
69 |
print "SETURL:" + url |
print "SETURL:" + url |
70 |
self.url = url |
self.url = url |
71 |
self.fetchClipDetails() |
self.fetchClipDetails() |
72 |
|
|
73 |
|
def fetchClipDetails(self): |
74 |
|
param1 = parse_parameter_string(self.url) |
75 |
|
|
76 |
def fetchClipDetails(self): |
self.clipkey = param1["clipkey"] |
77 |
param1 = parse_parameter_string( self.url ) |
print "CLIPKEY:" + self.clipkey |
78 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
79 |
|
|
80 |
self.clipkey = param1[ "clipkey" ] |
xml = open_url(detailurl) |
|
print "CLIPKEY:" + self.clipkey |
|
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
|
|
|
|
|
xml = open_url(detailurl) |
|
81 |
|
|
82 |
doc = parseString(xml) |
doc = parseString(xml) |
83 |
self.imdbrating = getText( doc.getElementsByTagName("imdbrating") ) |
self.imdbrating = getText(doc.getElementsByTagName("imdbrating")) |
84 |
self.moviegroups = getText( doc.getElementsByTagName("moviegroups") ) |
self.moviegroups = getText(doc.getElementsByTagName("moviegroups")) |
85 |
self.playlength = getText( doc.getElementsByTagName("playlength") ) |
self.playlength = getText(doc.getElementsByTagName("playlength")) |
86 |
self.codecdetails = getText( doc.getElementsByTagName("codecdetails") ) |
self.codecdetails = getText(doc.getElementsByTagName("codecdetails")) |
87 |
|
|
88 |
|
def setName(self, name): |
89 |
|
self.name = name |
90 |
|
|
91 |
|
def setDescription(self, description): |
92 |
|
self.description = description |
|
|
|
|
def setName( self, name ): |
|
|
self.name = name |
|
|
|
|
|
def setDescription( self, description ): |
|
|
self.description = description |
|
93 |
|
|
94 |
|
|
95 |
class TodicPlayer(xbmc.Player): |
class TodicPlayer(xbmc.Player): |
96 |
def __init__(self, *args, **kwargs): |
|
97 |
#xbmc.Player.__init__(selv,*args,**kwargs) |
def __init__(self, *args, **kwargs): |
98 |
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER ) |
# xbmc.Player.__init__(selv,*args,**kwargs) |
99 |
self.stopped = False |
xbmc.Player.__init__(self, xbmc.PLAYER_CORE_MPLAYER) |
100 |
self.started = False |
self.stopped = False |
101 |
print "[TodicPlayer] init" |
self.started = False |
102 |
|
print "[TodicPlayer] init" |
103 |
# @catchall |
|
104 |
def onPlayBackStarted(self): |
# @catchall |
105 |
self.started = True |
def onPlayBackStarted(self): |
106 |
print "[TodicPlayer] : started" |
self.started = True |
107 |
|
print "[TodicPlayer] : started" |
108 |
# super.onPlayBackStarted() |
# super.onPlayBackStarted() |
109 |
|
|
110 |
def onPlayBackStopped(self): |
def onPlayBackStopped(self): |
111 |
self.stopped = True |
self.stopped = True |
112 |
print "[TodicPlayer] : stopped" |
print "[TodicPlayer] : stopped" |
113 |
|
|
114 |
def onPlayBackEnded(self): |
def onPlayBackEnded(self): |
115 |
self.stopped = True |
self.stopped = True |
116 |
print "[TodicPlayer] : ended" |
print "[TodicPlayer] : ended" |
117 |
|
|
118 |
def callbackLoop(self): |
def callbackLoop(self): |
119 |
print "[Todic] startLoop" |
print "[Todic] startLoop" |
120 |
while (self.stopped == False): |
while (self.stopped == False): |
121 |
if (self.started == True ): |
if (self.started == True): |
122 |
print "[todic] " + str(self.getTime()) |
print "[todic] " + str(self.getTime()) |
123 |
xbmc.sleep(5000) |
xbmc.sleep(5000) |
124 |
|
|
125 |
|
|
126 |
def getText2(nodelist): |
def getText2(nodelist): |
127 |
rc = [] |
rc = [] |
128 |
for node in nodelist: |
for node in nodelist: |
129 |
if node.nodeType == node.TEXT_NODE: |
if node.nodeType == node.TEXT_NODE: |
130 |
rc.append(node.data) |
rc.append(node.data) |
131 |
else: |
else: |
132 |
rc.append( getText(node.childNodes) ) |
rc.append(getText(node.childNodes)) |
133 |
return ''.join(rc) |
return ''.join(rc) |
134 |
|
|
135 |
|
|
136 |
def getText(nodelist): |
def getText(nodelist): |
137 |
if nodelist.length == 0: |
if nodelist.length == 0: |
138 |
return '' |
return '' |
139 |
else: |
else: |
140 |
if nodelist[0].childNodes.length == 0: |
if nodelist[0].childNodes.length == 0: |
141 |
return '' |
return '' |
142 |
else: |
else: |
143 |
return nodelist[0].childNodes[0].nodeValue |
return nodelist[0].childNodes[0].nodeValue |
144 |
|
|
145 |
|
|
146 |
def SaveFile(path, data): |
def SaveFile(path, data): |
147 |
file = open(path,'w') |
file = open(path, 'w') |
148 |
file.write(data) |
file.write(data) |
149 |
file.close() |
file.close() |
150 |
|
|
151 |
|
|
152 |
def open_url(url): |
def open_url(url): |
153 |
req = urllib2.Request(url) |
req = urllib2.Request(url) |
154 |
content = urllib2.urlopen(req) |
content = urllib2.urlopen(req) |
155 |
data = content.read() |
data = content.read() |
156 |
content.close() |
content.close() |
157 |
return data |
return data |
|
|
|
|
def rootMenu(): |
|
|
|
|
|
msg = open_url(__backend__ + "&action=messages") |
|
|
msg = msg.strip() |
|
|
|
|
|
if msg != "": |
|
|
dialog = xbmcgui.Dialog() |
|
|
dialog.ok('XBMC Todic', msg) |
|
158 |
|
|
|
buildList(__backend__, "", False) # call default list |
|
|
|
|
|
# Adde xtra items to root menu |
|
|
listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') |
|
|
listitem.setProperty('Fanart_Image', fanartImage) |
|
|
|
|
|
u = sys.argv[0] + "?mode=10&name=" |
|
|
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
|
|
|
|
|
#add search series |
|
|
listitem = xbmcgui.ListItem(label = "Søg Serier ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') |
|
|
listitem.setProperty('Fanart_Image', fanartImage) |
|
|
|
|
|
u = sys.argv[0] + "?mode=11&name=" |
|
|
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
|
|
|
|
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
|
|
|
|
|
|
|
|
def buildList(url,title, endlist=True): |
|
|
print '[TODIC]:'+str(url) |
|
|
|
|
|
link = open_url(url) |
|
|
doc = parseString(link) |
|
|
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
|
|
print '[TODIC]'+str(ty) |
|
|
|
|
|
if ty == 'clipList': |
|
|
mode = '50' |
|
|
folder = False |
|
|
else: |
|
|
mode = '1' |
|
|
folder = True |
|
159 |
|
|
160 |
|
def rootMenu(): |
161 |
|
|
162 |
entries = doc.getElementsByTagName("entry") |
msg = open_url(__backend__ + "&action=messages") |
163 |
l=len(entries) |
msg = msg.strip() |
|
description = '' |
|
|
for entry in entries: |
|
|
name = getText( entry.getElementsByTagName("title") ) |
|
|
url = getText( entry.getElementsByTagName("url") ) |
|
|
thumb = getText( entry.getElementsByTagName("cover") ) |
|
|
description = getText( entry.getElementsByTagName("description") ) |
|
|
playcount = getText( entry.getElementsByTagName("playcount") ) |
|
|
|
|
|
if playcount == '': |
|
|
playcount = '0' |
|
|
playcount = int(playcount) |
|
164 |
|
|
165 |
|
if msg != "": |
166 |
|
dialog = xbmcgui.Dialog() |
167 |
|
dialog.ok('XBMC Todic', msg) |
168 |
|
|
169 |
|
buildList(__backend__, "", False) # call default list |
170 |
|
|
171 |
|
# Adde xtra items to root menu |
172 |
|
listitem = xbmcgui.ListItem( |
173 |
|
label="Søg film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
174 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
175 |
|
|
176 |
|
u = sys.argv[0] + "?mode=10&name=" |
177 |
|
xbmcplugin.addDirectoryItem( |
178 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
179 |
|
|
180 |
|
# add search series |
181 |
|
listitem = xbmcgui.ListItem( |
182 |
|
label="Søg Serier ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
183 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
184 |
|
|
185 |
|
u = sys.argv[0] + "?mode=11&name=" |
186 |
|
xbmcplugin.addDirectoryItem( |
187 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
188 |
|
|
189 |
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
190 |
|
|
191 |
|
|
192 |
|
def buildList(url, title, endlist=True): |
193 |
|
print '[TODIC]:' + str(url) |
194 |
|
|
195 |
|
link = open_url(url) |
196 |
|
doc = parseString(link) |
197 |
|
ty = doc.getElementsByTagName("meta")[0].getAttribute("type") |
198 |
|
print '[TODIC]' + str(ty) |
199 |
|
|
200 |
|
if ty == 'clipList': |
201 |
|
mode = '50' |
202 |
|
folder = False |
203 |
|
else: |
204 |
|
mode = '1' |
205 |
|
folder = True |
206 |
|
|
207 |
|
entries = doc.getElementsByTagName("entry") |
208 |
|
l = len(entries) |
209 |
|
description = '' |
210 |
|
for entry in entries: |
211 |
|
name = getText(entry.getElementsByTagName("title")) |
212 |
|
url = getText(entry.getElementsByTagName("url")) |
213 |
|
thumb = getText(entry.getElementsByTagName("cover")) |
214 |
|
description = getText(entry.getElementsByTagName("description")) |
215 |
|
playcount = getText(entry.getElementsByTagName("playcount")) |
216 |
|
|
217 |
|
if playcount == '': |
218 |
|
playcount = '0' |
219 |
|
playcount = int(playcount) |
220 |
|
|
221 |
## print "name:" + name |
# print "name:" + name |
222 |
# print "url:" + url |
# print "url:" + url |
223 |
# print "thumb:" + thumb |
# print "thumb:" + thumb |
224 |
# print "description:" + description |
# print "description:" + description |
225 |
|
listitem = xbmcgui.ListItem( |
226 |
|
label=name, label2='test', iconImage='DefaultFolder.png', thumbnailImage=thumb) |
227 |
|
listitem.setProperty('Fanart_Image', fanartImage) |
228 |
|
if mode == '50': |
229 |
|
infoLabels = {} |
230 |
|
infoLabels['title'] = name |
231 |
|
infoLabels['plot'] = description |
232 |
|
infoLabels['playcount'] = playcount |
233 |
|
listitem.setInfo('video', infoLabels) |
234 |
|
|
235 |
|
name = name.encode('UTF-8') |
236 |
|
description = description.encode('UTF-8') |
237 |
|
|
238 |
|
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
239 |
|
name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
240 |
|
xbmcplugin.addDirectoryItem( |
241 |
|
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
242 |
|
|
243 |
|
if (endlist == True): |
244 |
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
245 |
|
|
246 |
|
|
247 |
|
def play_video(url, name, description): |
248 |
|
if (description == None or description == ""): |
249 |
|
play_real_video(url, name) |
250 |
|
else: |
251 |
|
d = TodicMovieDialog() |
252 |
|
d.setUrl(url) |
253 |
|
d.setName(name) |
254 |
|
d.setDescription(description) |
255 |
|
|
256 |
|
d.doModal() |
|
listitem = xbmcgui.ListItem(label = name, label2='test', iconImage = 'DefaultFolder.png', thumbnailImage = thumb) |
|
|
listitem.setProperty('Fanart_Image', fanartImage) |
|
|
if mode == '50': |
|
|
infoLabels = {} |
|
|
infoLabels['title'] = name |
|
|
infoLabels['plot'] = description |
|
|
infoLabels['playcount'] = playcount |
|
|
listitem.setInfo('video', infoLabels) |
|
|
|
|
|
name = name.encode('UTF-8') |
|
|
description = description.encode('UTF-8') |
|
|
|
|
|
|
|
|
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
|
|
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) |
|
|
|
|
|
if (endlist == True): |
|
|
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def play_video(url, name,description): |
|
|
if (description == None or description == ""): |
|
|
play_real_video(url,name) |
|
|
else: |
|
|
d = TodicMovieDialog() |
|
|
d.setUrl( url) |
|
|
d.setName( name ) |
|
|
d.setDescription( description ) |
|
|
|
|
|
d.doModal() |
|
257 |
|
|
258 |
|
|
259 |
def play_real_video(url, name): |
def play_real_video(url, name): |
260 |
xml = open_url(url) |
xml = open_url(url) |
261 |
print 'TODIC url: ' + str(url) |
print 'TODIC url: ' + str(url) |
262 |
print 'TODIC xml: '+ xml |
print 'TODIC xml: ' + xml |
263 |
|
|
264 |
doc = parseString(xml) |
doc = parseString(xml) |
265 |
url = getText( doc.getElementsByTagName("url") ) |
url = getText(doc.getElementsByTagName("url")) |
266 |
|
|
267 |
subtitleurl = getText( doc.getElementsByTagName("subtitles") ) |
subtitleurl = getText(doc.getElementsByTagName("subtitles")) |
268 |
subtitlesfile = os.path.join(datapath,'temp.srt') |
subtitlesfile = os.path.join(datapath, 'temp.srt') |
269 |
|
|
270 |
#if old srt file exists delete it first |
# if old srt file exists delete it first |
271 |
if os.path.isfile(subtitlesfile): |
if os.path.isfile(subtitlesfile): |
272 |
os.unlink(subtitlesfile) |
os.unlink(subtitlesfile) |
273 |
|
|
274 |
print '[TODIC] subs: '+str(subtitleurl) |
print '[TODIC] subs: ' + str(subtitleurl) |
275 |
if len(subtitleurl) > 0: |
if len(subtitleurl) > 0: |
276 |
subtitles = open_url(subtitleurl) |
subtitles = open_url(subtitleurl) |
277 |
SaveFile(subtitlesfile, subtitles) |
SaveFile(subtitlesfile, subtitles) |
278 |
print 'TODIC downloaded subtitles' |
print 'TODIC downloaded subtitles' |
279 |
|
|
280 |
|
image = xbmc.getInfoImage('ListItem.Thumb') |
281 |
|
listitem = xbmcgui.ListItem( |
282 |
image = xbmc.getInfoImage( 'ListItem.Thumb' ) |
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
283 |
listitem = xbmcgui.ListItem(label = name , iconImage = 'DefaultVideo.png', thumbnailImage = image) |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
284 |
listitem.setInfo( type = "Video", infoLabels={ "Title": name } ) |
|
285 |
|
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
286 |
player = TodicPlayer(xbmc.PLAYER_CORE_AUTO) |
player.play(str(url), listitem) |
287 |
player.play(str(url), listitem) |
|
288 |
|
# kan ikke loade subtitles hvis foerend playeren koerer |
289 |
#kan ikke loade subtitles hvis foerend playeren koerer |
count = 0 |
290 |
count = 0 |
while not xbmc.Player().isPlaying(): |
291 |
while not xbmc.Player().isPlaying(): |
xbmc.sleep(500) |
292 |
xbmc.sleep(500) |
count += 1 |
293 |
count += 1 |
if count > 10: |
294 |
if count > 10: |
break |
295 |
break |
|
296 |
|
if xbmc.Player().isPlaying(): |
297 |
|
if os.path.isfile(subtitlesfile): |
298 |
if xbmc.Player().isPlaying(): |
player.setSubtitles(subtitlesfile) |
299 |
if os.path.isfile(subtitlesfile): |
print 'TODIC started subtitles' |
300 |
player.setSubtitles(subtitlesfile) |
else: |
301 |
print 'TODIC started subtitles' |
player.disableSubtitles() |
|
else: |
|
|
player.disableSubtitles() |
|
302 |
|
|
303 |
# player.callbackLoop() |
# player.callbackLoop() |
304 |
|
|
305 |
|
|
|
|
|
306 |
def search(): |
def search(): |
307 |
search = getUserInput("Todic Søgning") |
search = getUserInput("Todic Søgning") |
308 |
|
|
309 |
if (search != None and search != ""): |
if (search != None and search != ""): |
310 |
url = __backend__ + "&action=search&search=" + urllib.quote_plus(search) |
url = __backend__ + "&action=search&search=" + \ |
311 |
|
urllib.quote_plus(search) |
312 |
|
|
313 |
#print "[TODIC] Search start: " + search |
# print "[TODIC] Search start: " + search |
314 |
#print "[TODIC] Search url: " + url |
# print "[TODIC] Search url: " + url |
315 |
|
|
316 |
buildList(url, "søgning") |
buildList(url, "søgning") |
317 |
|
|
|
def searchSeries(): |
|
|
search = getUserInput("Todic Serie Søgning") |
|
318 |
|
|
319 |
if (search != None and search != ""): |
def searchSeries(): |
320 |
url = __backend__ + "&action=searchseries&search=" + urllib.quote_plus(search) |
search = getUserInput("Todic Serie Søgning") |
321 |
|
|
322 |
#print "[TODIC] Search start: " + search |
if (search != None and search != ""): |
323 |
#print "[TODIC] Search url: " + url |
url = __backend__ + "&action=searchseries&search=" + \ |
324 |
|
urllib.quote_plus(search) |
325 |
|
|
326 |
buildList(url, "serie søgning") |
# print "[TODIC] Search start: " + search |
327 |
|
# print "[TODIC] Search url: " + url |
328 |
|
|
329 |
|
buildList(url, "serie søgning") |
330 |
|
|
331 |
|
|
332 |
|
#=================================== Tool Box ======================================= |
|
#=================================== Tool Box ======================================= |
|
333 |
# shows a more userfriendly notification |
# shows a more userfriendly notification |
334 |
def showMessage(heading, message): |
def showMessage(heading, message): |
335 |
duration = 15*1000 |
duration = 15 * 1000 |
336 |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % ( heading, message, duration) ) |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
337 |
|
(heading, message, duration)) |
338 |
|
|
339 |
|
|
340 |
# raise a keyboard for user input |
# raise a keyboard for user input |
341 |
def getUserInput(title = "Input", default="", hidden=False): |
def getUserInput(title="Input", default="", hidden=False): |
342 |
result = None |
result = None |
343 |
|
|
344 |
|
# Fix for when this functions is called with default=None |
345 |
|
if not default: |
346 |
|
default = "" |
347 |
|
|
348 |
|
keyboard = xbmc.Keyboard(default, title) |
349 |
|
keyboard.setHiddenInput(hidden) |
350 |
|
keyboard.doModal() |
351 |
|
|
352 |
|
if keyboard.isConfirmed(): |
353 |
|
result = keyboard.getText() |
354 |
|
|
355 |
# Fix for when this functions is called with default=None |
return result |
|
if not default: |
|
|
default = "" |
|
|
|
|
|
keyboard = xbmc.Keyboard(default, title) |
|
|
keyboard.setHiddenInput(hidden) |
|
|
keyboard.doModal() |
|
|
|
|
|
if keyboard.isConfirmed(): |
|
|
result = keyboard.getText() |
|
|
|
|
|
return result |
|
356 |
|
|
357 |
|
|
358 |
def get_params(): |
def get_params(): |
359 |
return parse_parameter_string( sys.argv[2] ) |
return parse_parameter_string(sys.argv[2]) |
360 |
|
|
361 |
def parse_parameter_string( paramstring ): |
|
362 |
param=[] |
def parse_parameter_string(paramstring): |
363 |
if len(paramstring)>=2: |
param = [] |
364 |
params = paramstring |
if len(paramstring) >= 2: |
365 |
cleanedparams=params.replace('?','') |
params = paramstring |
366 |
if (params[len(params)-1]=='/'): |
cleanedparams = params.replace('?', '') |
367 |
params=params[0:len(params)-2] |
if (params[len(params) - 1] == '/'): |
368 |
pairsofparams=cleanedparams.split('&') |
params = params[0:len(params) - 2] |
369 |
param={} |
pairsofparams = cleanedparams.split('&') |
370 |
for i in range(len(pairsofparams)): |
param = {} |
371 |
splitparams={} |
for i in range(len(pairsofparams)): |
372 |
splitparams=pairsofparams[i].split('=') |
splitparams = {} |
373 |
if (len(splitparams))==2: |
splitparams = pairsofparams[i].split('=') |
374 |
param[splitparams[0]]=splitparams[1] |
if (len(splitparams)) == 2: |
375 |
return param |
param[splitparams[0]] = splitparams[1] |
376 |
|
return param |
377 |
|
|
378 |
|
|
379 |
params = get_params() |
params = get_params() |
383 |
description = None |
description = None |
384 |
|
|
385 |
try: |
try: |
386 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.unquote_plus(params["url"]) |
387 |
except: |
except: |
388 |
pass |
pass |
389 |
try: |
try: |
390 |
name = urllib.unquote_plus(params["name"]) |
name = urllib.unquote_plus(params["name"]) |
391 |
except: |
except: |
392 |
pass |
pass |
393 |
try: |
try: |
394 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
395 |
except: |
except: |
396 |
pass |
pass |
397 |
try: |
try: |
398 |
description = urllib.unquote_plus(params["description"]) |
description = urllib.unquote_plus(params["description"]) |
399 |
except: |
except: |
400 |
pass |
pass |
401 |
|
|
402 |
try: |
try: |
403 |
open_url("http://todic.dk") |
open_url("http://todic.dk") |
404 |
except: |
except: |
405 |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
406 |
exit() |
exit() |
407 |
|
|
408 |
|
|
409 |
if url == 'refresh': |
if url == 'refresh': |
410 |
#xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker ikke med XBMC12 |
# xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker |
411 |
xbmc.executebuiltin("Container.Refresh") |
# ikke med XBMC12 |
412 |
|
xbmc.executebuiltin("Container.Refresh") |
413 |
|
|
414 |
|
|
415 |
elif mode == None: |
elif mode == None: |
416 |
#build main menu |
# build main menu |
417 |
rootMenu() |
rootMenu() |
418 |
|
|
419 |
elif mode == 1: |
elif mode == 1: |
420 |
#build list of movie starting letters |
# build list of movie starting letters |
421 |
buildList(url, name) |
buildList(url, name) |
422 |
|
|
423 |
elif mode == 10: |
elif mode == 10: |
424 |
search() |
search() |
425 |
|
|
426 |
elif mode == 11: |
elif mode == 11: |
427 |
searchSeries() |
searchSeries() |
|
|
|
|
|
|
|
elif mode == 50: |
|
|
play_video(url, name, description) |
|
|
|
|
|
|
|
428 |
|
|
429 |
|
|
430 |
|
elif mode == 50: |
431 |
|
play_video(url, name, description) |