Can we modify a Directory item URL (plugin)?
#1
Hi,

In order to optimize a plugin, I was thinking to retrieve the directory Item video in a separate thread. The problem is in the plugin API we have the addDirectoryItem function, but I didn't find a wait to modify the URL once an ListItem has been added.

Is it possible?

Also it is not clear to me what is the role of the setResolvedUrl() functionm could someone explain that to me?

Thank you in advance.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#2
Reading at this thread: http://forum.xbmc.org/showthread.php?tid=79189
I think I found the solution (please correct me if I am mistaken):

if I do:
Code:
myLisItem.setPath(path=url)

That should modify the URL, am I correct?

Concerning the setResolvedUrl() I have seen some example of code, but I am still not sure how to use it and most importantly why.

Thanks.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#3
Yes, the above will alter the path.

setResolvedURL is used ONLY for returning the playback URL once XBMC has re-run your plugin to resolve a URL prior to playback.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#4
jmarshall Wrote:Yes, the above will alter the path.
Thanks for the info Jonathan, that will be very helpful

jmarshall Wrote:setResolvedURL is used ONLY for returning the playback URL once XBMC has re-run your plugin to resolve a URL prior to playback.

Cheers,
Jonathan
I am probably dumb here, but could you give me an example of a scenario?
If i understand, you are talking about the case:
- I have a list of video
- I click on one and the video start to play
- once done, the plugin is reload in order to provide the same list of videos.
Correct? I am not sure why we would need the playback URL in this case.
What would be the difference with a standard AddDirectoryItem()?

I am probably missing something.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#5
Nope. It's this scenario:

1. You give us a list of videos, but the URLs of those videos need to be resolved directly before playback, not on listing (eg they use a URL which times out after a while, or some cookie, or require quite a lot of processing to determine the real URL).

2. Thus, you instead provide the URL of the video as a link back to your plugin (with isFolder set to false).

3. When the user clicks on a file XBMC calls your plugin.

4. Your plugin then figures out the real URL of the video and calls setResolvedUrl().

5. XBMC plays the real URL.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#6
jmarshall Wrote:Nope. It's this scenario:

1. You give us a list of videos, but the URLs of those videos need to be resolved directly before playback, not on listing (eg they use a URL which times out after a while, or some cookie, or require quite a lot of processing to determine the real URL).

2. Thus, you instead provide the URL of the video as a link back to your plugin (with isFolder set to false).

3. When the user clicks on a file XBMC calls your plugin.

4. Your plugin then figures out the real URL of the video and calls setResolvedUrl().

5. XBMC plays the real URL.

Cheers,
Jonathan

Nice, thank you fir the explanation. When I was trying to do something similar I was usually ending by calling myself the player, I didn't know the plugin could support that.
I am more a script guy, but since I don't have too much time anymore, I am trying to do plugins: faster to implement but also more constraint, unless you know it well, I still have a lot to learn on plugin programming.
Anyways, thank you that will be useful.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#7
I tried to modify a list item in a separate thread but my changes are not taken in account in the list (in the plugin).

In the main thread i do something like:
PHP Code:
import threading
from Queue import Queue
, Empty

global 
q_in
q_in 
Queue(0)

# Create a ListItem
item=xbmcgui.ListItem(label=video["title"],label2=video["publication_date"],
                                  
iconImage=video['image.url'],
                                  
thumbnailImage=video['image.url'])

# Add it to the queue with extra info
q_in.put( (itemvideo["videoID"]) )                        

# Add ListItem to the plugin list with fake URL
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                                    
url="fakeURL",
                                                    
listitem=item,
                                                    
isFolder=False)

# Start the thread where the URL will be resolved
threading.Thread(target getinfos)
t.start() 

Now the code of the thread
PHP Code:
def getinfos():
    global 
q_in
    
try:
        
item videoID q_in.get_nowait()

        print 
"** Thread"
        
# Get info we need
        
infos retrieve_info(videoID)
        
url=infos["goodurl"]
        
item.setPath(url)

    
except Empty:
        
pass 


I know there is other way to do that for instance with setResolvedURL(), but I am trying to understand why the change I made (in a separate thread) to the list item added to the list in the plugin are not taken in account.

Any ideas? Is it possible or not?
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#8
Reason is the item is copied when you addDirectoryItem, thus when you update your copy it doesn't change the one that was added. Nothing you can do about that.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#9
jmarshall Wrote:Reason is the item is copied when you addDirectoryItem, thus when you update your copy it doesn't change the one that was added. Nothing you can do about that.

I was afraid of that, also I was wondering is it could be the context of the thread.
Anyways, good to know, thanks again.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#10
don't you need to refresh container?
Reply
#11
ppic Wrote:don't you need to refresh container?
Yes, it crossed my mine, but since the the ListItem are passed by copy to the addDirectortItem and not by reference, that won't work.
I was trying something like that since I did it in a script, but the pkugin does not allows as much a script does, still good to know how it works.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#12
Another quick question (I know againHuh Big Grin) about jmarshall explanation on setResolvedUrl():

jmarshall Wrote:Nope. It's this scenario:

1. You give us a list of videos, but the URLs of those videos need to be resolved directly before playback, not on listing (eg they use a URL which times out after a while, or some cookie, or require quite a lot of processing to determine the real URL).

2. Thus, you instead provide the URL of the video as a link back to your plugin (with isFolder set to false).

3. When the user clicks on a file XBMC calls your plugin.

4. Your plugin then figures out the real URL of the video and calls setResolvedUrl().

5. XBMC plays the real URL.

Cheers,
Jonathan


In your example we are talking about video, it would be very similar with music or picture, we would have XBMC player player the media.

But in case of a program what would happen?

Does it makes sense to use setResolvedUrl()?

It makes sense to set the isFolder to false and call the plugin in order to process what we want, but in which case (for a program plugin) it would make sens to use setResolvedUrl()?

I am asking since I am currently working on a program plugin anf I have this type of scenario.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
#13
setResolvedUrl() likely won't do anything at all for executable content.
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply

Logout Mark Read Team Forum Stats Members Help
Can we modify a Directory item URL (plugin)?0