Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 47 additions & 125 deletions addon.py
Original file line number Diff line number Diff line change
@@ -1,125 +1,47 @@
import urllib,urllib2,re,xbmcplugin,xbmcgui

#TV DASH - by You 2008.

def CATEGORIES():
addDir('Seinastu sendingarnar', 'http://stream.kringvarp.fo/webservice/ripley_service.xml?media=1&sort=1&page=0', 2, '', 0)
addLink('LIVE', 'rtmp://46.137.78.64:1935/fo', 'video', 'http://www.kringvarp.fo/MediaPlayer/ripley/Ripley.1.3.2.swf', '')
addLink('LIVE (HQ)', 'rtmp://46.137.78.64:1935/fo', 'videohigh', 'http://www.kringvarp.fo/MediaPlayer/ripley/Ripley.1.3.2.swf', '')

def INDEX(url):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link = response.read()
response.close()
match = re.compile('').findall(link)
for thumbnail, url, name in match:
addDir(name, url, 2, thumbnail, 0)

def VIDEOLINKS(url,name, page):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link = response.read()
response.close()
match = re.compile('<id>(.*)</id>\n.*<title>(.*)</title>(\n.*){1,20}<publish>(.*)</publish>(\n.*){1,20}<media>(.*)</media>').findall(link)
for nothing, name, nothing2, publish, nothing3, url in match:
addLink(name.replace('&amp;','&') + ' : ' + publish,'rtmp://87.230.58.72:1935/vod', 'mp4:video/' + url.upper() + '.mp4','http://www.kringvarp.fo/MediaPlayer/ripley/Ripley.1.3.2.swf','')
addDir('Fleiri sendingar - s. ' + str(page + 1), 'http://stream.kringvarp.fo/webservice/ripley_service.xml?media=1&sort=1&page=' + str((page + 1)), 2, '', page + 1)



def get_params():
param = []
paramstring = sys.argv[2]
if len(paramstring) >= 2:
params=sys.argv[2]
cleanedparams = params.replace('?', '')
if (params[len(params) - 1] == '/'):
params = params[0:len(params)-2]
pairsofparams = cleanedparams.split('&')
param = {}
for i in range(len(pairsofparams)):
splitparams = {}
splitparams = pairsofparams[i].split('=')
if (len(splitparams)) == 2:
param[splitparams[0]] = splitparams[1]

return param




def addLinkOLD(name, url, iconimage):
ok = True
liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage = iconimage)
liz.setInfo(type="Video", infoLabels={ "Title": name })
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = url, listitem = liz)
return ok

def addLink(name, url, playpath, swfUrl, iconimage):
ok = True
liz = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo(type="Video", infoLabels={ "Title": name })
liz.setProperty("SWFPlayer", swfUrl)
liz.setProperty("PlayPath", playpath)
ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = url, listitem = liz)
#xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(url, liz)
return ok



def addDir(name,url,mode,iconimage,page):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(name) + "&page=" + str(page)
ok = True
liz = xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo(type="Video", infoLabels={ "Title": name })
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)
return ok


params = get_params()
url = None
name = None
mode = None
page = 0

try:
url = urllib.unquote_plus(params["url"])
except:
pass
try:
name = urllib.unquote_plus(params["name"])
except:
pass
try:
mode = int(params["mode"])
except:
pass

try:
page = int(params["page"])
except:
pass

print "Mode: " + str(mode)
print "URL: " + str(url)
print "Name: " + str(name)
print "Page: " + str(page)

if mode == None or url == None or len(url) < 1:
print ""
CATEGORIES()

elif mode == 1:
print "" + url
INDEX(url)

elif mode == 2:
print "" + url
VIDEOLINKS(url, name, page)



xbmcplugin.endOfDirectory(int(sys.argv[1]))
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)
5 changes: 3 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.kringvarp" version="1.2" name="Kringvarp Føroya" provider-name="dotfo">
<addon id="plugin.video.kringvarp" version="2.0" name="Kringvarp Føroya" provider-name="dotfo">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="xbmc.python" version="2.14"/>
<import addon="script.module.beautifulsoup" version="3.2.1"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
Expand Down