3 |
|
|
4 |
''' |
''' |
5 |
Todic plugin for XBMC |
Todic plugin for XBMC |
6 |
Version 1.7.3 |
Version 1.9.0 |
7 |
''' |
''' |
8 |
|
|
9 |
import sys |
import sys |
13 |
import xbmc |
import xbmc |
14 |
import xbmcaddon |
import xbmcaddon |
15 |
import xbmcgui |
import xbmcgui |
16 |
|
import xbmcvfs |
17 |
import xbmcplugin |
import xbmcplugin |
18 |
import urllib |
import urllib |
19 |
import urllib2 |
import urllib.request |
20 |
|
|
21 |
# import pprint |
# import pprint |
22 |
|
|
37 |
|
|
38 |
print( "[Todic] entrypoint: " + __entrypoint__ ) |
print( "[Todic] entrypoint: " + __entrypoint__ ) |
39 |
print( "[Todic] backend: " + __backend__ ) |
print( "[Todic] backend: " + __backend__ ) |
40 |
|
print( "[Todic] version: " + __addon__.getAddonInfo('version') ) |
41 |
|
|
42 |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
fanartImage = os.path.join(__addon__.getAddonInfo('path'), 'movie_bg_blur.jpg') |
43 |
datapath = xbmc.translatePath( |
datapath = xbmcvfs.translatePath( |
44 |
'special://profile/addon_data/plugin.video.todic/') |
'special://profile/addon_data/plugin.video.todic/') |
45 |
|
|
46 |
ADDON_PATH = __addon__.getAddonInfo('path') |
ADDON_PATH = __addon__.getAddonInfo('path') |
148 |
self.reportPlaytime("ended") |
self.reportPlaytime("ended") |
149 |
|
|
150 |
def tick(self): |
def tick(self): |
151 |
#print "[Todic] Tick: " + str( self.isPlaying() ) |
#print( "[Todic] Tick: " + str( self.isPlaying() ) ) |
152 |
if ( self.isPlaying() ): |
if ( self.isPlaying() ): |
153 |
tmpTime = self.getTime() |
tmpTime = self.getTime() |
154 |
|
|
156 |
if tmpTime != self.playingPosition: |
if tmpTime != self.playingPosition: |
157 |
self.playingPosition = tmpTime |
self.playingPosition = tmpTime |
158 |
now = time() |
now = time() |
159 |
#print "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) |
#print( "[Todic] tick " + str(now) + " " + str(self.lastReport) + " : " +str(now - self.lastReport) ) |
160 |
if ( (now - self.lastReport) > 60.0): |
if ( (now - self.lastReport) > 60.0): |
161 |
self.lastReport = now |
self.lastReport = now |
162 |
self.reportPlaytime("playing") |
self.reportPlaytime("playing") |
198 |
|
|
199 |
|
|
200 |
def open_url(url): |
def open_url(url): |
201 |
req = urllib2.Request(url) |
with urllib.request.urlopen(url) as response: |
202 |
content = urllib2.urlopen(req) |
data = response.read() |
203 |
data = content.read() |
return data |
|
content.close() |
|
|
return data |
|
204 |
|
|
205 |
|
|
206 |
# wraps open url in a catch-all exception handler |
# wraps open url in a catch-all exception handler |
216 |
def rootMenu(): |
def rootMenu(): |
217 |
kodi_ver = xbmc.getInfoLabel('System.BuildVersion') |
kodi_ver = xbmc.getInfoLabel('System.BuildVersion') |
218 |
plugin_ver = __addon__.getAddonInfo('version') |
plugin_ver = __addon__.getAddonInfo('version') |
219 |
msgurl = __backend__ + "&action=messages&kodi=" + urllib.quote_plus(kodi_ver) + "&todicplugin=" + urllib.quote_plus(plugin_ver) |
msgurl = __backend__ + "&action=messages&kodi=" + urllib.parse.quote(kodi_ver) + "&todicplugin=" + urllib.parse.quote(plugin_ver) |
220 |
|
|
221 |
msg = open_url(msgurl) |
msg = open_url(msgurl) |
222 |
msg = msg.strip() |
msg = msg.strip() |
228 |
buildList(__backend__, "", False) # call default list |
buildList(__backend__, "", False) # call default list |
229 |
|
|
230 |
# Adde xtra items to root menu |
# Adde xtra items to root menu |
231 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label="Søg Film ...") |
232 |
label="Søg Film ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
listitem.setArt( { 'icon':'DefaultFolder.png', 'thumb':'DefaultFolder.png'} ) |
233 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
234 |
|
|
235 |
u = sys.argv[0] + "?mode=10&name=" |
u = sys.argv[0] + "?mode=10&name=" |
237 |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=True) |
238 |
|
|
239 |
# add search series |
# add search series |
240 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label="Søg Serier ...") |
241 |
label="Søg Serier ...", iconImage='DefaultFolder.png', thumbnailImage='DefaultFolder.png') |
listitem.setArt( { 'icon':'DefaultFolder.png', 'thumb':'DefaultFolder.png'} ) |
242 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
243 |
|
|
244 |
u = sys.argv[0] + "?mode=11&name=" |
u = sys.argv[0] + "?mode=11&name=" |
249 |
|
|
250 |
|
|
251 |
def buildList(url, title, endlist=True): |
def buildList(url, title, endlist=True): |
252 |
print( '[Todic]:' + str(url) ) |
print( '[Todic::buildList]:' + str(url) ) |
253 |
|
|
254 |
link = open_url(url) |
link = open_url(url) |
255 |
doc = parseString(link) |
doc = parseString(link) |
279 |
|
|
280 |
# print "name:" + name |
# print "name:" + name |
281 |
# print "url:" + url |
# print "url:" + url |
282 |
# print "thumb:" + thumb |
# print "thumb:" + thumbi |
283 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label=name, label2='test') |
284 |
label=name, label2='test', iconImage='DefaultFolder.png') |
listitem.setArt( {'icon': 'DefaultFolder.png'} ) |
285 |
listitem.setProperty('Fanart_Image', fanartImage) |
listitem.setProperty('Fanart_Image', fanartImage) |
286 |
listitem.addContextMenuItems([('Refresh', 'Container.Refresh')]) |
listitem.addContextMenuItems([('Refresh', 'Container.Refresh')]) |
287 |
|
listitem.setArt( {'thumb': thumb} ) |
288 |
|
|
289 |
if mode == '50': |
if mode == '50': |
290 |
infoLabels = {} |
infoLabels = {} |
291 |
infoLabels['title'] = name |
infoLabels['title'] = name |
292 |
infoLabels['playcount'] = playcount |
infoLabels['playcount'] = playcount |
293 |
if playcount > 0: |
# if playcount > 0: |
294 |
listitem.setArt( {'thumb': thumb} ) #not pretty - but at least we can show a different icon for unwatched/watched in kodi18 |
# listitem.setArt( {'thumb': thumb} ) #not pretty - but at least we can show a different icon for unwatched/watched in kodi18 |
295 |
listitem.setInfo('video', infoLabels) |
listitem.setInfo('video', infoLabels) |
|
listitem.setProperty('IsPlayable', 'true') |
|
296 |
|
|
297 |
name = name.encode('UTF-8') |
name = name.encode('UTF-8') |
298 |
|
|
299 |
u = sys.argv[0] + "?mode=" + urllib.quote(mode) + "&name=" + urllib.quote( |
u = sys.argv[0] + "?mode=" + urllib.parse.quote(mode) + "&name=" + urllib.parse.quote(name) + "&url=" + urllib.parse.quote(url) |
|
name) + "&url=" + urllib.quote(url) |
|
300 |
xbmcplugin.addDirectoryItem( |
xbmcplugin.addDirectoryItem( |
301 |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
handle=int(sys.argv[1]), url=u, listitem=listitem, isFolder=folder, totalItems=l) |
302 |
|
|
347 |
def play_real_video(url, name, position): |
def play_real_video(url, name, position): |
348 |
xml = open_url(url) |
xml = open_url(url) |
349 |
print( '[Todic] url: ' + str(url) ) |
print( '[Todic] url: ' + str(url) ) |
350 |
print( '[Todic] xml: ' + xml ) |
print( '[Todic] xml: ' + str(xml) ) |
351 |
print( '[Todic] pos: ' + str(position) ) |
print( '[Todic] pos: ' + str(position) ) |
352 |
|
|
353 |
doc = parseString(xml) |
doc = parseString(xml) |
359 |
print( '[Todic] subs: ' + str(subtitleurl) ) |
print( '[Todic] subs: ' + str(subtitleurl) ) |
360 |
|
|
361 |
image = xbmc.getInfoImage('ListItem.Thumb') |
image = xbmc.getInfoImage('ListItem.Thumb') |
362 |
listitem = xbmcgui.ListItem( |
listitem = xbmcgui.ListItem(label=name) |
363 |
label=name, iconImage='DefaultVideo.png', thumbnailImage=image) |
listitem.setArt( {'icon': 'DefaultVideo.png', 'thumb':image} ) |
364 |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
listitem.setInfo(type="Video", infoLabels={"Title": name}) |
365 |
|
|
366 |
listitem.setProperty('StartOffset', str(position) ) |
listitem.setProperty('StartOffset', str(position) ) |
373 |
|
|
374 |
|
|
375 |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
#Holder python kørernde indtil at det bliver bedt om at stoppe |
376 |
while (not xbmc.abortRequested): |
kodiMonitor = xbmc.Monitor() |
377 |
|
|
378 |
|
|
379 |
|
while (not kodiMonitor.abortRequested()): |
380 |
player.tick() |
player.tick() |
381 |
xbmc.sleep(500) |
kodiMonitor.waitForAbort( 1 ) |
382 |
|
|
383 |
|
|
384 |
|
|
387 |
|
|
388 |
if (search != None and search != ""): |
if (search != None and search != ""): |
389 |
url = __backend__ + "&action=search&search=" + \ |
url = __backend__ + "&action=search&search=" + \ |
390 |
urllib.quote_plus(search) |
urllib.parse.quote(search) |
391 |
|
|
392 |
# print "[Todic] Search start: " + search |
# print "[Todic] Search start: " + search |
393 |
# print "[Todic] Search url: " + url |
# print "[Todic] Search url: " + url |
400 |
|
|
401 |
if (search != None and search != ""): |
if (search != None and search != ""): |
402 |
url = __backend__ + "&action=searchseries&search=" + \ |
url = __backend__ + "&action=searchseries&search=" + \ |
403 |
urllib.quote_plus(search) |
urllib.parse.quote(search) |
404 |
|
|
405 |
# print "[Todic] Search start: " + search |
# print "[Todic] Search start: " + search |
406 |
# print "[Todic] Search url: " + url |
# print "[Todic] Search url: " + url |
411 |
#=================================== Tool Box ======================================= |
#=================================== Tool Box ======================================= |
412 |
# shows a more userfriendly notification |
# shows a more userfriendly notification |
413 |
def showMessage(heading, message): |
def showMessage(heading, message): |
414 |
|
print( "[Todic::showMessage] " + message) |
415 |
|
print( message ) |
416 |
duration = 15 * 1000 |
duration = 15 * 1000 |
417 |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % |
418 |
(heading, message, duration)) |
(heading, message, duration)) |
466 |
#print params |
#print params |
467 |
|
|
468 |
try: |
try: |
469 |
url = urllib.unquote_plus(params["url"]) |
url = urllib.parse.unquote(params["url"]) |
470 |
except: |
except: |
471 |
pass |
pass |
472 |
try: |
try: |
473 |
name = urllib.unquote_plus(params["name"]) |
name = urllib.parse.unquote(params["name"]) |
474 |
except: |
except: |
475 |
pass |
pass |
476 |
try: |
try: |
480 |
|
|
481 |
|
|
482 |
|
|
|
|
|
483 |
try: |
try: |
484 |
open_url("http://todic.dk") |
open_url("https://todic.dk") |
485 |
except: |
except: |
486 |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
showMessage("Fejl", "Kunne ikke forbinde til todic.dk") |
487 |
exit() |
exit() |