Reuse the YouTube add-on functionality
#1
I'm developing an XBMC add-on for a website that's basically a collection of YouTube-embedded videos arranged in a certain way. So each clip on the website is actually a YouTube video.

I wouldn't like to reinvent the wheel and recreate the code for sniffing the direct stream URL for a given YouTube video. Ideally, I'd rather reuse the functionality that's already in the YouTube add-on, namely the YouTubePlayer.buildVideoObject() method.

So is there a way for me to use those YouTube add-on's methods in my own add-on? I tried copying over YouTubePlayer.as but I'm getting a bunch of errors of the type

Code:
File "addon.py", line 14, in index
    ( video, status ) = player.YouTubePlayer().buildVideoObject(params)
File "YouTubePlayer.py", line 60, in __init__
    self.xbmcgui = sys.modules["__main__"].xbmcgui
AttributeError: 'module' object has no attribute 'xbmcgui'

Any hints please?
Reply
#2
dont copy anything. depend on plugin.video.youtube, then set resolved url to plugin://plugin.video.youtube?action=play_video&video_id=<id>
Reply
#3
Excellent, thank you very much!
Reply
#4
spiff's suggestions is of course the better solution for your problem.

But regarding the exception you see: The Youtube add-on uses an uncommon way to reuse objects from parent modules in child modules. If you really need to import something from the youtube add-on your main add-on file needs to have all xbmc related modules imported before the import of youtube modules.

@spiff:
(2013-08-12, 18:26)spiff Wrote: ...depend on plugin.video.youtube...

If you call any plugin URL which points to a known (in installed repo) but not already installed plugin you will get asked to install the add-on. So I would guess the depend statement is not needed, am I wrong?
My GitHub. My Add-ons:
Image
Reply
#5
i forgot that was added to cover up missing depends :-)
Reply
#6
Is there a way to show a playlist? For example https://www.youtube.com/playlist?list=PL...sA5ZWz9fL_
Reply
#7
(2013-08-28, 14:03)nightflyer Wrote: Is there a way to show a playlist? For example https://www.youtube.com/playlist?list=PL...sA5ZWz9fL_

Yes.

Every view you can see in any plugin can be called by any other add-on - that's how the XBMC Plugin API works.

Enable debug log in XBMC and open the desired view in the youtube add-on - you should be able to see the XBMC Plugin URL which was used for that view.
My GitHub. My Add-ons:
Image
Reply

Logout Mark Read Team Forum Stats Members Help
Reuse the YouTube add-on functionality0