My first script - Error
#1
Hi,

I'm new at python development (but have other dev experience) and am currently trying to create a very basic script to experiment with Kodi development. Using Openelec (Kodi v14), on Raspberry Pi.

Script file:
Code:
import kodi
kodi.executebuiltin("RunPlugin(plugin://plugin.video.youtube)")

Error:
Code:
AttributeError: 'module' object has no attribute 'executebuiltin'

I run the script by navigating to the directory in Putty and use the following command:
Code:
python script.py

If I run the script using the following command, I don't get any errors, but nothing is happening...
Code:
kodi-send -a "RunScript(script.py)"

I did a lot of googling but cannot figure out why this is not working. All documentation seems to be saying it should basically work.

What am I doing wrong? Huh

Btw: I upload my file to /storage/scripts and gave the .py-script 755 permissions in my FTP program (FileZilla).
Reply
#2
"import kodi" does not exist

"import xbmc" does
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
(2015-08-13, 22:32)Martijn Wrote: "import kodi" does not exist

"import xbmc" does

And I for one hope that doesn't change for a very, very, very long time. Wink
Reply
#4
(2015-08-13, 22:32)Martijn Wrote: "import kodi" does not exist

"import xbmc" does

Thanks for the reply! However, when I change that into import xbmc I get the following error: "ImportError: no module named xbmc".

Do I have to run the script from a specific location where the xbmc module can be found/imported?
Reply
#5
(2015-08-14, 04:30)pkscout Wrote:
(2015-08-13, 22:32)Martijn Wrote: "import kodi" does not exist

"import xbmc" does

And I for one hope that doesn't change for a very, very, very long time. Wink

Well it might change but will for sure be backwards compatible.

(2015-08-14, 10:04)longshanks17 Wrote:
(2015-08-13, 22:32)Martijn Wrote: "import kodi" does not exist

"import xbmc" does

Thanks for the reply! However, when I change that into import xbmc I get the following error: "ImportError: no module named xbmc".

Do I have to run the script from a specific location where the xbmc module can be found/imported?

you can only use it from within Kodi itself. No through outside editors.
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#6
Bit of an aside, but it's curious that the "import kodi" line isn't raising an ImportError. Presumably there's also a kodi.py file in the same folder.

It would probably help if we understood what you were trying to achieve i.e. it's perfectly possible to control Kodi with a script run outside of Kodi itself (e.g. using the JSON-RPC interface).
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply
#7
Ok I see.

If you say "only from within kodi itself", how whould I do that? Does it mean through the GUI?

I imagine when you develop an add-on you could install it on your kodi machine but in my case it's just one script file, not a real add-on, so not sure how to "trigger" that from within Kodi itself.

EDIT: What I want to achieve is calling a plugin and passing some parameters along, something like:

xbmc.executebuiltin('RunPlugin(plugin://plugin.video.youtube/?action=play_video&videoid=<VIDEO-ID>)')
Reply

Logout Mark Read Team Forum Stats Members Help
My first script - Error0