3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 0.0.2 |
Version 0.0.15 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
18 |
import urllib |
import urllib |
19 |
import urllib2 |
import urllib2 |
20 |
|
|
21 |
|
#import pprint |
22 |
|
|
23 |
from xml.dom.minidom import parseString |
from xml.dom.minidom import parseString |
24 |
|
|
25 |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
__addon__ = xbmcaddon.Addon(id='plugin.video.todic') |
26 |
__key__ = __addon__.getSetting('xbmckey').lower() |
__key__ = __addon__.getSetting('xbmckey').lower() |
27 |
__backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ |
__backend__ = "http://todic.dk/xbmc.php?xbmckey=" + __key__ |
28 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'fanart.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
29 |
datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/') |
datapath = xbmc.translatePath('special://profile/addon_data/plugin.video.todic/') |
30 |
|
|
31 |
|
ADDON_PATH = __addon__.getAddonInfo('path') |
32 |
|
SkinMasterPath = os.path.join(ADDON_PATH, 'skins' ) + '/' |
33 |
|
MySkinPath = (os.path.join(SkinMasterPath, '720p')) + '/' |
34 |
|
MySkin = 'main.xml' |
35 |
|
|
36 |
|
|
37 |
|
class TodicMovieDialog(xbmcgui.WindowXMLDialog): |
38 |
|
def __new__(cls): |
39 |
|
return super(TodicMovieDialog, cls).__new__(cls, "main.xml", ADDON_PATH) |
40 |
|
|
41 |
|
def __init__(self): |
42 |
|
super(TodicMovieDialog, self).__init__() |
43 |
|
|
44 |
|
def onClick( self, controlId ): |
45 |
|
print "OnClick: " + str(controlId) |
46 |
|
|
47 |
|
if (controlId == 50): |
48 |
|
self.close() |
49 |
|
play_real_video(self.url, self.name) |
50 |
|
|
51 |
|
if ( controlId == 98 ): |
52 |
|
self.close() |
53 |
|
|
54 |
|
|
55 |
|
def onInit(self): |
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 |
|
|
65 |
|
|
66 |
|
orig_img_width = self.getControl(40).getWidth() |
67 |
|
self.starwidth = ( float(self.imdbrating) / 10.0) * orig_img_width; |
68 |
|
self.getControl(40).setWidth( int(self.starwidth) ) |
69 |
|
|
70 |
|
def setUrl( self, url): |
71 |
|
print "SETURL:" + url |
72 |
|
self.url = url |
73 |
|
self.fetchClipDetails() |
74 |
|
|
75 |
|
|
76 |
|
def fetchClipDetails(self): |
77 |
|
param1 = parse_parameter_string( self.url ) |
78 |
|
|
79 |
|
self.clipkey = param1[ "clipkey" ] |
80 |
|
print "CLIPKEY:" + self.clipkey |
81 |
|
detailurl = __backend__ + "&action=clipdetails&clipkey=" + self.clipkey |
82 |
|
|
83 |
|
xml = open_url(detailurl) |
84 |
|
|
85 |
|
doc = parseString(xml) |
86 |
|
self.imdbrating = getText( doc.getElementsByTagName("imdbrating") ) |
87 |
|
self.moviegroups = getText( doc.getElementsByTagName("moviegroups") ) |
88 |
|
self.playlength = getText( doc.getElementsByTagName("playlength") ) |
89 |
|
self.codecdetails = getText( doc.getElementsByTagName("codecdetails") ) |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
def setName( self, name ): |
96 |
|
self.name = name |
97 |
|
|
98 |
|
def setDescription( self, description ): |
99 |
|
self.description = description |
100 |
|
|
101 |
|
|
102 |
class TodicPlayer(xbmc.Player): |
class TodicPlayer(xbmc.Player): |
103 |
def __init__(self, *args, **kwargs): |
def __init__(self, *args, **kwargs): |
178 |
u = sys.argv[0] + "?mode=10&name=" |
u = sys.argv[0] + "?mode=10&name=" |
179 |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
180 |
|
|
181 |
|
#add search series |
182 |
|
listitem = xbmcgui.ListItem(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 |
|
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) |
187 |
|
|
188 |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
xbmcplugin.endOfDirectory(int(sys.argv[1])) |
189 |
|
|
190 |
|
|
218 |
playcount = '0' |
playcount = '0' |
219 |
playcount = int(playcount) |
playcount = int(playcount) |
220 |
|
|
|
name = name.encode('latin-1') |
|
|
description = description.encode('latin-1') |
|
221 |
|
|
222 |
## print "name:" + name |
## print "name:" + name |
223 |
# print "url:" + url |
# print "url:" + url |
234 |
infoLabels['playcount'] = playcount |
infoLabels['playcount'] = playcount |
235 |
listitem.setInfo('video', infoLabels) |
listitem.setInfo('video', infoLabels) |
236 |
|
|
237 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) |
name = name.encode('UTF-8') |
238 |
|
description = description.encode('UTF-8') |
239 |
|
|
240 |
|
|
241 |
|
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote(name) + "&url=" + urllib.quote(url) + "&description=" + urllib.quote(description) |
242 |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) |
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) |
243 |
|
|
244 |
if (endlist == True): |
if (endlist == True): |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
def play_video(url, name): |
def play_video(url, name,description): |
251 |
xml = open_url(url) |
if (description == None or description == ""): |
252 |
|
play_real_video(url,name) |
253 |
|
else: |
254 |
|
d = TodicMovieDialog() |
255 |
|
d.setUrl( url) |
256 |
|
d.setName( name ) |
257 |
|
d.setDescription( description ) |
258 |
|
|
259 |
|
d.doModal() |
260 |
|
|
261 |
|
|
262 |
|
def play_real_video(url, name): |
263 |
|
xml = open_url(url) |
264 |
print 'TODIC url: ' + str(url) |
print 'TODIC url: ' + str(url) |
265 |
print 'TODIC xml: '+ xml |
print 'TODIC xml: '+ xml |
266 |
|
|
320 |
|
|
321 |
buildList(url, "søgning") |
buildList(url, "søgning") |
322 |
|
|
323 |
|
def searchSeries(): |
324 |
|
search = getUserInput("Todic Serie Søgning") |
325 |
|
|
326 |
|
if (search != None and search != ""): |
327 |
|
url = __backend__ + "&action=searchseries&search=" + urllib.quote_plus(search) |
328 |
|
|
329 |
|
#print "[TODIC] Search start: " + search |
330 |
|
#print "[TODIC] Search url: " + url |
331 |
|
|
332 |
|
buildList(url, "serie søgning") |
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
361 |
|
|
362 |
|
|
363 |
def get_params(): |
def get_params(): |
364 |
|
return parse_parameter_string( sys.argv[2] ) |
365 |
|
|
366 |
|
def parse_parameter_string( paramstring ): |
367 |
param=[] |
param=[] |
|
paramstring=sys.argv[2] |
|
368 |
if len(paramstring)>=2: |
if len(paramstring)>=2: |
369 |
params=sys.argv[2] |
params = paramstring |
370 |
cleanedparams=params.replace('?','') |
cleanedparams=params.replace('?','') |
371 |
if (params[len(params)-1]=='/'): |
if (params[len(params)-1]=='/'): |
372 |
params=params[0:len(params)-2] |
params=params[0:len(params)-2] |
384 |
url = None |
url = None |
385 |
name = None |
name = None |
386 |
mode = None |
mode = None |
387 |
|
description = None |
388 |
|
|
389 |
try: |
try: |
390 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.unquote_plus(params["url"]) |
398 |
mode = int(params["mode"]) |
mode = int(params["mode"]) |
399 |
except: |
except: |
400 |
pass |
pass |
401 |
|
try: |
402 |
|
description = urllib.unquote_plus(params["description"]) |
403 |
|
except: |
404 |
|
pass |
405 |
|
|
406 |
|
try: |
407 |
|
open_url("http://todic.dk") |
408 |
|
except: |
409 |
|
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
410 |
|
exit() |
411 |
|
|
412 |
|
|
413 |
if url == 'refresh': |
if url == 'refresh': |
414 |
xbmc.output("[tvserver] Container.Refresh") |
#xbmc.output("[tvserver] Container.Refresh") #20130418 xbmc.output virker ikke med XBMC12 |
415 |
xbmc.executebuiltin("Container.Refresh") |
xbmc.executebuiltin("Container.Refresh") |
416 |
|
|
417 |
|
|
425 |
|
|
426 |
elif mode == 10: |
elif mode == 10: |
427 |
search() |
search() |
428 |
|
|
429 |
|
elif mode == 11: |
430 |
|
searchSeries() |
431 |
|
|
432 |
|
|
433 |
elif mode == 50: |
elif mode == 50: |
434 |
play_video(url, name) |
play_video(url, name, description) |
435 |
|
|
436 |
|
|
437 |
|
|