-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
48 lines (38 loc) · 1.59 KB
/
addon.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
from elementtree import ElementTree
import sys
import os
import urllib2
import xbmcgui
import xbmcaddon
import xbmcplugin
FEED_URL = "http://natholdet.lbi.dk/xmlfeed.php?feed=33556715"
IPAD_USERAGENT = "AppleCoreMedia/1.0.0.9A334 (iPad; U; CPU OS 5_0 like Mac OS X; en_us) Paros/3.2.13"
class NatholdetAddon(object):
def listVideos(self):
r = urllib2.Request(FEED_URL, headers = {'user-agent' : IPAD_USERAGENT})
u = urllib2.urlopen(r)
xml = u.read()
u.close()
doc = ElementTree.fromstring(xml)
fanartImage = os.path.join(ADDON.getAddonInfo('path'), 'fanart.jpg')
for clip in doc.find('.'):
url = clip.findtext('url') + '|User-Agent=' + IPAD_USERAGENT
image = clip.findtext('image') + '|User-Agent=' + IPAD_USERAGENT
title = 'Natholdet - ' + clip.findtext('headline')
item = xbmcgui.ListItem(title, iconImage = image, thumbnailImage = image)
item.setProperty('Fanart_Image', fanartImage)
item.setInfo(type = 'video', infoLabels = {
'title' : clip.findtext('headline'),
'duration' : clip.findtext('duration'),
'plot' : clip.findtext('description'),
'studio' : 'TV2',
'cast' : ['Anders Breinholt']
})
xbmcplugin.addDirectoryItem(HANDLE, url, item)
xbmcplugin.endOfDirectory(HANDLE)
if __name__ == '__main__':
ADDON = xbmcaddon.Addon(id = 'plugin.video.natholdet')
PATH = sys.argv[0]
HANDLE = int(sys.argv[1])
natholdet = NatholdetAddon()
natholdet.listVideos()