Python xbmcplugin 模块,SORT_METHOD_DURATION 实例源码

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

项目:plugin.video.amazon65    作者:phil65    | 项目源码 | 文件源码
def LIST_MOVIES(filter='', value=False, sortcol=False, sortaz=True, search=False, cmmode=0):
    import movies as moviesDB
    if 'year' in filter:
        value = value.replace('0 -', '')
    movies = moviesDB.loadMoviedb(movie_filter=filter, value=value, sortcol=sortcol)
    count = 0
    for moviedata in movies:
        count += 1
        ADD_MOVIE_ITEM(moviedata, cmmode=cmmode)
    if not search:
        if sortaz:
            if 'year' not in filter:
                xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_TITLE)
            xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_YEAR)
            xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RUNTIME)
            xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING)
            xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_DURATION)
            xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE)
        common.SetView('movies')
    return count
项目:plugin.video.skygo    作者:trummerjo    | 项目源码 | 文件源码
def listEpisodesFromSeason(series_id, season_id):
    url = skygo.baseUrl + '/sg/multiplatform/web/json/details/series/' + str(series_id) + '_global.json'
    r = requests.get(url)
    data = r.json()['serieRecap']['serie']
    xbmcplugin.setContent(addon_handle, 'episodes')
    for season in data['seasons']['season']:
        if str(season['id']) == str(season_id):
            for episode in season['episodes']['episode']:
                #Check Altersfreigabe / Jugendschutzeinstellungen
                if 'parental_rating' in episode:
                    if js_showall == 'false':
                        if not skygo.parentalCheck(episode['parental_rating']['value'], play=False):   
                            continue
                url = common.build_url({'action': 'playVod', 'vod_id': episode['id']})
                li = xbmcgui.ListItem()
                li.setProperty('IsPlayable', 'true')
                li.addContextMenuItems(getWatchlistContextItem({'type': 'Episode', 'data': episode}), replaceItems=False)
                info, episode = getInfoLabel('Episode', episode)
                li.setInfo('video', info)
                li.setLabel('%02d. %s' % (info['episode'], info['title']))
                li.setArt({'poster': skygo.baseUrl + season['path'], 
                           'fanart': getHeroImage(data),
                           'thumb': skygo.baseUrl + episode['webplayer_config']['assetThumbnail']})
                xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
                                            listitem=li, isFolder=False)

    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_EPISODE)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR) 
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION)
    xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
项目: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’.
    )
项目:plugin.video.skygo    作者:trummerjo    | 项目源码 | 文件源码
def listAssets(asset_list, isWatchlist=False):
    for item in asset_list:
        isPlayable = False
        li = xbmcgui.ListItem(label=item['label'], iconImage=icon_file)
        if item['type'] in ['Film', 'Episode', 'Sport', 'Clip', 'Series', 'live', 'searchresult']:
            isPlayable = True
            #Check Altersfreigabe / Jugendschutzeinstellungen
            if 'parental_rating' in item['data']:
                if js_showall == 'false':
                    if not skygo.parentalCheck(item['data']['parental_rating']['value'], play=False):   
                        continue
            info, item['data'] = getInfoLabel(item['type'], item['data'])
            # xbmc.log( "Debug_Info Current item Element: %s" % (item) ) 
            li.setInfo('video', info)
            li.setLabel(info['title'])         
            li.setArt({'poster': getPoster(item['data']), 'fanart': getHeroImage(item['data'])})           
        if item['type'] in ['Film']:
            xbmcplugin.setContent(addon_handle, 'movies')
            if xbmcaddon.Addon().getSetting('lookup_tmdb_data') == 'true' and 'TMDb_poster_path' in item['data']:
                poster_path = item['data']['TMDb_poster_path'] 
            else:
                poster_path = getPoster(item['data'])
            # xbmc.log('Debug-Info: Current Poster in item: %s' % getPoster(item['data']) ) 
            # xbmc.log('Debug-Info: Current Poster in info: %s' % item['data']['TMDb_poster_path'] )    
            li.setArt({'poster': poster_path})
        elif item['type'] in ['Series']:
            xbmcplugin.setContent(addon_handle, 'tvshows')
            isPlayable = False
        elif item['type'] in ['Episode']:
            xbmcplugin.setContent(addon_handle, 'episodes')
        elif item['type'] in ['Sport', 'Clip']:
            xbmcplugin.setContent(addon_handle, 'files')
            li.setArt({'thumb': getHeroImage(item['data'])})
        elif item['type'] == 'searchresult':          
            xbmcplugin.setContent(addon_handle, 'movies')
        elif item['type'] == ('live'):
            xbmcplugin.setContent(addon_handle, 'files')
            if 'TMDb_poster_path' in item['data']:
                poster = item['data']['TMDb_poster_path']
            elif 'mediainfo' in item['data']:
                poster = getPoster(item['data']['mediainfo'])
            else:
                poster = getPoster(item['data']['channel'])
            fanart = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else skygo.baseUrl + '/bin/Picture/817/C_1_Picture_7179_content_4.jpg'
            thumb = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else getChannelLogo(item['data']['channel'])
            li.setArt({'poster': poster, 'fanart': fanart, 'thumb': thumb})

        #add contextmenu item for watchlist to playable content - not for live and clip content
        if isPlayable and not item['type'] in ['live', 'Clip']:
            li.addContextMenuItems(getWatchlistContextItem(item, isWatchlist), replaceItems=False)
        li.setProperty('IsPlayable', str(isPlayable).lower())
        xbmcplugin.addDirectoryItem(handle=addon_handle, url=item['url'],
                                    listitem=li, isFolder=(not isPlayable))

    xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE)
    xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE)
    xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR)
    xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION)
    xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)