Skip to content

Instantly share code, notes, and snippets.

@benmcnelly
Forked from HansMayer/default.py
Created August 8, 2012 00:50
Show Gist options
  • Select an option

  • Save benmcnelly/3291027 to your computer and use it in GitHub Desktop.

Select an option

Save benmcnelly/3291027 to your computer and use it in GitHub Desktop.
XBMC rtmpGUI plugin with multiple source lists, local source lists (file://), channel logos (<logourl>) and distinction by language
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib, urllib2, cookielib
import string, os, re, time, datetime, sys
import xbmc, xbmcgui, xbmcplugin, xbmcaddon
#from xml.etree import ElementTree
from elementtree import ElementTree
BASE = [
'http://apps.ohlulz.com/rtmpgui/list.xml',
#'http://localhost/list.xml',
]
def listSources():
for source in BASE:
print source
u=sys.argv[0]+"?src="+str(BASE.index(source))
item=xbmcgui.ListItem(source, iconImage="DefaultFolder.png")
item.setInfo( type="Video", infoLabels={ "Title": source })
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True)
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ) )
# Root listing
def listVideos(src=0):
xml=getURL(BASE[int(src)])
tree = ElementTree.XML(xml)
streams = tree.findall('stream')
for stream in streams:
language = stream.findtext('language')
if language.find('Link Down') == -1 :
title = stream.findtext('title')+' ('+language+')'
rtmplink = stream.findtext('link')+' playpath='+stream.findtext('playpath')+' swfurl='+stream.findtext('swfUrl')+' pageurl='+stream.findtext('pageUrl')
item=xbmcgui.ListItem(title)
item.setInfo( type="Video", infoLabels={'title':title})
item.setProperty('IsPlayable', 'true')
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=rtmplink,listitem=item,isFolder=False)
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ) )
def getURL( url ):
print 'RTMPGUI --> common :: getURL :: url = '+url
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
opener.addheaders = [('User-Agent', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2;)')]
usock=opener.open(url)
response=usock.read()
usock.close()
return response
#listVideos()
if len(sys.argv[2]) >= 6:
listVideos(sys.argv[2][5:])
else:
listSources()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment