Python xbmcplugin.SORT_METHOD_LABEL Examples

The following are 20 code examples of xbmcplugin.SORT_METHOD_LABEL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module xbmcplugin , or try the search function .
Example #1
Source File: default.py    From tdw with GNU General Public License v3.0 6 votes vote down vote up
def play_url(params):
	torr_link=params['file']
	img=urllib.unquote_plus(params["img"])
	#showMessage('heading', torr_link, 10000)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'TORRENT',port=aceport)
	if out=='Ok':
		for k,v in TSplayer.files.iteritems():
			li = xbmcgui.ListItem(urllib.unquote(k))
			uri = construct_request({
				'torr_url': torr_link,
				'title': k,
				'ind':v,
				'img':img,
				'mode': 'play_url2'
			})
			xbmcplugin.addDirectoryItem(handle, uri, li, False)
	xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
	xbmcplugin.endOfDirectory(handle)
	TSplayer.end() 
Example #2
Source File: xbmcUtils.py    From filmkodi with Apache License 2.0 6 votes vote down vote up
def setSortMethodsForCurrentXBMCList(handle, sortKeys):

    def addSortMethod(method):
        xbmcplugin.addSortMethod(handle = handle, sortMethod = method)

    if not sortKeys or sortKeys==[]:
        addSortMethod(xbmcplugin.SORT_METHOD_UNSORTED)
    else:
        if 'name' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_LABEL)
        if 'size' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_SIZE)
        if 'duration' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_DURATION)
        if 'genre' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_GENRE)
        if 'rating' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_VIDEO_RATING)
        if 'date' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_DATE)
        if 'file' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_FILE) 
Example #3
Source File: mystreams.py    From program.plexus with GNU General Public License v2.0 6 votes vote down vote up
def my_streams_menu():
	if not os.path.exists(mystrm_folder): xbmcvfs.mkdir(mystrm_folder)
	files = os.listdir(mystrm_folder)
	if files:
		for fic in files:
			content = readfile(os.path.join(mystrm_folder,fic)).split('|')
			if content:
				if 'acestream://' in content[1] or '.acelive' in content[1] or '.torrent' in content[1]:
					addDir(content[0],content[1],1,content[2],1,False) 
				elif 'sop://' in content[1]:
					addDir(content[0],content[1],2,content[2],1,False) 
				else:
					pass
		xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
		xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
	addDir('[B][COLOR maroon]'+translate(30009)+'[/COLOR][/B]',MainURL,11,os.path.join(addonpath,art,'plus-menu.png'),1,False) 
Example #4
Source File: main.py    From plugin.video.auvio with GNU General Public License v3.0 6 votes vote down vote up
def menu_categories(params):
    
    listing = []
    
    categories = api.get_menu_categories()

    if categories:
        for item in categories:
            li = category_to_kodi_item(item)
            listing.append(li)  # Item label
        
    sortable_by = (
        xbmcplugin.SORT_METHOD_LABEL
    )

    return common.plugin.create_listing(
        listing,
        #succeeded = True, #if False Kodi won’t open a new listing and stays on the current level.
        #update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one. 
        #cache_to_disk = True, #cache this view to disk.
        #sort_methods = sortable_by, #he list of integer constants representing virtual folder sort methods.
        #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
        #content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’.
    ) 
Example #5
Source File: xbmcUtils.py    From filmkodi with Apache License 2.0 6 votes vote down vote up
def setSortMethodsForCurrentXBMCList(handle, sortKeys):
    
    def addSortMethod(method):
        xbmcplugin.addSortMethod(handle = handle, sortMethod = method)
    
    if not sortKeys or sortKeys==[]: 
        addSortMethod(xbmcplugin.SORT_METHOD_UNSORTED)
    else:     
        if 'name' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_LABEL)
        if 'size' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_SIZE)
        if 'duration' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_DURATION)
        if 'genre' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_GENRE)
        if 'rating' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_VIDEO_RATING)
        if 'date' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_DATE)
        if 'file' in sortKeys:
            addSortMethod(xbmcplugin.SORT_METHOD_FILE) 
