Пример #1
0
def addEntries(l):
    lists = []
    doneList = []

    for d in l:
        if str(d) in doneList:  #primitive methode to filter duplicated entries
            continue
        doneList.append(str(d))

        if '_overridepath' in d:
            u = d['_overridepath']
        else:
            u = _buildUri(d)
        newd = {}
        for key in d:
            if key.startswith('_'):
                if isinstance(d[key], unicode):
                    d[key] = d[key].encode('utf-8', 'ignore')
                newd[key[1:]] = d[key]
            elif isinstance(d[key], unicode):
                newd[key] = d[key].encode('utf-8', 'ignore')
            else:
                newd[key] = d[key]
        d = newd

        if 'type' in d and d['type'] == 'nextPage':
            d['name'] = translation(31040)
            if not 'mode' in d:
                d['mode'] = get_params()['mode']
        if isinstance(d["name"], unicode):
            d["name"] = d["name"].encode('utf-8')
        d["name"] = clearString(d["name"])
        if 'airedISO8601' in d or 'airedISO8601A' in d:
            d['aired'], d['airedtime'] = _airedISO8601(d)

        if 'type' in d and d['type'] == 'date' and 'airedtime' in d:
            d["name"] = '(' + str(d["airedtime"]) + ') ' + d["name"]
        elif 'type' in d and d['type'] == 'date' and 'time' in d:
            d["name"] = '(' + str(d["date"]) + ') ' + d["name"]

        ilabels = {
            "Title": clearString(d.get('name', '')),
            "Plot": clearString(d.get('plot', '')),
            "Plotoutline": clearString(d.get('plot', '')),
            "Duration": d.get('duration', ''),
            "Mpaa": d.get('mpaa', ''),
            "Aired": d.get('aired', ''),
            "Studio": d.get('channel', ''),
        }
        if 'epoch' in d:
            ilabels['aired'] = time.strftime("%Y-%m-%d",
                                             time.gmtime(float(d['epoch'])))
        if 'episode' in d:
            ilabels['episode'] = d['episode']
        if 'season' in d:
            ilabels['season'] = d['season']
        if 'plot' in d:
            ilabels['plot'] = d['plot']
            ilabels['plotoutline'] = d['plot']
        if 'plotoutline' in d:
            ilabels['plotoutline'] = d['plotoutline']
        if 'tvshowtitle' in d:
            ilabels['tvshowtitle'] = d['tvshowtitle']
            #ilabels['tagline'] = d['tvshowtitle']
            #ilabels['album'] = d['tvshowtitle']
        if 'rating' in d:
            ilabels['rating'] = d['rating']
        if 'type' in d and d['type'] != 'nextPage':
            if d['type'] == 'video' or d['type'] == 'live' or d[
                    'type'] == 'date' or d['type'] == 'clip':
                ilabels['mediatype'] = 'video'
            elif d['type'] == 'shows' or d['type'] == 'season':
                ilabels['mediatype'] = 'season'
            elif d['type'] == 'episode':
                ilabels['mediatype'] = 'episode'
            else:
                ilabels['mediatype'] = 'video'

        ok = True
        liz = xbmcgui.ListItem(clearString(d.get('name', '')))
        if d['type'] == 'audio':
            liz.setInfo(type="music", infoLabels=ilabels)
        else:
            liz.setInfo(type="Video", infoLabels=ilabels)
        liz.addStreamInfo('subtitle', {'language': 'deu'})
        art = {}
        art['thumb'] = d.get('thumb')
        art['landscape'] = d.get('thumb')
        art['poster'] = d.get('thumb')
        art['fanart'] = d.get('fanart', d.get('thumb', fanart))
        art['icon'] = d.get('channelLogo', '')
        liz.setArt(art)

        if 'customprops' in d:
            for prop in d['customprops']:
                liz.setProperty(prop, d['customprops'][prop])

        if d.get('type',
                 None) == 'video' or d.get('type', None) == 'live' or d.get(
                     'type',
                     None) == 'date' or d.get('type', None) == 'clip' or d.get(
                         'type', None) == 'episode' or d.get(
                             'type', None) == 'audio' or d.get(
                                 'type', None) == 'sport':
            #xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content="episodes" )
            liz.setProperty('IsPlayable', 'true')
            lists.append([u, liz, False])
        else:
            lists.append([u, liz, True])

    if len(l) > 0:
        type = l[0]['_type']
        if type == 'video' or type == 'live' or type == 'date' or type == 'clip' or type == 'episode':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content="episodes")
        elif type == 'shows' or type == 'season':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content="tvshows")
        elif type == 'sport':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content="sport")
        else:
            xbmcplugin.setContent(handle=int(sys.argv[1]), content="files")

    xbmcplugin.addDirectoryItems(int(sys.argv[1]), lists)
