Ejemplo n.º 1
0
def channelLevel():
    stop = False

    try:
        data = load_channels.getAllChannels(portal['mac'], portal['url'],
                                            portal['serial'], addondir)

    except Exception as e:
        xbmcgui.Dialog().notification(addonname, str(e),
                                      xbmcgui.NOTIFICATION_ERROR)
        return

    data = data['channels']
    genre_name = args.get('genre_name', None)

    genre_id_main = args.get('genre_id', None)
    genre_id_main = genre_id_main[0]

    if genre_id_main == '10' and portal['parental'] == 'true':
        result = xbmcgui.Dialog().input(
            'Parental',
            hashlib.md5(portal['password'].encode('utf-8')).hexdigest(),
            type=xbmcgui.INPUT_PASSWORD,
            option=xbmcgui.PASSWORD_VERIFY)
        if result == '':
            stop = True

    if stop == False:
        for i in data.values():

            name = i["name"]
            cmd = i["cmd"]
            tmp = i["tmp"]
            number = i["number"]
            genre_id = i["genre_id"]
            logo = i["logo"]

            if genre_id_main == '*' and genre_id == '10' and portal[
                    'parental'] == 'true':
                continue

            if genre_id_main == genre_id or genre_id_main == '*':

                if logo != '':
                    logo_url = portal[
                        'url'] + '/stalker_portal/misc/logos/320/' + logo
                else:
                    logo_url = 'DefaultVideo.png'

                url = build_url({
                    'mode': 'play',
                    'cmd': cmd,
                    'tmp': tmp,
                    'title': name.encode("utf-8"),
                    'genre_name': genre_name,
                    'logo_url': logo_url,
                    'portal': json.dumps(portal)
                })

                li = xbmcgui.ListItem(name,
                                      iconImage=logo_url,
                                      thumbnailImage=logo_url)
                li.setInfo(type='Video',
                           infoLabels={
                               'title': name,
                               'count': number
                           })

                xbmcplugin.addDirectoryItem(handle=addon_handle,
                                            url=url,
                                            listitem=li)

        xbmcplugin.addSortMethod(addon_handle,
                                 xbmcplugin.SORT_METHOD_PLAYLIST_ORDER)
        xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.addSortMethod(addon_handle,
                                 xbmcplugin.SORT_METHOD_PROGRAM_COUNT)

        xbmcplugin.endOfDirectory(addon_handle)
Ejemplo n.º 2
0
def channelLevel():
	stop=False;
		
	try:
		data = load_channels.getAllChannels(portal['mac'], portal['url'], portal['serial'], addondir);
		
	except Exception as e:
		xbmcgui.Dialog().notification(addonname, str(e), xbmcgui.NOTIFICATION_ERROR );
		return;
	
	
	data = data['channels'];
	genre_name 	= args.get('genre_name', None);
	
	genre_id_main = args.get('genre_id', None);
	genre_id_main = genre_id_main[0];
	
	if genre_id_main == '10' and portal['parental'] == 'true':
		result = xbmcgui.Dialog().input('Parental', hashlib.md5(portal['password'].encode('utf-8')).hexdigest(), type=xbmcgui.INPUT_PASSWORD, option=xbmcgui.PASSWORD_VERIFY);
		if result == '':
			stop = True;

	
	if stop == False:
		for i in data.values():
			
			name 		= i["name"];
			cmd 		= i["cmd"];
			tmp 		= i["tmp"];
			number 		= i["number"];
			genre_id 	= i["genre_id"];
			logo 		= i["logo"];
		
			if genre_id_main == '*' and genre_id == '10' and portal['parental'] == 'true':
				continue;
		
		
			if genre_id_main == genre_id or genre_id_main == '*':
		
				if logo != '':
					logo_url = portal['url'] + '/stalker_portal/misc/logos/320/' + logo;
				else:
					logo_url = 'DefaultVideo.png';
				
				
				url = build_url({
					'mode': 'play', 
					'cmd': cmd, 
					'tmp' : tmp, 
					'title' : name.encode("utf-8"),
					'genre_name' : genre_name,
					'logo_url' : logo_url,  
					'portal' : json.dumps(portal)
					});
			

				li = xbmcgui.ListItem(name, iconImage=logo_url, thumbnailImage=logo_url);
				li.setInfo(type='Video', infoLabels={ 
					'title': name,
					'count' : number
					});

				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li);
		
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_PLAYLIST_ORDER);
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE);
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_PROGRAM_COUNT);
		
		
		xbmcplugin.endOfDirectory(addon_handle);
