Esempio n. 1
0
def new_viditem(v={}, as_dict=False):
    pathdl = plugin.url_for(endpoint=download, vurl=v.get('contentUrl', v.get('hostPageUrl', '')))
    ctxlist = []
    citem = ('Download', 'RunPlugin({0})'.format(pathdl),)
    ctxlist.append(citem)
    pathdel = plugin.url_for(endpoint=fav_del, idvid=v.get('videoId', ''))
    citem = ('DELETE', 'RunPlugin({0})'.format(pathdel),)
    ctxlist.append(citem)
    img = v.get('thumbnail', v.get('thumbnailUrl', 'DefaultVideo.png'))
    lbl = v.get('label', v.get('name', ''))
    lbl2 = v.get('label2', v.get('videoId', ''))
    vidpath = v.get('path', None)
    if vidpath is None:
        vidpath = plugin.url_for(endpoint=play, vtitle=v.get('name', lbl), vurl=v.get('contentUrl', v.get('hostPageUrl', lbl2)))
    xitem = None
    if not as_dict:
        xitem = ListItem(label=lbl, label2=lbl2, icon=img, thumbnail=img, path=vidpath)
        xitem.add_context_menu_items(items=ctxlist, replace_items=False)
        xitem.playable = True
        xitem.is_folder = False
        xitem.set_info(info_type='video', info_labels={'Title': lbl, 'Plot': lbl2, 'Premiered': v.get('datePublished', '')})
        xitem.thumbnail = img
        xitem.icon = img
        idvid = v.get('videoId', 0)
        if idvid is not 0:
            xitem.set_property(key='videoId', value=idvid)
            xitem.set_info(info_type='video', info_labels={'VideoID': idvid})
    else:
        xitem = {'label': lbl, 'label2': lbl2, 'icon': img, 'thumbnail': img, 'is_playable': True, 'path': vidpath}
    return xitem
Esempio n. 2
0
    def test_icon(self):
        item = ListItem()
        self.assertIsNone(item.icon)

        item.icon = 'bar'
        self.assertEqual(item.icon, 'bar')
        self.assertEqual(item.get_icon(), 'bar')

        item.set_icon('baz')
        self.assertEqual(item.icon, 'baz')
        self.assertEqual(item.get_icon(), 'baz')
Esempio n. 3
0
    def test_icon(self):
        item = ListItem()
        self.assertIsNone(item.icon)

        item.icon = 'bar'
        self.assertEqual(item.icon, 'bar')
        self.assertEqual(item.get_icon(), 'bar')

        item.set_icon('baz')
        self.assertEqual(item.icon, 'baz')
        self.assertEqual(item.get_icon(), 'baz')