NarutoGet Add-on
#1
I am working on a little NarutoGet add-on for narutoget.com. I'm able to get it working on Windows 7, but when I try it on Apple TV 2 the plug-in doesn't even run.

PHP Code:
import urllib,urllib2,re,xbmcplugin,xbmcgui

def CATEGORIES
():
        
addDir('Naruto Shippuden English Subbed','http://www.narutoget.com/naruto-shippuden-episodes/',1,'')
                       
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('<a href="(.+?)" class="movie"  title="(.+?)">(.+?)</a> <br />(.+?)</td>').findall(link)
        for 
urldespcriptionepisodename  in match:
                
name name.replace(''', "'")
                episode = episode.replace('&amp', '&')
                addDir(episode+' - '+name,url,2,'')

def VIDEOLINKS(url,name):
        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('file=(.+?)&skin=').findall(link)
        for url in match:
                addLink(name,url,'')

        try:
            match=re.compile('<iframe width="
670" scrolling="no" height="430" frameborder="0" src="(.+?)"></iframe>').findall(link)
            match[0]=re.sub('&amp;','&',match[0])
            print match[0]
            req = urllib2.Request(match[0])
            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('file=(.+?)&autostart=').findall(link)
            for url in match:
                    addLink(name,url,'')
        except:
            print 'Error'
                
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 addLink(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 addDir(name,url,mode,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="
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

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

print "
Mode"+str(mode)
print "
URL"+str(url)
print "
Name"+str(name)

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)



xbmcplugin.endOfDirectory(int(sys.argv[1])) 
#2
Thread closed per http://forum.xbmc.org/showpost.php?p=981646

Logout Mark Read Team Forum Stats Members Help
NarutoGet Add-on0