Example #6
Source File: default.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def mainScreen(params):
	link='http://manga24.ru/all/'
	http = GET(link)
	if http == None: return False
	beautifulSoup = BeautifulSoup(http)
	content = beautifulSoup.find('select', attrs={'id': 'manga_list'})
	cats=content.findAll('option')
	for manga in cats:
		try:
			manga.prettify()
			title=manga.string
			path=str(manga).split('"')[1]
			listitem=xbmcgui.ListItem(title,addon_icon,addon_icon)
			listitem.setProperty('IsPlayable', 'false')
			listitem.setLabel(title)
			uri = construct_request({
				'func': 'get_manga',
				'm_path':path
				})
			xbmcplugin.addDirectoryItem(hos, uri, listitem, True)
		except: pass
	#xbmcplugin.addSortMethod(hos, xbmcplugin.SORT_METHOD_LABEL)
	#xbmcplugin.addSortMethod(hos, xbmcplugin.SORT_METHOD_TITLE)
	xbmcplugin.endOfDirectory(handle=hos, succeeded=True, updateListing=False, cacheToDisc=True) 
Example #7
Source File: torr2xbmc.py    From ru with GNU General Public License v2.0 6 votes vote down vote up
def play_file(params):
	#получаем содержимое файла в base64
	f = open(params['file'].decode('utf-8'), 'rb')
	buf=f.read()
	f.close
	torr_link=base64.b64encode(buf)
	xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL)
	TSplayer=tsengine()
	out=TSplayer.load_torrent(torr_link,'RAW',port=aceport)
	if out=='Ok':
		for k,v in TSplayer.files.iteritems():

			li = xbmcgui.ListItem(urllib.unquote(k))
			uri = construct_request({
				'torr_url': torr_link,
				'title': k,
				'ind':v,
				'img':None,
				'func': 'play_it'
			})
			xbmcplugin.addDirectoryItem(hos, uri, li, False)
	xbmcplugin.endOfDirectory(hos)
	TSplayer.end() 
Example #8
Source File: common.py    From plugin.video.ustvvod with GNU General Public License v2.0 5 votes vote down vote up
def set_view(type = 'root'):
	confluence_views = [500,501,50,503,504,508,51]
	if type == 'root':
		xbmcplugin.setContent(pluginHandle, 'movies')
	elif type == 'seasons':
		xbmcplugin.setContent(pluginHandle, 'movies')
	else:
		if type == 'tvshows':
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		xbmcplugin.setContent(pluginHandle, type)
	if addon.getSetting('viewenable') == 'true':
		view = int(addon.getSetting(type + 'view'))
		xbmc.executebuiltin('Container.SetViewMode(' + str(confluence_views[view]) + ')') 
Example #9
Source File: tvnplayer.py    From filmkodi with Apache License 2.0 5 votes vote down vote up
def endDir(self, sort=False, content=None, viewMode=None, ps=None):
        '''
        ToDo:
        Check is Confluence, not? other View Mode
        Confluence View Modes:
        http://www.xbmchub.com/forums/general-python-development/717-how-set-default-view-type-xbmc-lists.html#post4683
        https://github.com/xbmc/xbmc/blob/master/addons/skin.confluence/720p/MyVideoNav.xml
        '''
        if ps == None:
            ps = int(sys.argv[1])
        if sort == True:
            xbmcplugin.addSortMethod(ps, xbmcplugin.SORT_METHOD_LABEL)
        canBeContent = ["files", "songs", "artists", "albums", "movies", "tvshows", "episodes", "musicvideos"]
        if content in canBeContent:
            xbmcplugin.setContent(ps, content)
        if viewMode != None:
            viewList = {}
            if 'confluence' in xbmc.getSkinDir():
                viewList = {
                    'List': '50',
                    'Big List': '51',
                    'ThumbnailView': '500',
                    'PosterWrapView': '501',
                    'PosterWrapView2_Fanart': '508',
                    'MediaInfo': '504',
                    'MediaInfo2': '503',
                    'MediaInfo3': '515',
                    'WideIconView': '505',
                    'MusicVideoInfoListView': '511',
                    'AddonInfoListView1': '550',
                    'AddonInfoThumbView1': '551',
                    'LiveTVView1': '560'
                }
            if viewMode in viewList:
                view = viewList[viewMode]
            else:
                view = 'None'
            xbmc.executebuiltin("Container.SetViewMode(%s)" % (view))
        xbmcplugin.endOfDirectory(ps) 
