2008-12-17, 23:19
I cannot figure out for the life of me where: xbmc.executebuiltin("Container.Refresh")
would go in all of this. Here is the code if anyone can help me out with a suggestion or two
would go in all of this. Here is the code if anyone can help me out with a suggestion or two
Code:
import urllib,urllib2,re,xbmcplugin,xbmcgui
#BBN
def Step0():
res=[]
url='URL'
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
response = urllib2.urlopen(req)
link=response.read()
code=re.sub(''','',link)
code2=re.sub('&','&',code)
response.close()
p=re.compile('<td align="center" valign="top">[.\r\n.]<div><a href="(.+?)"><img [.\r\n.]src="(.+?)".+? alt="(.+?)"></a></div>[.\r\n.].+?[.\r\n.]<small>Rating: (.+?) .+?[.\r\n.]<div>.+?</div>[.\r\n.]</td>')
match=p.findall(code2)
for url,img,name,rating in match:
res.append((url,img,name,rating))
for url,img,name,rating in res:
addDir0(name,"URL" + url,img,1)
def Step1(url):
res=[]
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
response = urllib2.urlopen(req)
link=response.read()
response.close()
p=re.compile('<tr>[.\r\n.]<td width=".+?">[.\r\n.]<a href="..(.+?)">[.\r\n.]<img src="(.+?)" .+?[.\r\n.]alt="(.+?)">[.\r\n.]</a>')
match=p.findall(link)
for url,img,name in match:
res.append((url,img,name))
addLink(name,url,img)
#addDir1(name,url,img,2)
def addDir0(name,url,img,mode):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&img="+urllib.quote_plus(img)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=img)
liz.setInfo( type="Pictures", infoLabels={ "Title": name } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def addLink(name,url,img):
res=[]
sfile=None
tfile=None
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=img)
liz.setInfo( type="Pictures", infoLabels={ "Title": name } )
req = urllib2.Request("URL" + url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
response = urllib2.urlopen(req)
link=response.read()
response.close()
p=re.compile('<a href="../(.+?)" class="size1"><big><big>Watch this trailer</big></big></a>')
match=p.findall(link)
for sfile in match:
res.append((sfile))
req = urllib2.Request("URL" + sfile)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
response = urllib2.urlopen(req)
link=response.read()
response.close()
p=re.compile('<a href=\"(.+?)\"><b>right click here</b></a>')
match=p.findall(link)
for tfile in match:
print "XBMCG33K :: " + tfile
res.append((tfile))
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=tfile,listitem=liz)
return ok
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
params=get_params()
url=None
sfile=None
Tfile=None
name=None
img=None
mode=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
sfile=urllib.unquote_plus(params["sfile"])
except:
pass
try:
sfile=urllib.unquote_plus(params["Tfile"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
try:
img=urllib.unquote_plus(params["img"])
except:
pass
try:
sName=urllib.unquote_plus(sName)
except:
pass
try:
sImg=urllib.unquote_plus(sImg)
except:
pass
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
print "Img: "+str(img)
print "sFile: "+str(sfile)
if mode==None or url==None or len(url)<1:
print "CATEGORY INDEX : "
Step0()
elif mode==1:
print "Create dir for : "+url
Step1(url)
elif mode==9:
print "Create link2 for : "+url
INDEX2(url)
xbmcplugin.endOfDirectory(int(sys.argv[1]))