Ejemplo n.º 3
0
    def do_GET(self):
        global portals, server;
        

        try:
            if re.match('.*channels-([0-9])\..*|.*channels\..*\?portal=([0-9])', self.path):

            	host = self.headers.get('Host');


            	searchObj = re.search('.*channels-([0-9])\..*|.*channels\..*\?portal=([0-9])', self.path);
            	if searchObj.group(1) != None:
            		numportal = searchObj.group(1);
            	elif searchObj.group(2) != None:
            		numportal = searchObj.group(2);
            	else:
            		self.send_error(400,'Bad Request');
            		return;
            	

            	portal = portals[numportal];
            	
            	EXTM3U = "#EXTM3U\n";
            	
            	try:

					data = load_channels.getAllChannels(portal['mac'], portal['url'], portal['serial'], portal['login'], portal['password'], addondir);
					data = load_channels.orderChannels(data['channels'].values());

					for i in data:
						name 		= i["name"];
						cmd 		= i["cmd"];
						tmp 		= i["tmp"];
						number 		= i["number"];
						genre_title = i["genre_title"];
						genre_id 	= i["genre_id"];
						logo 		= i["logo"];

						if logo != '':
							logo = portal['url'] + '/stalker_portal/misc/logos/320/' + logo;
				
					
						parameters = urllib.urlencode( { 'channel' : cmd, 'tmp' : tmp, 'portal' : numportal } );
					
						EXTM3U += '#EXTINF:-1, tvg-id="' + number + '" tvg-name="' + name + '" tvg-logo="' + logo + '" group-title="' + genre_title + '", ' + name + '\n';
						EXTM3U += 'http://' + host + '/live.m3u?'  + parameters +'\n\n';
					
            	except Exception as e:
						EXTM3U += '#EXTINF:-1, tvg-id="Error" tvg-name="Error" tvg-logo="" group-title="Error", ' + portal['name'] + ' ' + str(e) + '\n';
						EXTM3U += 'http://\n\n';
        	
        	
                self.send_response(200)
                self.send_header('Content-type',	'application/x-mpegURL')
                #self.send_header('Content-type',	'text/html')
                self.send_header('Connection',	'close')
                self.send_header('Content-Length', len(EXTM3U))
                self.end_headers()
                self.wfile.write(EXTM3U.encode('utf-8'))
                self.finish()
                
            elif 'live.m3u' in self.path:
				
				args = parse_qs(urlparse(self.path).query);
				cmd = args['channel'][0];
				tmp = args['tmp'][0];
				numportal = args['portal'][0];
				
				portal = portals[numportal];
				
				url = load_channels.retriveUrl(portal['mac'], portal['url'], portal['serial'], portal['login'], portal['password'], cmd, tmp);
				
				self.send_response(301)
				self.send_header('Location', url)
				self.end_headers()
				self.finish()
                
