def make_matches_list(params, live=False):
    """
    """
    listing = []
    if live:
        matches = comm.list_matches(params, live=True)
        upcoming = comm.get_upcoming()

        for event in upcoming:
            thumb = os.path.join(addonPath, 'resources', 'soon.jpg')
            li = xbmcgui.ListItem(event, iconImage=thumb)
            url = '{0}?action=listmatches{1}'.format(_url, m.make_kodi_url())
            is_folder = False
            listing.append((url, li, is_folder))
        xbmcplugin.addSortMethod(_handle,
                                 sortMethod=xbmcplugin.SORT_METHOD_UNSORTED)

    else:
        matches = comm.list_matches(params)

    for m in matches:
        li = xbmcgui.ListItem(label=str(m.title),
                              iconImage=m.thumb,
                              thumbnailImage=m.thumb)
        url = '{0}?action=listmatches{1}'.format(_url, m.make_kodi_url())
        is_folder = False
        li.setProperty('IsPlayable', 'true')
        li.setInfo('video', {'plot': m.desc, 'plotoutline': m.desc})
        listing.append((url, li, is_folder))

    xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
    xbmcplugin.endOfDirectory(_handle)
def list_matches(params, live=False):
    """
    """
    try:
        listing = []
        if not live:
            matches = comm.list_matches(params, live)
        else:
            matches = comm.get_live_matches()

        for m in matches:
            li = xbmcgui.ListItem(label=str(m.title), iconImage=m.thumb,
                                  thumbnailImage=m.thumb)
            url = '{0}?action=listmatches{1}'.format(_url, m.make_kodi_url())
            is_folder = False
            li.setProperty('IsPlayable', 'true')
            li.setInfo('video', {'plot': m.desc, 'plotoutline': m.desc})
            listing.append((url, li, is_folder))

        if live:
            upcoming = comm.get_upcoming()
            for event in upcoming:
                thumb = os.path.join(addonPath, 'resources', 'soon.jpg')
                li = xbmcgui.ListItem(event.title, iconImage=thumb)
                url = '{0}?action=listmatches{1}'.format(
                    _url, event.make_kodi_url())
                is_folder = False
                listing.append((url, li, is_folder))
            xbmcplugin.addSortMethod(
                _handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED)

        xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
        xbmcplugin.endOfDirectory(_handle)
    except Exception:
        utils.handle_error('Unable to fetch match list')
def make_replay_list(params):
    try:
        listing = []
        matches = comm.list_matches(params)

        for m in matches:
            li = xbmcgui.ListItem(label=m.title,
                                  iconImage=m.thumb,
                                  thumbnailImage=m.thumb)
            url = '{0}?action=listreplays{1}'.format(_url, m.make_kodi_url())
            is_folder = False
            li.setProperty('IsPlayable', 'true')
            li.setInfo('video', {'plot': m.title, 'plotoutline': m.title})
            listing.append((url, li, is_folder))

        xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
        xbmcplugin.endOfDirectory(_handle)
    except Exception:
        utils.handle_error('Unable to display match replays')