Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84005

addLink

$
0
0
I'm new to xbmc addon development, so far I'm
just copy/pasting other addons.
can't get the following code to do anything.
can anyone give me some hints?

the links show up but nothing happends when i click them.
they are .mp3 extended and work fine if i put them in an .strm file

Code:
import urllib2,urllib,re
import xbmc,xbmcgui,xbmcplugin,xbmcaddon

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

base_url = 'myurl.url'
list_url=base_url+'/cgi-bin/list'

req = urllib2.Request(list_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('<a href="(stream[^"]+)">.+&nbsp;([^<]+)<br>').findall(link)

for item in match:
    addLink(item[1],1,base_url+"/cgi-bin/"+item[0],'')

xbmcplugin.endOfDirectory(int(sys.argv[1]))

Viewing all articles
Browse latest Browse all 84005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>