#            elif 'epg.xml' in self.path:
#				
#				args = parse_qs(urlparse(self.path).query);
#				numportal = args['portal'][0];
#				
#				portal = portals[numportal];
#				
#				try:
#					xml = load_channels.getEPG(portal['mac'], portal['url'], portal['serial'], addondir);
#				except Exception as e:
#					xml  = '<?xml version="1.0" encoding="ISO-8859-1"?>'
#					xml += '<error>' + str(e) + '</error>';
#					
#				
#				self.send_response(200)
#				self.send_header('Content-type',	'txt/xml')
#				self.send_header('Connection',	'close')
#				self.send_header('Content-Length', len(xml))
#				self.end_headers()
#				self.wfile.write(xml)
#				self.finish()
                 
            elif 'stop' in self.path:
				msg = 'Stopping ...';
            	
				self.send_response(200)
				self.send_header('Content-type',	'text/html')
				self.send_header('Connection',	'close')
				self.send_header('Content-Length', len(msg))
				self.end_headers()
				self.wfile.write(msg.encode('utf-8'))
                
				server.socket.close();
                
            elif 'online' in self.path:
				msg = 'Yes. I am.';
            	
				self.send_response(200)
				self.send_header('Content-type',	'text/html')
				self.send_header('Connection',	'close')
				self.send_header('Content-Length', len(msg))
				self.end_headers()
				self.wfile.write(msg.encode('utf-8'))

            
            else:
            	self.send_error(400,'Bad Request');
            	
        except IOError:
            self.send_error(500,'Internal Server Error ' + str(IOError))
Ejemplo n.º 4
0
def channelLevel():
	stop=False 
		
	try:
		data = load_channels.getAllChannels(portal['mac'], portal['url'], portal['serial'], addondir) 
		
	except Exception:
#		xbmcgui.Dialog().notification(str, xbmcgui.NOTIFICATION_ERROR) 
		return 
	
	
	data = data['channels'] 
	genre_name 	= args.get('genre_name', None) 
	
	genre_id_main = args.get('genre_id', None) 
	genre_id_main = genre_id_main[0] 
	
	if genre_id_main == '68' and portal['parental'] == 'true':
		result = xbmcgui.Dialog().input('Parental', hashlib.md5(portal['password'].encode('utf-8')).hexdigest(), type=xbmcgui.INPUT_PASSWORD, option=xbmcgui.PASSWORD_VERIFY) 
		if result == '':
			stop = True 

	
	if stop == False:
		for i in data.values():
			
			name 		= i["name"] 
			cmd 		= i["cmd"] 
			tmp 		= i["tmp"] 
			number 		= i["number"] 
			genre_id 	= i["genre_id"] 
			logo 		= i["logo"] 
		
			if genre_id_main == '*' and genre_id == '10' and portal['parental'] == 'true':
				continue 
		
		
			if genre_id_main == genre_id or genre_id_main == '*':
		
				if logo != '':
					logo_url = portal['url'] + '/stalker_portal/misc/logos/321/' + logo 
				else:
					logo_url = 'special://home/addons/plugin.video.dnatv/fanart.jpg' 
				
				
				url = build_url({
					'mode': 'play', 
					'cmd': cmd, 
					'tmp' : tmp, 
					'title' : name.encode("utf-8"),
					'genre_name' : genre_name,
					'logo_url' : logo_url,  
					'portal' : json.dumps(portal)
					})
					  
			

				li = xbmcgui.ListItem(name, iconImage=logo_url, thumbnailImage=logo_url) 
				li.setInfo(type='Video', infoLabels={ 
					'title': name,
					'count' : number
					}) 

				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) 
		
		
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE) 
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_PROGRAM_COUNT) 
		
		
		xbmcplugin.endOfDirectory(addon_handle) 
