Python xbmcplugin 模块,SORT_METHOD_DATE 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用xbmcplugin.SORT_METHOD_DATE

项目:plugin.video.telekom-sport    作者:asciidisco    | 项目源码 | 文件源码
def show_sport_selection(self):
        """Creates the KODI list items for the static sport selection"""
        self.utils.log('Sport selection')
        sports = self.constants.get_sports_list()

        for sport in sports:
            url = self.utils.build_url({'for': sport})
            list_item = xbmcgui.ListItem(label=sports.get(sport).get('name'))
            list_item = self.item_helper.set_art(
                list_item=list_item,
                sport=sport)
            xbmcplugin.addDirectoryItem(
                handle=self.plugin_handle,
                url=url,
                listitem=list_item,
                isFolder=True)
            xbmcplugin.addSortMethod(
                handle=self.plugin_handle,
                sortMethod=xbmcplugin.SORT_METHOD_DATE)
        xbmcplugin.endOfDirectory(self.plugin_handle)
项目:catchup4kodi    作者:catchup4kodi    | 项目源码 | 文件源码
def addDir(name,url,mode,iconimage,plot='',isFolder=True):
        try:
            PID = iconimage.split('productionId=')[1]
        except:pass    
        u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)
        ok=True
        liz=xbmcgui.ListItem(name,iconImage="DefaultVideo.png", thumbnailImage=iconimage)
        liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": plot,'Premiered' : '2012-01-01','Episode' : '7-1' } )
        menu=[]
        if mode == 2:
            menu.append(('[COLOR yellow]Add To Favourites[/COLOR]','XBMC.RunPlugin(%s?mode=13&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,PID)))
        if mode == 204:
            menu.append(('[COLOR yellow]Remove Favourite[/COLOR]','XBMC.RunPlugin(%s?mode=14&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,iconimage)))
        liz.addContextMenuItems(items=menu, replaceItems=False)    
        if mode==3:
            xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
        if isFolder==False:
            liz.setProperty("IsPlayable","true")
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder)
        return ok
项目:plugin.video.telekom-sport    作者:asciidisco    | 项目源码 | 文件源码
def show_date_list(self, _for):
        """
        Creates the KODI list items for a list of dates with contents
        based on the current date & syndication.

        :param _for: Chosen sport
        :type _for: string
        """
        self.utils.log('Main menu')
        plugin_handle = self.plugin_handle
        addon_data = self.utils.get_addon_data()
        epg = self.get_epg(_for)
        for _date in epg.keys():
            title = ''
            items = epg.get(_date)
            for item in items:
                title = title + \
                    str(' '.join(item.get('title').replace('Uhr', '').split(
                        ' ')[:-2]).encode('utf-8')) + '\n\n'
            url = self.utils.build_url({'date': date, 'for': _for})
            list_item = xbmcgui.ListItem(label=_date)
            list_item.setProperty('fanart_image', addon_data.get('fanart'))
            list_item.setInfo('video', {
                'date': date,
                'title': title,
                'plot': title,
            })
            xbmcplugin.addDirectoryItem(
                handle=plugin_handle,
                url=url,
                listitem=list_item,
                isFolder=True)
            xbmcplugin.addSortMethod(
                handle=plugin_handle,
                sortMethod=xbmcplugin.SORT_METHOD_DATE)
        xbmcplugin.endOfDirectory(plugin_handle)
项目:plugin.video.auvio    作者:rickybiscus    | 项目源码 | 文件源码
def list_medias(params):

    common.plugin.log("list_medias")
    common.plugin.log(json.dumps(params))

    filter_medias = params.get('filter_medias','')
    page =          int(params.get('page',1))
    channel_id =    int(params.get('channel_id',0))
    category_id =   int(params.get('category_id',0))
    program_id =    int(params.get('program_id',0))

    nodes = []
    listing = []
    listing_params = {}

    #live
    if filter_medias == 'live_medias_recent':
        nodes = api.get_live_videos(page)
    #program
    elif filter_medias == 'program_medias_recent':
        nodes = api.get_program_medias(program_id,page)
        listing_params['show_channel'] = False
    #category
    elif filter_medias == 'category_medias_recent':
        nodes = api.get_category_medias(category_id,page)

    for node in nodes:
        li = media_to_kodi_item(node,listing_params)
        listing.append(li)  # Item label

    #menu link
    link_root = navigate_root()
    listing.append(link_root)

    #pagination link if the listing is not empty
    if len(nodes):
        link_next = next_medias_link(params)
        if link_next:
            listing.append(link_next)

    sortable_by = (xbmcplugin.SORT_METHOD_DATE,
                   xbmcplugin.SORT_METHOD_DURATION)

    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’.
    )