forked from dotfo/plugin.video.kringvarp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddon.py
More file actions
47 lines (37 loc) · 1.68 KB
/
addon.py
File metadata and controls
47 lines (37 loc) · 1.68 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
43
44
45
46
47
import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin
import urllib2
from BeautifulSoup import BeautifulSoup
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
xbmcplugin.setContent(addon_handle, 'movies')
def build_url(query):
return base_url + '?' + urllib.urlencode(query)
mode = args.get('mode', None)
if mode is None:
# First the live feed
url = 'http://80.77.128.59/fo/videohigher/playlist.m3u8'
li = xbmcgui.ListItem('Watch Kringvarp Live', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
# Then a folder for programs
url = build_url({'mode': 'programlist'})
li = xbmcgui.ListItem('Sendingar', iconImage='DefaultFolder.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
elif mode[0] == 'programlist':
# Get a list of programs from kvf.fo and add a folder per program
url = 'http://kvf.fo/podcast'
source = urllib2.urlopen(url)
# Turn the saved source into a BeautifulSoup object
soup = BeautifulSoup(source, convertEntities=BeautifulSoup.HTML_ENTITIES)
for span in soup.findAll('span', {'class': ['field-content']}):
title = span.text
# By replacing http by rss XBMC can figure out to do lists automaticly
feedurl = span.find('a')['href'].replace('http', 'rss')
li = xbmcgui.ListItem(title, iconImage='DefaultFolder.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=feedurl, listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)