Ejemplo n.º 5
0
def channelLevel():
	stop=False;
	
	stalker_url = args.get('stalker_url', None);
	stalker_url = stalker_url[0];
	
	genre_id_main = args.get('genre_id', None);
	genre_id_main = genre_id_main[0];
	
	data = load_channels.getAllChannels(stalker_url, addondir);
	data = data['channels'];
	
	genre_name 	= args.get('genre_name', None);
	
	
	if genre_id_main == '10' and parental == 'true':
		result = xbmcgui.Dialog().input('Parental', hashlib.md5(password.encode('utf-8')).hexdigest(), type=xbmcgui.INPUT_PASSWORD, option=xbmcgui.PASSWORD_VERIFY);
		if result == '':
			stop = True;

	if stop == False:
		for i in data:
			name 	= i["name"];
			cmd 	= i["cmd"];
			tmp 	= i["tmp"];
			number 	= i["number"];
			genre_id 	= i["genre_id"];
			logo 	= i["logo"];
		
			if genre_id_main == '*' and genre_id == '10':
				continue;
		
			if genre_id_main == genre_id or genre_id_main == '*':
		
				if logo != '':
					logo_url = stalker_url + '/stalker_portal/misc/logos/320/' + logo;
				else:
					logo_url = 'DefaultVideo.png';
				
				
				url = build_url({
					'mode': 'play', 
					'stalker_url' : stalker_url, 
					'cmd': cmd, 
					'tmp' : tmp, 
					'title' : name.encode("utf-8"),
					'genre_name' : genre_name,
					'logo_url' : logo_url
					});
			

				li = xbmcgui.ListItem(name, iconImage=logo_url, thumbnailImage=logo_url);
				li.setInfo(type='Video', infoLabels={ "title": name });

				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li);
		
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_UNSORTED);
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE);
		
		
		xbmcplugin.endOfDirectory(addon_handle);
Ejemplo n.º 6
0
def channelLevel():
	stop=False; 
		
	try:
		data = load_channels.getAllChannels(portal['mac'], portal['url'], portal['serial'], addondir); 
		
	except Exception:
#		xbmcgui.Dialog().notification(str, xbmcgui.NOTIFICATION_ERROR) 
		genrepain();
		return; 
	
	
	data = data['channels']; 
	genre_name 	= args.get('genre_name', None); 
	
	genre_id_main = args.get('genre_id', None); 
	genre_id_main = genre_id_main[0]; 
	
	if genre_id_main == '68' and portal['parental'] == 'true':
		result = xbmcgui.Dialog().input('Parental', hashlib.md5(portal['password'].encode('utf-8')).hexdigest(), type=xbmcgui.INPUT_PASSWORD, option=xbmcgui.PASSWORD_VERIFY); 
		if result == '':
			stop = True; 

	
	if stop == False:
		for i in data.values():
			
			name 		= i["name"]; 
			cmd 		= i["cmd"]; 
			tmp 		= i["tmp"]; 
			number 		= i["number"]; 
			genre_id 	= i["genre_id"]; 
			logo 		= i["logo"]; 
		
			if genre_id_main == '*' and genre_id == '10' and portal['parental'] == 'true':
				continue; 
		
		
			if genre_id_main == genre_id or genre_id_main == '*':
			

				if logo != '':
#					logo_url = portal['url'] + '/stalker_portal/misc/logos/320/' + logo;
					logo_url = 'aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL21hY2JsaXp6YXJkL2RuYXR2Z3VpZGUta29kaS9tYXN0ZXIvbG9nb3Mv'.decode('base64') + logo;
				else:
					logo_url = 'special://home/addons/plugin.video.dnatv/icon.png';
				
				
				url = build_url({
					'mode': 'play', 
					'cmd': cmd, 
					'tmp' : tmp, 
					'title' : name.encode("utf-8"),
					'genre_name' : genre_name,
					'logo_url' : logo_url,  
					'portal' : json.dumps(portal)
					});
					  
			

				li = xbmcgui.ListItem(name, iconImage=logo_url, thumbnailImage=logo_url); 
				li.setInfo(type='Video', infoLabels={ 
					'title': name,
					'count' : number
					}); 

				xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li); 
		
		
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE); 
		xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_PROGRAM_COUNT); 
		
		
		xbmcplugin.endOfDirectory(addon_handle); 