Example #10
Source File: addon.py    From plugin.git.browser with GNU General Public License v3.0 5 votes vote down vote up
def set_view(view_id, content=None):
	if content is not None:
		xbmcplugin.setContent(HANDLE_ID, content)

	xbmc.executebuiltin("Container.SetViewMode(%s)" % view_id)
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_LABEL )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RATING )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_DATE )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_PROGRAM_COUNT )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_RUNTIME )
	xbmcplugin.addSortMethod( handle=HANDLE_ID, sortMethod=xbmcplugin.SORT_METHOD_GENRE ) 
Example #11
Source File: default.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def get_manga(params):
	link='http://manga24.ru%s'%params['m_path']
	http = GET(link)
	if http == None: return False
	#print http
	beautifulSoup = BeautifulSoup(http)
	content = beautifulSoup.find('ul', attrs={'class': 'mlist'})
	try:
		cats=content.findAll('li')
		for scene in cats:
			title= str(scene).split('"')[1].split('/')[2]
			path= scene.find('a')['href']
			listitem=xbmcgui.ListItem(title,addon_icon,addon_icon)
			listitem.setProperty('IsPlayable', 'false')
			
			uri = construct_request({
				'func': 'read_manga',
				'm_path':path
				})
			xbmcplugin.addDirectoryItem(hos, uri, listitem, True)
	except: 
		try:
			content = beautifulSoup.find('div', attrs={'class': 'item2'})
			path= content.find('a')['href']
			listitem=xbmcgui.ListItem("Читать",addon_icon,addon_icon)
			listitem.setProperty('IsPlayable', 'false')
			uri = construct_request({
				'func': 'read_manga',
				'm_path':path
				})
			xbmcplugin.addDirectoryItem(hos, uri, listitem, True)
		except: pass
	xbmcplugin.addSortMethod(hos, xbmcplugin.SORT_METHOD_LABEL)
	xbmcplugin.addSortMethod(hos, xbmcplugin.SORT_METHOD_TITLE)
	#xbmcplugin.endOfDirectory(handle=hos, succeeded=True, updateListing=False, cacheToDisc=True)
	xbmcplugin.endOfDirectory(handle=hos, succeeded=True, updateListing=False, cacheToDisc=True) 