Пример #2
0
def addEntries(l):
    lists = []
    doneList = []

    download_dir = getSetting('download_dir')

    for d in l:
        if str(d) in doneList:  #primitive methode to filter duplicated entries
            continue
        doneList.append(str(d))

        if '_overridepath' in d:
            u = d['_overridepath']
        else:
            u = _buildUri(d)
        newd = {}
        for key in d:
            if sys.version_info[0] < 3:  # for Python 2
                if isinstance(d[key], unicode):
                    d[key] = d[key].encode('utf-8', 'ignore')
            if key.startswith('_'):
                newd[key[1:]] = d[key]
            else:
                newd[key] = d[key]
        d = newd

        if 'type' in d and d['type'] == 'nextPage':
            d['name'] = translation(31040)
            if not 'mode' in d:
                d['mode'] = get_params()['mode']
        if sys.version_info[0] < 3:  # for Python 2
            if isinstance(d['name'], unicode):
                d['name'] = d['name'].encode('utf-8')
        d['name'] = clearString(d['name'])
        if 'airedISO8601' in d:
            d['aired'], d['airedtime'] = _airedISO8601(d)

        if d.get('type', None) == 'date' and d.get('airedtime', None):
            d['name'] = '[COLOR orange]' + str(
                d['airedtime']) + '[/COLOR]  ' + d['name']

        ilabels = {
            'Title': clearString(d.get('name', '')),
            'Plot': clearString(d.get('plot', '')),
            'Plotoutline': clearString(d.get('plot', '')),
            'Duration': d.get('duration', ''),
            'Mpaa': d.get('mpaa', ''),
            'Aired': d.get('aired', ''),
            'Studio': d.get('channel', ''),
        }
        if 'epoch' in d:
            ilabels['aired'] = time.strftime('%Y-%m-%d',
                                             time.gmtime(float(d['epoch'])))
        if 'episode' in d:
            ilabels['Episode'] = d['episode']
        if 'Season' in d:
            ilabels['Season'] = d['season']
        if 'tvshowtitle' in d:
            ilabels['tvshowtitle'] = d['tvshowtitle']
            ilabels['tagline'] = d['tvshowtitle']
            ilabels['album'] = d['tvshowtitle']
        if 'rating' in d:
            ilabels['rating'] = d['rating']
        if 'type' in d and d['type'] != 'nextPage':
            if d['type'] == 'video' or d['type'] == 'live' or d[
                    'type'] == 'date' or d['type'] == 'clip':
                ilabels['mediatype'] = 'video'
            elif d['type'] == 'shows' or d['type'] == 'season':
                ilabels['mediatype'] = 'season'
            elif d['type'] == 'episode':
                ilabels['mediatype'] = 'episode'
            elif d['type'] != 'dir':
                ilabels['mediatype'] = 'video'

        ok = True
        liz = xbmcgui.ListItem(clearString(d.get('name', '')))
        if d.get('type', None) == 'audio':
            liz.setInfo(type='music', infoLabels=ilabels)
        else:
            liz.setInfo(type='video', infoLabels=ilabels)
        liz.addStreamInfo('subtitle', {'language': 'deu'})
        art = {}
        art['thumb'] = d.get('thumb')
        art['landscape'] = d.get('thumb')
        art['poster'] = d.get('thumb')
        art['fanart'] = d.get('fanart', d.get('thumb', fanart))
        art['icon'] = d.get('channelLogo', '')
        liz.setArt(art)

        if 'customprops' in d:
            for prop in d['customprops']:
                liz.setProperty(prop, d['customprops'][prop])

        if d.get('type',
                 None) == 'video' or d.get('type', None) == 'live' or d.get(
                     'type',
                     None) == 'date' or d.get('type', None) == 'clip' or d.get(
                         'type', None) == 'episode' or d.get('type',
                                                             None) == 'audio':
            #xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ), content='episodes' )
            liz.setProperty('IsPlayable', 'true')
            if d.get('type', None) == 'live':
                liz.setProperty('starttime', '1')
                liz.setProperty('totaltime', '1')
            if download_dir and d.get('type', None) in ('video', 'date'):
                liz.addContextMenuItems([
                    ('Download', 'RunPlugin(%s&download_dir=%s)' %
                     (u, quote_plus(download_dir)))
                ])
            lists.append([u, liz, False])
        else:
            lists.append([u, liz, True])

    if len(l) > 0:
        type = l[0]['_type']
        if type == 'video' or type == 'live':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content='videos')
        elif type == 'date' or type == 'clip' or type == 'episode':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
        elif type == 'shows' or type == 'season':
            xbmcplugin.setContent(handle=int(sys.argv[1]), content='tvshows')
        else:
            xbmcplugin.setContent(handle=int(sys.argv[1]), content='files')

    xbmcplugin.addDirectoryItems(int(sys.argv[1]), lists)