Exemple #1
0
        public static void Add(IList <ListItem> items)
        {
            var    list     = PyVariableManager.NewVariable();
            string listCode = "[";

            for (int i = 0; i < items.Count; i++)
            {
                listCode += string.Format("({0},{1},{2})",
                                          PythonInterop.EscapeArgument(items[i].Url),
                                          items[i].Instance.PyName,
                                          items[i].IsFolder
                                          );
                if (i + 1 < items.Count)
                {
                    listCode += ",";
                }
            }
            listCode += "]";

            PyVariable listVar = PyVariableManager.NewVariable(flags: PyVariableFlags.Object);

            listVar.Value = listCode;

            PythonInterop.CallFunction(
                new PythonFunction(PyModule.XbmcPlugin, "addDirectoryItems"),
                new List <object> {
                KodiBridge.RunningAddon.Handle,
                listVar,
                items.Count
            }
                );
        }
Exemple #2
0
        public override int DefaultRoute()
        {
            TestPlugin addon = KodiBridge.RunningAddon as TestPlugin;

            //ConsoleHelper.CreateConsole();
            Console.WriteLine("TestPlugin v1.0 - Smx");

            using (var sum = PyVariableManager.NewVariable()) {
                sum.Value = "1+2";
                PyConsole.WriteLine("Result: " + sum);
            }

            //Console.WriteLine("Settings['test'] => " + addon.Settings["test"]);

            using (var dict = PyVariableManager.NewVariable()) {
                Dictionary <string, string> TestDict = new Dictionary <string, string> {
                    { "hello", "python" },
                    { "dict", "test" }
                };
                dict.Value = TestDict.ToPythonCode();
                PyConsole.WriteLine("Dict: " + dict);
            }

            PyConsole.WriteLine("Hello Python");

            //ConsoleHelper.FreeConsole();
            return(0);
        }
Exemple #3
0
        public KodiAddon(bool persist = false, bool debug = false)
        {
            DebugEnabled = debug;
            IsPersistent = persist;
            try {
                PyVariableManager = new PyVariableManager();

                // Parse parameters
                this.BaseUrl   = PythonInterop.EvalToResult("sys.argv[0]").Value;
                this.IsService = PythonInterop.EvalToResult("len(sys.argv) < 2").Value;

                this.Router = new RouteManager(this);
            } catch (Exception ex) {
                KodiBridge.SaveException(ex);
            }
        }
Exemple #4
0
 public InfoTagRadioRDS()
 {
     this.Instance = PyVariableManager.NewVariable(flags: PyVariableFlags.Object);
 }
Exemple #5
0
 public Player(PyVariable player)
 {
     PyVariableManager.CopyVariable(Instance, player);
 }