Example #12
Source File: torr2xbmc.py    From ru with GNU General Public License v2.0 5 votes vote down vote up
def start_torr(params):
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    TSplayer=TSengine()
    out=TSplayer.load_torrent(params['file'],'TORRENT')
    if out=='Ok':
        for k,v in TSplayer.files.iteritems():
            if TSplayer.files.__len__() == 1:
               p=urllib.unquote_plus(params['title1'])
            else: p=urllib.unquote_plus(k)
            li = xbmcgui.ListItem(urllib.unquote(k), urllib.unquote(k), params['img'], params['img'])
            #if __addon__.getSetting('fanart') == 'false':
            li.setProperty('fanart_image', params['img'])
            li.setInfo(type = "Video", infoLabels = {'year': params['year'], 'genre': params['genre'], 'plot': params['descr'], 'director': params['director'], 'writer': params['writer'], 'rating': params['rating']})
            #li = xbmcgui.ListItem(urllib.unquote(k))
            li.setProperty('IsPlayable', 'true')
            #li.addContextMenuItems([('Добавить в плейлист', 'XBMC.RunPlugin(%s)' % uri),])
            uri = construct_request({
                'torr_url': urllib.quote(params['file']),
                'title': k,
                'title1': p,
                'ind':v,
                'img':params['img'],
                'func': 'play_url2'
            })
            #li.addContextMenuItems([('Добавить в плейлист', 'XBMC.RunPlugin(%s?func=addplist&torr_url=%s&title=%s&ind=%s&img=%s&func=play_url2)' % (sys.argv[0],urllib.quote(torr_link),k,v,img  )),])
            xbmcplugin.addDirectoryItem(hos, uri, li)
    xbmcplugin.addSortMethod(hos, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(hos)
    xbmc.executebuiltin('Container.SetViewMode(%s)' % view_mode)
    TSplayer.end() 
Example #13
Source File: addon.py    From script.module.clouddrive.common with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        self._addon = KodiUtils.get_addon()
        self._addonid = self._addon.getAddonInfo('id')
        self._addon_name = self._addon.getAddonInfo('name')
        self._addon_url = sys.argv[0]
        self._addon_version = self._addon.getAddonInfo('version')
        self._common_addon_id = 'script.module.clouddrive.common'
        self._common_addon = KodiUtils.get_addon(self._common_addon_id)
        self._common_addon_version = self._common_addon.getAddonInfo('version')
        self._dialog = xbmcgui.Dialog()
        self._profile_path = Utils.unicode(KodiUtils.translate_path(self._addon.getAddonInfo('profile')))
        self._progress_dialog = DialogProgress(self._addon_name)
        self._progress_dialog_bg = DialogProgressBG(self._addon_name)
        self._export_progress_dialog_bg = DialogProgressBG(self._addon_name)
        self._system_monitor = KodiUtils.get_system_monitor()
        self._account_manager = AccountManager(self._profile_path)
        self._pin_dialog = None
        self.iskrypton = KodiUtils.get_home_property('iskrypton') == 'true'
        
        if len(sys.argv) > 1:
            self._addon_handle = int(sys.argv[1])
            self._addon_params = urlparse.parse_qs(sys.argv[2][1:])
            for param in self._addon_params:
                self._addon_params[param] = self._addon_params.get(param)[0]
            self._content_type = Utils.get_safe_value(self._addon_params, 'content_type')
            if not self._content_type:
                wid = xbmcgui.getCurrentWindowId()
                if wid == 10005 or wid == 10500 or wid == 10501 or wid == 10502:
                    self._content_type = 'audio'
                elif wid == 10002:
                    self._content_type = 'image'
                else:
                    self._content_type = 'video'
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED ) 
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_SIZE )
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DATE )
            xbmcplugin.addSortMethod(handle=self._addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION ) 
Example #14
Source File: main.py    From plugin.video.auvio with GNU General Public License v3.0 5 votes vote down vote up
def menu_favorites(params):
    
    if not user_has_account():
        
        common.popup("Veuillez configurer votre compte dans les options de l'addon.")
        
    else:
        
        listing = []
        
        #get user token
        try:
            user_token = get_user_jwt_token()
        except ValueError as e:
            common.popup(e) # warn user
            return

        favorites =  api.get_user_favorites(user_token)

        if favorites:
            for favorite in favorites:
                media_id = favorite.get('data',{}).get('id',0)
                media_node = api.get_media_details(media_id) #so we match the other API medias; because media_to_kodi_item can handle it - which is not the case of the current 'data' attribute. TOFIX TOCHECK.
                li = media_to_kodi_item(media_node)
                listing.append(li)  # Item label

        sortable_by = (
            xbmcplugin.SORT_METHOD_LABEL
        )

        return common.plugin.create_listing(
            listing,
            #succeeded = True, #if False Kodi won’t open a new listing and stays on the current level.
            #update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one. 
            #cache_to_disk = True, #cache this view to disk.
            #sort_methods = sortable_by, #he list of integer constants representing virtual folder sort methods.
            #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
            #content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’.
        ) 