Ejemplo n.º 7
0
    def do_GET(self):
        global portals, server

        try:
            if re.match(
                    '.*channels-([0-9])\..*|.*channels\..*\?portal=([0-9])',
                    self.path):

                host = self.headers.get('Host')

                searchObj = re.search(
                    '.*channels-([0-9])\..*|.*channels\..*\?portal=([0-9])',
                    self.path)
                if searchObj.group(1) != None:
                    numportal = searchObj.group(1)
                elif searchObj.group(2) != None:
                    numportal = searchObj.group(2)
                else:
                    self.send_error(400, 'Bad Request')
                    return

                portal = portals[numportal]

                EXTM3U = "#EXTM3U\n"

                try:

                    data = load_channels.getAllChannels(
                        portal['mac'], portal['url'], portal['serial'],
                        addondir)
                    data = load_channels.orderChannels(
                        data['channels'].values())

                    for i in data:
                        name = i["name"]
                        cmd = i["cmd"]
                        tmp = i["tmp"]
                        number = i["number"]
                        genre_title = i["genre_title"]
                        genre_id = i["genre_id"]
                        logo = i["logo"]

                        if logo != '':
                            logo = portal[
                                'url'] + '/stalker_portal/misc/logos/320/' + logo

                        parameters = urllib.urlencode({
                            'channel': cmd,
                            'tmp': tmp,
                            'portal': numportal
                        })

                        EXTM3U += '#EXTINF:-1, tvg-id="' + number + '" tvg-name="' + name + '" tvg-logo="' + logo + '" group-title="' + genre_title + '", ' + name + '\n'
                        EXTM3U += 'http://' + host + '/live.m3u?' + parameters + '\n\n'

                except Exception as e:
                    EXTM3U += '#EXTINF:-1, tvg-id="Error" tvg-name="Error" tvg-logo="" group-title="Error", ' + portal[
                        'name'] + ' ' + str(e) + '\n'
                    EXTM3U += 'http://\n\n'

                self.send_response(200)
                self.send_header('Content-type', 'application/x-mpegURL')
                #self.send_header('Content-type',	'text/html')
                self.send_header('Connection', 'close')
                self.send_header('Content-Length', len(EXTM3U))
                self.end_headers()
                self.wfile.write(EXTM3U.encode('utf-8'))
                self.finish()

            elif 'live.m3u' in self.path:

                args = parse_qs(urlparse(self.path).query)
                cmd = args['channel'][0]
                tmp = args['tmp'][0]
                numportal = args['portal'][0]

                portal = portals[numportal]

                url = load_channels.retriveUrl(portal['mac'], portal['url'],
                                               portal['serial'], cmd, tmp)

                self.send_response(301)
                self.send_header('Location', url)
                self.end_headers()
                self.finish()

            elif 'epg.xml' in self.path:

                args = parse_qs(urlparse(self.path).query)
                numportal = args['portal'][0]

                portal = portals[numportal]

                try:
                    xml = load_channels.getEPG(portal['mac'], portal['url'],
                                               portal['serial'], addondir)
                except Exception as e:
                    xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'
                    xml += '<error>' + str(e) + '</error>'

                self.send_response(200)
                self.send_header('Content-type', 'txt/xml')
                self.send_header('Connection', 'close')
                self.send_header('Content-Length', len(xml))
                self.end_headers()
                self.wfile.write(xml)
                self.finish()

            elif 'stop' in self.path:
                msg = 'Stopping ...'

                self.send_response(200)
                self.send_header('Content-type', 'text/html')
                self.send_header('Connection', 'close')
                self.send_header('Content-Length', len(msg))
                self.end_headers()
                self.wfile.write(msg.encode('utf-8'))

                server.socket.close()

            elif 'online' in self.path:
                msg = 'Yes. I am.'

                self.send_response(200)
                self.send_header('Content-type', 'text/html')
                self.send_header('Connection', 'close')
                self.send_header('Content-Length', len(msg))
                self.end_headers()
                self.wfile.write(msg.encode('utf-8'))

            else:
                self.send_error(400, 'Bad Request')

        except IOError:
            self.send_error(500, 'Internal Server Error ' + str(IOError))
