KSharp - Write Kodi Addon with Csharp
#1
Hi, (sorry for my english, im french)  Ksharp is a library to develop kodi add-ons in C#, Python Call CSharp application console with subprocess.Popen, C# listen standard input for Python event and reply to Function writen in standard output.

Version 1.00: not all tested, please test and send your report to [email protected]

 
Code:
---> [url=https://github.com/CRialDev/KSHarp]https://github.com/CRialDev/KSHarp [/url]Tested in LibreElec whith Kodi 17.
[code]- Implemented :
[list]
[*]xbmcplugin.*
[*]xbmc.InfoTagMusic
[*]xbmc.InfoTagVideo
[*]xbmc.Keyboard // Tested on Krypton
[*]xbmc.Monitor // Tested on Krypton
[*]xbmc.PlayList
[*]xbmcgui.Action
[*]xbmcgui.ControlButton // Tested on Krypton
[*]xbmcgui.ControlEdit // Tested on Krypton
[*]xbmcgui.ControlFadeLabel // Tested on Krypton
[*]xbmcgui.ControlImage // Tested on Krypton
[*]xbmcgui.ControlLabel // Tested on Krypton
[*]xbmcgui.ControlList
[*]xbmcgui.ControlSlider
[*]xbmcgui.ControlSpin
[*]xbmcgui.ControlTextBox
[*]xbmcgui.Dialog
[*]xbmcgui.DialogProgress
[*]xbmcgui.DialogProgressBG
[*]xbmcgui.ListItem
[*]xbmcgui.Window // Tested on Krypton
[*]xbmcgui.WindowDialog // Tested on Krypton
[*]xbmcgui.WindowXML // Tested on Krypton
[*]xbmcgui.WindowXMLDialog // Tested on Krypton
[*]xbmcaddon.Addon // Tested on Krypton
[*]xbmcvfs.File
[*]Added VideoLibrary Class
[/list]
[/code]
Reply
#2
For a Simple example.
  • Copy addon.py file placed in the example folder to your addon folder.
  • Compile your csharp code and place this to your addon folder.
  • Replace Csharp application name by your application name:
    cs:
    args.append(xbmcaddon.Addon().getAddonInfo('path')+'/addon.exe')
  • Run your addon !

Simple CSharp Addon :
cs:
   
class Program
    {
        static void Main(string args)
        {
            SimpleAddon myAddon = new SimpleAddon();
        }
    }
    public class SimpleAddon : KSharp
    {
        Addon addon;
        public SimpleAddon():base()
        {
            addon = new Addon();
            if(Dialog.Ok(addon.getAddonInfo("name"),addon.getAddonInfo("path"),"Click ok to show notification"))
            {
                Dialog.Notification(addon.getAddonInfo("name"), "Clicked Ok");
            }
            Stop();
        }
    }

Reply
#3
Interesting, but why do we need this? Except maybe for some poor souls who know C# and do not want to learn Python.
Reply
#4
Exactly, before writing this code I did not know python, this code can be used just for the c # developer, or to code an addon from a c # code without having to translate everything into python, this code also aims to be able to use all the mono libraries in an addon
Reply
#5
nice work, i have some comments that you migh be interested in,

1) stdout encoding is depensant on the os localization afaik, you have not defined any encoding on stdout parsing, maybe simple base64 encoding would be helpfull.
2) kodi spawns a cpython thread everytime addon is called, calling an executable also in addon call would also another delay and lag each time, so performance would be an issue on the long run.
3) portability of c# code is always an issue, thats why only pythonic libraries exists (except standart python libs like ssl etc..) on kodi distros. But i think you already started the project having this on mind.
Reply
#6
Thank you boogiepop, I will study your remarks, especially the stdin stdout encoding.
Reply

Logout Mark Read Team Forum Stats Members Help
KSharp - Write Kodi Addon with Csharp0