From 19657ec1a42c68cad735dbb3eddb466ff3ae6d33 Mon Sep 17 00:00:00 2001 From: tgc-dk Date: Tue, 19 Aug 2014 17:03:32 +0200 Subject: [PATCH 1/4] Updated code to work with the new kvf.fo --- addon.py | 172 +++++++++++++++---------------------------------------- 1 file changed, 47 insertions(+), 125 deletions(-) diff --git a/addon.py b/addon.py index 2af3e3c..4713196 100644 --- a/addon.py +++ b/addon.py @@ -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('(.*)\n.*(.*)(\n.*){1,20}(.*)(\n.*){1,20}(.*)').findall(link) - for nothing, name, nothing2, publish, nothing3, url in match: - addLink(name.replace('&','&') + ' : ' + 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 = 'rtsp://217.172.83.186/fo/videohigher' + 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) From bf85f3a00fbf55620714557f77368aa6cc4455a3 Mon Sep 17 00:00:00 2001 From: tgc-dk Date: Tue, 19 Aug 2014 17:05:21 +0200 Subject: [PATCH 2/4] Fixed dependencies and bumped version --- addon.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addon.xml b/addon.xml index d882c4c..f624d2a 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,8 @@ - + - + + video From f02b785757940ec04bc52b786ba803c468700fc1 Mon Sep 17 00:00:00 2001 From: tgc-dk Date: Tue, 30 Sep 2014 08:44:08 +0100 Subject: [PATCH 3/4] Switch to different livestream url --- addon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.py b/addon.py index 4713196..8a0506f 100644 --- a/addon.py +++ b/addon.py @@ -21,7 +21,7 @@ def build_url(query): if mode is None: # First the live feed - url = 'rtsp://217.172.83.186/fo/videohigher' + url = 'http://217.172.83.186/fo/videohigher/playlist.m3u8' li = xbmcgui.ListItem('Watch Kringvarp Live', iconImage='DefaultVideo.png') xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) From 8acf1ea0b488cfe2a3b716c1896fea85c19f219b Mon Sep 17 00:00:00 2001 From: Nolsoe Date: Thu, 4 Dec 2014 12:47:36 +0100 Subject: [PATCH 4/4] Update addon.py New IP for video streaming server --- addon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon.py b/addon.py index 8a0506f..caa3cca 100644 --- a/addon.py +++ b/addon.py @@ -21,7 +21,7 @@ def build_url(query): if mode is None: # First the live feed - url = 'http://217.172.83.186/fo/videohigher/playlist.m3u8' + 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)