script.module.urlresolver development - Printable Version
+- Kodi Community Forum (http://forum.kodi.tv)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Add-ons (/forumdisplay.php?fid=26)
+--- Thread: script.module.urlresolver development (/showthread.php?tid=105707)
- t0mm0 - 2011-09-01 20:55
this url works for me... maybe there was a problem with the site at the time or something?
- t0mm0 - 2011-09-01 21:12
DragonWin Wrote:Hi t0mm0
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 - 2011-09-01 21:31
DragonWin Wrote:MyContextObject = create_contextmenu(menuname, scriptargs, mode=True/False, [contextobject]):
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?
(i am probably missing something with this a i haven't really played with xbmc context menus before )
- DragonWin - 2011-09-02 08:01
t0mm0 Wrote:this url works for me... maybe there was a problem with the site at the time or something?
hmm strange it still does not work for me. It works when I try it in my browser, but not when I put the link in the t0mm0 test addon.
Guess I'll have to try and look into it another time, I would like to get on with the contextmenu setup.
- DragonWin - 2011-09-02 08:03
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?
Hmm, I might have been confused about that then, as I were also looking at marshall, json and a few others to see what would give the most options.
Lets leave it in and see if any it there is an issue at all.
- DragonWin - 2011-09-02 08:30
t0mm0 Wrote:i'm not sure i understand the mode bit, or what XBMC.Container.Update() is for.
This function helps create the tuples, let me try and explain
It took me quite a bit of digging to figure this one out, let me see if I can explain myself better. The reason why I opted to put this function in, is because I found quite a few posts when searching on how to do this, from people with similar issue, but no resolution to there problem. With this function they don't need to know about RunPlugin or Container.Update, they just need to know, do I present a new list of items or not (True/False).
mode should properly be called newlist=True/False
Lets say that I want to add 2 context menu's to some movies. The first menu option is "Go to startup screen" which presents the catagories (mode=main), and the second menu option is "Add to favorites", which stays on the same screen (same dir) but just saves the url.
If I used this on both
If I used this on both
So the user would create there menu items and receive the contextmenu obj, which would then be passed to add_item, add_video_item, add_music_item, for each item the menu should be on, and they would have there menu up and running.
It was purely thought of as a way for the addon coder to have an easy way to add/del favorites, and also a fast way to jump to favorites. If they want to do more elaborate stuff they would have to mix in there own tuples and pass that to add_item etc.
t0mm0 Wrote:(i am probably missing something with this a i haven't really played with xbmc context menus before )
Hehe as I said took me quite a bit of digging around, and I made my post early in the morning before work, I might not have been fully awake ;-)
I hope this explanation is a bit better, sorry if my first post were a bit confusing
- DragonWin - 2011-09-02 09:45
I have been messing a bit around with it now, from the addon creators point of view, it would look some thing like this:
Create my 2 menu's and add them.
of cause in the 2nd arg you can always add more info like url to save, what to do on loading it again etc.
End result: Save Favorite hits mode=favorite, but stays on the current screen, and Go to Main screen resets the list, and shows the mode=main initial directory.
- t0mm0 - 2011-09-02 20:00
DragonWin Wrote:Hi t0mm0
ah yeah i think i understand what you mean now! sorry for being a bit slow
looks good to me so far - more building blocks for favourites....
- DragonWin - 2011-09-02 20:54
I have been busy today
I have been able to create the "add favorite", and also to show them, and play them. Only movie links so far, I have not tested directories yet. It still needs a lot of work, but it's starting to look like some thing.
As it's not possible to call a module function directly, the user has to create 3 modes in the addon: savefavorite, deletefavorite, showfavorites
So far when they want to add the "Add favorite" context they then call this. I'll explain the tuple more when I have decided on a structure, but callback 'play' means add_item, it could also be a mode that is to be called.
To display the favorites
I hope this can be a useful addition to common.addon, if nothing else shown a way Not to do it
I'll give it some more attention tomorrow, right now dinner is almost done ;-)
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.
- t0mm0 - 2011-09-02 22:39
DragonWin Wrote:Hey t0mm0,cool - looks like it's coming on nicely!
think i will get a chance to write some more code myself too this weekend.
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.
i'm happy to take a look when you're ready (but of course i may just make it worse )
- DragonWin - 2011-09-03 22:19
I need your help, I have been banging my head against this one for quite a few hours now. it seems to be related to functions and default values ... some how
I have been messing around with it a lot so the code is not tidy, right now I'm just trying to figure out what is going on, and how to fix it.
The objective is to allow the addon author to add his own menu items while also making use of the favorite
Pastebin link to snippet of the code used: http://pastebin.com/Dbi5j7GD
What happens is that the object "mymenuobj" defined at line 6 is modified during the for loop at line 16.
At line 19 it's passed to addon.add_item as contextmenuobj=mymenuobj, and I think this is where it goes wrong.
After that at line 51 it's passed to self.create_contextmenu()
which send it to line 75 where I append the new menu to the contextmenuobj, which is the returned in line 51.
The 2nd time round through this process I would have expected mymenuobj to contain my original from line 6, but instead it contains the original and the previous menu item resulting in, the 2nd item in the list suddenly have 2 x 'Add solarmovie favorite' menu, 3rd time I have 3 x 'Add solarmovie favorite' etc.
I read that by using a none modifiable value for the default value, this should not happen, but I have tried False, None, '' etc, and none of those works..
How can I get around this ?
- t0mm0 - 2011-09-03 22:43
DragonWin Wrote:I need your help
hmmm, from a quick glance i guess you are running into some unwanted side effects of this type of thing?
specifically the contextmenuobj.append() on lines 80 or 83 will alter the original object that was passed to create_contextmenu() and NOT a copy of it as you might expect.
so i think when you get to line 51 both contextmenuobj and newcontextmenuobj are actually references to the same object!
- DragonWin - 2011-09-03 23:35
Thanks that was just what I needed. The other explanations I had found did not explain it that clearly.
So guess it's time to clean up all the test code, and add 'Delete favorite' contextmenu, do more testing, write documentation
- DragonWin - 2011-09-04 12:59
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 )
It still needs more testing, but I think it's close to be ready.
- t0mm0 - 2011-09-04 13:46
DragonWin Wrote:Hey t0mm0,
this looks great! thanks for the video - you are really good at that
a couple of questions.....
i don't think there's any need to be passing sys.argv around - that is already available to methods in addon as self.queries already parsed and as a dictionary. (just noticed that's not documented - i should fix that!)
rather than passing the context menu object back into addon.create_context_Menu(), would it be better to make a ContextMenu class? then you could do something like:
would that also make it possible to make create_favorite() a method on the context menu object so everything was kept together?
what do you think?