def addDir(self,name, url, mode, image,category='',page=1,maintitle = False, link = False,desc='', extra={},show='', searchall = None,type='',dialog=None):
try:category=category.encode("utf-8")
except:cateory=str(category)
extra=str(extra)
m3u8=False
if name and name.startswith("Error") :
mode=-1
if not dialog:
dialog="error"
if name and mode==-1 :
if not dialog:
dialog="error"
name="Error:"+name
if name and (name.startswith("Message") or str(url).startswith("Message")):
mode=-2
if not dialog:
dialog='message'
name=name.replace("Message:","")
if name and mode==-2 and not name.startswith("Message"):
if not dialog:
dialog='message'
name="Message:"+name
if mode==-5:
m3u8=True
mode=0
if link==True:
mode=0
if mode==0:
link=True
if mode==503:
if not dialog:
dialog="input"
if mode==903:
if not dialog:
dialog="login"
if mode==103 or mode==603 or mode==703 or mode==803 or mode==1003 or mode==2003:
if not dialog:
dialog="search"
if url.startswith('plugin://plugin.video.youtube') or 'youtube.com' in url:
link=True
mode=0
if image.startswith("img/"):
image=AppPath+"/addons/"+self.addonSPath+"/"+image
if not image.startswith("http") and not os.path.exists(image):
image=AppPath+"/addons/"+self.addonSPath+"/icon.png"
imageBasename=getimage_basename(image)
try:name = name.encode('utf-8', 'ingnore')
except:pass
try:category = category.encode('utf-8', 'ingnore')
except:pass
try:desc = desc.encode('utf-8', 'ingnore')
except:pass
if url and ('m3u8' in url and not name == 'm3u8_0') or m3u8==True:
try:
from m3u8player import getm3u8playlist
list = getm3u8playlist(url)
for item in list:
url = str(item[1])
url = self.Clear_Txt(url)
title = str(item[0])+"-"+ name
try:
title = name+"_"+title.encode('utf-8', 'ingnore')
name=title
except:
pass
except:
pass
if link=='True':
u=url
else:
try:u = self.spath + '?url=' + urllib.quote_plus(url) + '&mode=' + str(mode) + '&name=' + urllib.quote_plus(name) + "&" + "image="+image+'&page=' + str(page) + '&desc=' + urllib.quote_plus(desc)+ '&category=' + urllib.quote_plus(category)+'&maintitle=' + str(maintitle) + '&extra=' + urllib.quote_plus(str(extra))+ '&show=' + urllib.quote_plus(show)
except:u=''
cParams={}
cParams['title']=name
cParams['name']=name
cParams['url']=url
cParams['mode']=mode
cParams['image']=image
cParams['category']=category
cParams['page']=page
cParams['maintitle']=maintitle
try:cParams['desc']=desc.encode("utf-8",'ignore')
except:cParams['desc']=''
cParams['extra']=extra
cParams['type']=type
cParams['show']=show
cParams['caddon_id']=self.addon_id
cParams['csection_id']=self.section_id
cParams['dialog']=dialog
cParams['imageBasename']=imageBasename
#cParams['u']=u
self.list.append(cParams)
if searchall is not None and dialog=='search':
try:
dirname = os.path.split(searchall)[0]
addon_name = os.path.basename(dirname)
search_file = searchall.replace('default.pyc', 'searchall').replace('default.pyo', 'searchall').replace('default.py', 'searchall')
afile = open(search_file, 'w')
afile.write(addon_name + ';;' + str(cParams))
afile.close()
except:
pass