2011-09-01, 20:55
DragonWin Wrote:[EDIT]
Forgot to include the url that does not work: http://embed.novamov.com/embed.php?width...3yvi5&px=1
[/EDIT]
this url works for me... maybe there was a problem with the site at the time or something?
DragonWin Wrote:[EDIT]
Forgot to include the url that does not work: http://embed.novamov.com/embed.php?width...3yvi5&px=1
[/EDIT]
DragonWin Wrote:Hi t0mm0
I just noticed that you change import pickle to cPickle. I omitted cPickle on purpose as there are some data type objects it can't handle (found it some where on the net can't remember what it is it can't handle) but pickle can.
Just thought I would mention it.
DragonWin Wrote:MyContextObject = create_contextmenu(menuname, scriptargs, mode=True/False, [contextobject]):
Where menuname, is what is displayed to the user on right click, scriptargs is the arguments passed to the plugin, mode indicates if the function that is hit creates a new listitem with add_dir, add_item ect, contextmenuitem object is an existing object. The object is a previously returned contextmenu, and only used if the user wants to add more menu items for that individual list item to be added using add_item add_video_item add_music_item (eg. Go to favories, Add item as favorite)
As far as I could make out using XBMC.Container.Update() forces it to clear the itemlist, and accept a new itemlist to be displayed (eg. Go to favorite menu item), or XBMC.RunPlugin() is used for eg. "add to favorites" as that would not generate a new itemlist. Which is why we need to know from the addon what type it is, hence the True/False in the create_contextmenu()
addContextMenuItems(...)
addContextMenuItems([(label, action,)*], replaceItems) -- Adds item(s) to the context menu for media lists.
items : list - [(label, action,)*] A list of tuples consisting of label and action pairs.
- label : string or unicode - item's label.
- action : string or unicode - any built-in function to perform.
replaceItems : [opt] bool - True=only your items will show/False=your items will be added to context menu(Default).
List of functions - http://wiki.xbmc.org/?title=List_of_Built_In_Functions
*Note, You can use the above as keywords for arguments and skip certain optional arguments.
Once you use a keyword, all following arguments require the keyword.
example:
- listitem.addContextMenuItems([('Theater Showtimes', 'XBMC.RunScript(special://home/scripts/showtimes/default.py,Iron Man)',)])
t0mm0 Wrote:this url works for me... maybe there was a problem with the site at the time or something?
t0mm0 Wrote:from what i can tell from the python docs the only difference is that you can't subclass Pickler and Unpickler (which we are not doing). cPickle is a lot faster, but i guess will only be available when using a system python in newer xbmc versions anyway? still if it is a problem i can change it back?
t0mm0
t0mm0 Wrote:i'm not sure i understand the mode bit, or what XBMC.Container.Update() is for.
from the docs for xbmcgui, a ListItem has a method addContextMenuItems() which already lets you add context menu items as a list of tuples. couldn't we just add an extra kwarg to the add_item() methods to pass that through to the ListItem? what does the above do that makes it easier?
contextmenuobj.append((menuname, u'XBMC.Container.Update(%s?%s)' %
(self.url, scriptargs)))
contextmenuobj.append((menuname, u'XBMC.RunPlugin(%s?%s)' %
(self.url, scriptargs)))
t0mm0 Wrote:(i am probably missing something with this a i haven't really played with xbmc context menus before )
mymenuobj = addon.create_contextmenu('Go to Main screen','mode=main',
newlist=True)
mymenuobj = addon.create_contextmenu('Save Favorite','mode=savefav',
newlist=False,
contextmenuobj=mymenuobj)
addon.add_video_item( url, { 'title' : title }, img=thumbnail,
contextmenuobj=mymenuobj)
DragonWin Wrote:Hi t0mm0
I have been messing a bit around with it now, from the addon creators point of view, it would look some thing like this:
elif mode == 'savefavorite':
test = addon.save_favorite(sys.argv[2])
if test is False:
addon.show_small_popup(msg='Unable to save favorite')
elif mode == 'deletefavorite':
#Yet to be created
pass
elif mode == 'showfavorites':
test = addon.show_favorites()
if test is False:
addon.show_small_popup(msg='No saved favorites to show')
favoritetuple = {'callback' : 'play', 'menuname' : 'Save solarmovie favorite',
'action' : 'savefavorite'}
add_video_item(addon.add_video_item( url, { 'title' : title }, img=thumbnail,
favorite=favoritetuple)
addon.add_directory({'mode' : 'showfavorites' }, 'Favorites')
DragonWin Wrote:Hey t0mm0,cool - looks like it's coming on nicely!
I have been busy today
DragonWin Wrote:Ps. I'm prob. going to need you to make the code more sturdy, and clean it up, like you did with the other commit, I hope you don't mind.
DragonWin Wrote:I need your help
def create_contextmenu(self, menuname, scriptargs,
newlist=False, contextmenuobj=None):
newobj = []
if contextmenuobj is None:
newobj = []
else:
for mytuple in contextmenuobj:
newobj.append(mytuple)
if newlist:
newobj.append((menuname, u'XBMC.Container.Update(%s?%s)' %
(self.url, scriptargs)))
else:
newobj.append((menuname, u'XBMC.RunPlugin(%s?%s)' %
(self.url, scriptargs)))
return newobj
DragonWin Wrote:Hey t0mm0,
Thanks for the help yesterday, I have been playing around with it a bit more, and I think I have some thing that could be useful.
instead of trying to explain it all I decided to do a quick movie (this is a one take, so it's not refined or any thing, and I seem to mumble at some places )
favorites demo
It still needs more testing, but I think it's close to be ready.
cm=ContextMenu()
cm.add(title, query, new_list)