Example #15
Source File: addon.py    From Kodi with GNU Lesser General Public License v3.0 5 votes vote down vote up
def kodi_draw_list(parts, rows):
    for row in rows:
        xbmcplugin.addDirectoryItem(*row.item(parts))

    xbmcplugin.addSortMethod(h, xbmcplugin.SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(h, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.addSortMethod(h, xbmcplugin.SORT_METHOD_VIDEO_RATING)
    xbmcplugin.addSortMethod(h, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
    xbmcplugin.addSortMethod(h, xbmcplugin.SORT_METHOD_DATE)
    xbmcplugin.setContent(h, 'files')
    xbmcplugin.endOfDirectory(h) 
Example #16
Source File: directory_utils.py    From plugin.video.netflix with MIT License 5 votes vote down vote up
def add_sort_methods(sort_type):
    if sort_type == 'sort_nothing':
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_NONE)
    if sort_type == 'sort_label':
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_LABEL)
    if sort_type == 'sort_label_ignore_folders':
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_FOLDERS)
    if sort_type == 'sort_episodes':
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_EPISODE)
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.addSortMethod(g.PLUGIN_HANDLE, xbmcplugin.SORT_METHOD_VIDEO_TITLE) 
Example #17
Source File: main.py    From plugin.video.iptv.recorder with GNU General Public License v3.0 4 votes vote down vote up
def recordings():
    dir = plugin.get_setting('recordings')
    found_files = find_files(dir)

    items = []
    starts = []

    for path in found_files:
        try:
            json_file = path[:-3]+'.json'
            info = json.loads(xbmcvfs.File(json_file).read())
            programme = info["programme"]

            title = programme['title']
            sub_title = programme['sub_title'] or ''
            episode = programme['episode']
            date = "(%s)" % programme['date'] or ''
            start = programme['start']
            starts.append(start)

            if episode and episode != "MOVIE":
                label = "%s [COLOR grey]%s[/COLOR] %s" % (title, episode, sub_title)
            elif episode == "MOVIE":
                label = "%s %s" % (title,date)
            else:
                label = "%s %s" % (title, sub_title)

            description = programme['description']
        except:
            label = os.path.splitext(os.path.basename(path))[0]
            description = ""
            starts.append("0")
            label = urllib.unquote_plus(label)
            label = label.decode("utf8")

        context_items = []

        context_items.append((_("Delete Recording"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(delete_recording, label=label.encode("utf8"), path=path))))
        context_items.append((_("Delete All Recordings"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(delete_all_recordings))))
        if plugin.get_setting('external.player'):
            context_items.append((_("External Player"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(play_external, path=path))))
        #context_items.append((_("Convert to mp4"), 'XBMC.RunPlugin(%s)' % (plugin.url_for(convert, path=path))))

        items.append({
            'label': label,
            'path': path,
            'is_playable': True,
            'context_menu': context_items,
            'info_type': 'Video',
            'info':{"title": label, "plot":description},
        })

    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_UNSORTED )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_DATE )

    start_items = zip(starts,items)
    start_items.sort(reverse=True)
    items = [x for y, x in start_items]
    return sorted(items, key=lambda k: k['label'].lower()) 
