• 1
  • 9
  • 10
  • 11(current)
  • 12
  • 13
  • 15
Your 1st Add-On: Hello World!
@zag. I tried to run the following code instead of default code helloword code and keep getting error:

Code:
import sys
import xbmcgui
import xbmcplugin

addon_handle = int(sys.argv[1])

xbmcplugin.setContent(addon_handle, 'movies')

url = 'http://someremotewebsite/some_video.mp4'
li = xbmcgui.ListItem('My First Video!', iconImage='DefaultVideo.png')
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)

xbmcplugin.endOfDirectory(addon_handle)

and this error i get:
Code:
Error:Script failed!:Hello World

xbmc.log details:

Code:
ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.IndexError'>
                                            Error Contents: list index out of range
                                            Traceback (most recent call last):
                                              File "C:\......\addons\script.hello.world-master\addon.py", line 5, in <module>
                                                addon_handle = int(sys.argv[1])
                                            IndexError: list index out of range
                                            -->End of Python script error report<--

could you help me fix this error ? Furthermore,I want to edit this hello word add on so it become a video add on . Currently it opens the app from program section with error . How to install the addon to video section instead?
Reply
2 david14

Addons (in general) do not have handles assigned to them. Only content plugins do.
Reply
@Roman_V_M so how to make that code work ?
Reply
@david14

You need to configure this as a plugin. You do this in the addon.xml file. Then when you open the addon it'll pass the right variables for sys.argv.
Reply
bumping this:

(2015-11-05, 16:26)HAK25 Wrote: Hello,

Im new to scripting in kodi, so i appreciate any help you can give me.

ok so i have installed an addon to kodi and im now editing it. i made a settings.xml in the resource folder and ive made 2 text boxes.

now what i want to do is pass a system command with the 2 strings as parameters.

my question is how can i pass these 2 strings as parameters in my python script?

i appreciate any help anyone can give me

Thank You
Reply
Something like plugin:\\script.myscript?param=$info[container.whatever getsthetext] probably.
Try asking in a separate thread?
Try getting a single harscoded value passed.
Look in other addons default.py for inspiration. Most of them pass values.
Good luck :-)
Reply
hi,

i installed script.hello.world on kodi, however i cannot locate the file script within the kodi directory in order to edit the addon.py. can someone please direct me to the addon location?

Thanks,

Eliran
Reply
(2016-01-06, 22:00)ekikos Wrote: hi,

i installed script.hello.world on kodi, however i cannot locate the file script within the kodi directory in order to edit the addon.py. can someone please direct me to the addon location?

Thanks,

Eliran

It depends what platform you are running on. If its windows it will be in userdata folder.

See here for different platforms

http://kodi.wiki/view/Userdata
Reply
Hi Zag,
Thank you for the post.

I have a general question - Why is the programming language for addons Python?

Can I program in other languages?


Thanks,
Tal
Reply
Python is the only language that the software supports for Add-ons at the moment.
Reply
Hello all,

Im trying to write a very simple addon that pops up a dialog box and displays my real-world IP address.

I tried a very simple....



import xbmcaddon
import xbmcgui
import os

addon = xbmcaddon.Addon()
addonname = addon.getAddonInfo('name')

line1 = os.system("curl ipv4.icanhazip.com")

xbmcgui.Dialog().ok(addonname, line1)




Debug shows... TypeError: argument "line1" for method "ok" must be unicode or str

Can anyone point me in the right direction?
Reply
Pointing in the right direction: get familiar with Python by reading up on it at Python.org. Google for "Python doc", or " Python os.system", and Python types. Kodi uses Python 2.7, but Python has a version 3.5 which is different. Stay in the 2.7 part.

In your case the Python doc on os.system says that call returns the process exit code, which is a number. The xmbc dialog wants a string. If you convert the number to a string, say with repr(), it will still be a string of numbers, probably just "0". Not the results of your curl command.

The doc also has a hint about using the module "subprocess". Read up on that! Especially subprocess.check_output.
Reply
I am trying to scrap youtube channel feeds https://www.youtube.com/feeds/videos.xml...=ANY-CH_ID
Tried following but its not getting any results. Any help please

match=re.compile(':title>(.+?)<.*?com/v/(.+?)?v.*?nail url="(.+?)"').findall(link)
use +/- ⇓⇓⇓⇓⇓⇓⇓
Reply
Hi,

Will you be able to provide a sample for playing a you tube video?
Consider this is a YouTube Hello World Smile

Thanks,
Wasanka
Reply
(2016-03-28, 15:55)wasanka2000 Wrote: Hi,

Will you be able to provide a sample for playing a you tube video?
Consider this is a YouTube Hello World Smile

Thanks,
Wasanka

http://forum.kodi.tv/showthread.php?tid=254207
Reply
  • 1
  • 9
  • 10
  • 11(current)
  • 12
  • 13
  • 15

Logout Mark Read Team Forum Stats Members Help
Your 1st Add-On: Hello World!5