-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdefault.py
More file actions
42 lines (30 loc) · 1.26 KB
/
default.py
File metadata and controls
42 lines (30 loc) · 1.26 KB
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
# -*- coding: utf-8 -*-
import xbmc
import xbmcaddon
import urllib
__addon__ = xbmcaddon.Addon()
__addon_id__ = __addon__.getAddonInfo('id')
__addonname__ = __addon__.getAddonInfo('name')
__icon__ = __addon__.getAddonInfo('icon')
__addonpath__ = xbmc.translatePath(__addon__.getAddonInfo('path'))
__lang__ = __addon__.getLocalizedString
class PlayTrailer:
def __init__(self):
self.getTrailer()
def getTrailer(self):
trailer = xbmc.getInfoLabel('ListItem.Trailer')
if 'plugin://plugin.video.youtube' not in trailer:
trailer = urllib.quote(trailer).replace('%3A', ':')
self.debug(trailer)
if len(trailer) > 0:
xbmc.Player().play(trailer)
else:
self.notify(__lang__(32000))
return
def debug(self, msg):
if 'true' in __addon__.getSetting('debug'):
xbmc.log('>>>> ' + __addonname__ + ' <<<< ' + msg)
def notify(self, msg):
if 'true' in __addon__.getSetting('notify'):
xbmc.executebuiltin('Notification(' + __addonname__ + ', ' + msg.encode('utf-8') + ', 4000, ' + __icon__ + ')')
PlayTrailer()