def test_poster(self): item = ListItem() self.assertIsNone(item.poster) item.poster = 'bar' self.assertEqual(item.poster, 'bar') item.poster = 'baz' self.assertEqual(item.poster, 'baz')
def makeitem(name=None, img=None, path='blogposts', playable=False, **kwargs): #if doDebug(): xitem = None try: if not path.startswith('plugin://'): itempath = plugin.url_for(endpoint=path, items=kwargs) else: itempath = path lbl2 = kwargs.get("label2", itempath.partition('plugin.video.tumblrv/')[-1]) if img is None: img = "https://api.tumblr.com/v2/blog/{0}/avatar/64".format(name) xitem = ListItem(label=name, label2=lbl2, icon=img, thumbnail=img, path=itempath) xitem.playable = playable xitem.poster = img #litem = {'label': name, 'thumbnail': img, 'icon': img, 'is_playable': playable, 'path': itempath)} if path == 'blogposts': img = "https://api.tumblr.com/v2/blog/{0}/avatar/64".format(name) elif plugin.request.path.find( 'following/') != -1 or plugin.request.path.find( 'liked/') != -1 or plugin.request.path.find( 'dashboard/') != -1: blogname = kwargs.get('blogname', name) ctxaction = "RunPlugin({0})".format( plugin.url_for(endpoint=blogposts, blogname=blogname)) cname = "[COLOR green]GOTO:[/COLOR] {0}".format(blogname) citem = ( cname, ctxaction, ) ctxlist.append(citem) vidurl = kwargs.get("vidurl", None) if vidurl is not None: pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl) citem = ( 'Download', 'RunPlugin({0})'.format(pathdl), ) ctxlist.append(citem) vidid = kwargs.get('id', None) if vidid is not None: pathaddlike = plugin.url_for(endpoint=addlike, id=vidid) citem = ( 'Like', 'RunPlugin({0})'.format(pathaddlike), ) ctxlist.append(citem) xitem.add_context_menu_items(items=ctxlist, replace_items=False) except Exception as ex: outmsg = "Error: {0}\n{1}\n{2}\n".format(str(ex), str(ex.message), str(ex.args)) plugin.notify(msg=outmsg, delay=10000) print outmsg return xitem