Example #18
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 4 votes vote down vote up
def build_profiles_listing(self, profiles, action, build_url):
        """
        Builds the profiles list Kodi screen

        :param profiles: list of user profiles
        :type profiles: list
        :param action: action paramter to build the subsequent routes
        :type action: str
        :param build_url: function to build the subsequent routes
        :type build_url: fn
        :returns: bool -- List could be build
        """
        # init html parser for entity decoding
        html_parser = HTMLParser()
        # build menu items for every profile
        for profile in profiles:
            # load & encode profile data
            enc_profile_name = profile.get('profileName', '')
            unescaped_profile_name = html_parser.unescape(enc_profile_name)
            profile_guid = profile.get('guid')

            # build urls
            url = build_url({'action': action, 'profile_id': profile_guid})
            autologin_url = build_url({
                'action': 'save_autologin',
                'autologin_id': profile_guid,
                'autologin_user': enc_profile_name})

            # add list item
            list_item = xbmcgui.ListItem(
                label=unescaped_profile_name)
            list_item.setArt(
                {'fanart_image' : self.default_fanart,
                 'icon' : profile.get('avatar')})
            # add context menu options
            auto_login = (
                self.get_local_string(30053),
                'RunPlugin(' + autologin_url + ')')
            list_item.addContextMenuItems(items=[auto_login])

            # add directory & sorting options
            xbmcplugin.addDirectoryItem(
                handle=self.plugin_handle,
                url=url,
                listitem=list_item,
                isFolder=True)
            xbmcplugin.addSortMethod(
                handle=self.plugin_handle,
                sortMethod=xbmcplugin.SORT_METHOD_LABEL)

        xbmcplugin.setContent(
            handle=self.plugin_handle,
            content=CONTENT_FOLDER)

        return xbmcplugin.endOfDirectory(handle=self.plugin_handle) 
Example #19
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 4 votes vote down vote up
def build_user_sub_listing(self, video_list_ids, type, action, build_url,
                               widget_display=False):
        """
        Builds the video lists screen for user subfolders
        (genres & recommendations)

        Parameters
        ----------
        video_list_ids : :obj:`dict` of :obj:`str`
            List of video lists

        type : :obj:`str`
            List type (genre or recommendation)

        action : :obj:`str`
            Action paramter to build the subsequent routes

        build_url : :obj:`fn`
            Function to build the subsequent routes

        Returns
        -------
        bool
            List could be build
        """
        for video_list_id in video_list_ids:
            li = xbmcgui.ListItem(
                label=video_list_ids[video_list_id]['displayName'])
            li.setArt(
                {'fanart_image' : self.default_fanart,
                 'icon' : self.default_fanart})

            url = build_url({'action': action, 'video_list_id': video_list_id})
            xbmcplugin.addDirectoryItem(
                handle=self.plugin_handle,
                url=url,
                listitem=li,
                isFolder=True)

        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.setContent(
            handle=self.plugin_handle,
            content=CONTENT_FOLDER)
        xbmcplugin.endOfDirectory(self.plugin_handle)
        if not widget_display:
            self.set_custom_view(VIEW_FOLDER)
        return True 
Example #20
Source File: KodiHelper.py    From plugin.video.netflix with MIT License 4 votes vote down vote up
def build_season_listing(self, seasons_sorted, build_url, widget_display=False):
        """Builds the season list screen for a show

        Parameters
        ----------
        seasons_sorted : :obj:`list` of :obj:`dict` of :obj:`str`
            Sorted list of season entries

        build_url : :obj:`fn`
            Function to build the subsequent routes

        Returns
        -------
        bool
            List could be build
        """
        for season in seasons_sorted:
            li = xbmcgui.ListItem(label=season['text'])
            # add some art to the item
            li.setArt(self._generate_art_info(entry=season))
            # add list item info
            infos = self._generate_listitem_info(
                entry=season,
                li=li,
                base_info={'mediatype': 'season'})
            self._generate_context_menu_items(entry=season, li=li)
            params = {'action': 'episode_list', 'season_id': season['id']}
            if 'tvshowtitle' in infos:
                title = infos.get('tvshowtitle', '').encode('utf-8')
                params['tvshowtitle'] = base64.urlsafe_b64encode(title)
            url = build_url(params)
            xbmcplugin.addDirectoryItem(
                handle=self.plugin_handle,
                url=url,
                listitem=li,
                isFolder=True)

        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_NONE)
        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_LASTPLAYED)
        xbmcplugin.addSortMethod(
            handle=self.plugin_handle,
            sortMethod=xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.setContent(
            handle=self.plugin_handle,
            content=CONTENT_SEASON)
        xbmcplugin.endOfDirectory(self.plugin_handle)
        if not widget_display:
            self.set_custom_view(VIEW_SEASON)
        return True