Ejemplo n.º 8
0
def channelLevel():
    stop = False

    try:
        data = load_channels.getAllChannels(portal['mac'], portal['url'],
                                            portal['serial'], addondir)

    except Exception:
        #		xbmcgui.Dialog().notification(str, xbmcgui.NOTIFICATION_ERROR)
        genrepain()
        return

    data = data['channels']
    genre_name = args.get('genre_name', None)

    genre_id_main = args.get('genre_id', None)
    genre_id_main = genre_id_main[0]

    if genre_id_main == '68' and portal['parental'] == 'true':
        result = xbmcgui.Dialog().input(
            'Parental',
            hashlib.md5(portal['password'].encode('utf-8')).hexdigest(),
            type=xbmcgui.INPUT_PASSWORD,
            option=xbmcgui.PASSWORD_VERIFY)
        if result == '':
            stop = True

    if stop == False:
        for i in data.values():

            name = i["name"]
            cmd = i["cmd"]
            tmp = i["tmp"]
            number = i["number"]
            genre_id = i["genre_id"]
            logo = i["logo"]

            if genre_id_main == '*' and genre_id == '10' and portal[
                    'parental'] == 'true':
                continue

            if genre_id_main == genre_id or genre_id_main == '*':

                if logo != '':
                    #					logo_url = portal['url'] + '/stalker_portal/misc/logos/320/' + logo;
                    logo_url = 'aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL21hY2JsaXp6YXJkL2RuYXR2Z3VpZGUta29kaS9tYXN0ZXIvbG9nb3Mv'.decode(
                        'base64') + logo
                else:
                    logo_url = 'special://home/addons/plugin.video.dnatv/icon.png'

                url = build_url({
                    'mode': 'play',
                    'cmd': cmd,
                    'tmp': tmp,
                    'title': name.encode("utf-8"),
                    'genre_name': genre_name,
                    'logo_url': logo_url,
                    'portal': json.dumps(portal)
                })

                li = xbmcgui.ListItem(name,
                                      iconImage=logo_url,
                                      thumbnailImage=logo_url)
                li.setInfo(type='Video',
                           infoLabels={
                               'title': name,
                               'count': number
                           })

                xbmcplugin.addDirectoryItem(handle=addon_handle,
                                            url=url,
                                            listitem=li)

        xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.addSortMethod(addon_handle,
                                 xbmcplugin.SORT_METHOD_PROGRAM_COUNT)

        xbmcplugin.endOfDirectory(addon_handle)
Ejemplo n.º 9
0
def channelLevel():
    stop = False

    try:
        data = load_channels.getAllChannels(portal["mac"], portal["url"], portal["serial"], addondir)

    except Exception as e:
        xbmcgui.Dialog().notification(Wrong, str(e), xbmcgui.NOTIFICATION_ERROR)
        return

    data = data["channels"]
    genre_name = args.get("genre_name", None)

    genre_id_main = args.get("genre_id", None)
    genre_id_main = genre_id_main[0]

    if genre_id_main == "68" and portal["parental"] == "true":
        result = xbmcgui.Dialog().input(
            "Parental",
            hashlib.md5(portal["password"].encode("utf-8")).hexdigest(),
            type=xbmcgui.INPUT_PASSWORD,
            option=xbmcgui.PASSWORD_VERIFY,
        )
        if result == "":
            stop = True

    if stop == False:
        for i in data.values():

            name = i["name"]
            cmd = i["cmd"]
            tmp = i["tmp"]
            number = i["number"]
            genre_id = i["genre_id"]
            logo = i["logo"]

            if genre_id_main == "*" and genre_id == "10" and portal["parental"] == "true":
                continue

            if genre_id_main == genre_id or genre_id_main == "*":

                if logo != "":
                    logo_url = portal["url"] + "/stalker_portal/misc/logos/321/" + logo
                else:
                    logo_url = "special://home/addons/plugin.video.ufo/fanart.jpg"

                url = build_url(
                    {
                        "mode": "play",
                        "cmd": cmd,
                        "tmp": tmp,
                        "title": name.encode("utf-8"),
                        "genre_name": genre_name,
                        "logo_url": logo_url,
                        "portal": json.dumps(portal),
                    }
                )

                li = xbmcgui.ListItem(name, iconImage=logo_url, thumbnailImage=logo_url)
                li.setInfo(type="Video", infoLabels={"title": name, "count": number})

                xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

        xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_PROGRAM_COUNT)

        xbmcplugin.endOfDirectory(addon_handle)