Kodi Community Forum
XBMC-JSON an open source .NET XBMC JSON-RPC Library - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: XBMC-JSON an open source .NET XBMC JSON-RPC Library (/showthread.php?tid=77733)

Pages: 1 2 3 4


XBMC-JSON an open source .NET XBMC JSON-RPC Library - dstruktiv - 2010-07-23

Hi All, just letting any interested devs know I've made a .Net library for interfacing with XBMC's JSON API.

Both Sync and Async projects are available although no one is currently maintaining the Sync project as this type of network I/O is far better suited to Asynchronous operations.

We currently have a few committers actively working on the project and it should be considered stable and ready for use.

Source and binaries available at http://code.google.com/p/xbmc-json/

If anyone would like to join the project let me know Smile

Cheers.


- Tolriq - 2010-07-23

Looks good Smile

You should perhaps, set a target c# version in VS to C# 2.0 so the code have more chance to be mono compatible (and so do not use default value parameters for example ).

And perhaps add a little more value, by removing the need to handle Json in the client, you library can do the work to move things to collection/lists and string, int , ... to remove all the tasks that all users of your lib will need to do Smile

Tolriq.


- dstruktiv - 2010-07-23

Tolriq Wrote:Looks good Smile

You should perhaps, set a target c# version in VS to C# 2.0 so the code have more chance to be mono compatible (and so do not use default value parameters for example ).

And perhaps add a little more value, by removing the need to handle Json in the client, you library can do the work to move things to collection/lists and string, int , ... to remove all the tasks that all users of your lib will need to do Smile

Tolriq.

Thanks Smile

I'll look at adding method overloads instead of optional parameters later I'm too lazy to type it all out at the moment and there's much funner stuff to work on Big Grin

Good idea about making the library handle the json... I started to update it... It does all the work now Smile

Code:
using System;
using System.Collections.Generic;
using XbmcJson;

namespace XBMCJsonTest
{
    class Program
    {
        static void Main(string[] args)
        {
            XbmcConnection xbmc = new XbmcConnection("192.168.1.200", 80, "xbmc", "");

            if (xbmc.Status.IsConnected)
            {
                foreach (TvShow e in xbmc.VideoLibrary.GetTvShows())
                {
                    Console.WriteLine(e.label);
                    Console.WriteLine(e.file);
                    Console.WriteLine(e.thumbnail);
                    Console.WriteLine(e.id);
                    Console.WriteLine();
                }
            }
            else
            {
                Console.WriteLine("Unable to connect to XBMC");
            }

            Console.ReadLine();
        }
    }
}



- dstruktiv - 2010-07-24

Added classes for each media type and updated all functions to return either generic types or instances of media classes. No more need to parse the JsonObjects in your own code Smile

Code:
using System;
using System.Collections.Generic;
using XbmcJson;

namespace xbmc_jsonTest
{
    class Program
    {
        static void Main(string[] args)
        {
            XbmcConnection xbmc = new XbmcConnection("127.0.0.1", 80, "xbmc", "password");

            if (xbmc.Status.IsConnected)
            {
                foreach (Movie m in xbmc.VideoLibrary.GetMovies(start: 1, end: 2))
                {
                    Console.WriteLine("id: " + m._id);
                    Console.WriteLine("file: " + m.File);
                    Console.WriteLine("label: " + m.Label);
                    Console.WriteLine("thumbnail: " + m.Thumbnail);
                    Console.WriteLine("director: " + m.Director);
                    Console.WriteLine("writer: " + m.Writer);
                    Console.WriteLine("studio: " + m.Studio);
                    Console.WriteLine("genre: " + m.Genre);
                    Console.WriteLine("year: " + m.Year);
                    Console.WriteLine("runtime: " + m.Runtime);
                    Console.WriteLine("rating: " + m.Rating);
                    Console.WriteLine("tagline: " + m.Tagline);
                    Console.WriteLine("plotoutline: " + m.PlotOutline);
                    Console.WriteLine("plot: " + m.Plot);
                }
            }
            else
            {
                Console.WriteLine("Unable to connect to XBMC");
            }

            Console.ReadLine();
        }
    }
}



- Johnsel - 2010-07-24

I've made a seperate branch that uses the Newtonsoft library too communicate; which has a .NET compact version so WinMo developers get some of the candy too Smile Still heavily under development though, just like the main branch.

enjoy Laugh


- dstruktiv - 2010-07-25

Just committed latest version which pretty much has all functions currently implemented in xbmc. Went through and removed .Net 4.0 optional parameters and added method overloads. Have changed .Net version to 3.5 so should hopefully be Mono compatible now if anyone wants to try...


- dstruktiv - 2010-07-27

First app making use of this lib going up - If anyones interested in contributing PM me:

http://code.google.com/p/xbmc-remote-control/

Image


- topfs2 - 2010-07-27

Awesome, plain awesome!.

Love to see how quick you guys are able to create stuff with jsonrpc.

Keep up the good work!

Cheers,
Tobias


- dstruktiv - 2010-07-27

Thanks topfs2 we've spent heaps of time getting the lib up to scratch Smile

Latest screenshot of remote:

Image


- jitterjames - 2010-10-02

this is really excellent. It is going to make my life so much easier. Thanks for creating this! Keep up the good work.


- dora - 2010-10-27

dstruktiv Wrote:If anyone would like to join the project let me know Smile

I implemented System.GetInfoLabels function.
Do you want me to send a patch?


- Johnsel - 2010-10-29

If anyone's interested, i'm currently rewriting the library to work entirely asynchronous. Hope to get it done in a couple of days.


- MigaXBMC - 2010-12-01

Many heartfelt thanks guys.. With all the time and effort you put into these developments, I can't say thank you enough.

Cheers!


- bartdesign - 2010-12-28

Keep up the good work, i'm using it in some of my home automation projects Wink


- bartdesign - 2011-01-01

Btw there is a bug in the GetRecentlyAddedEpisodes method:

Code:
if (query["movies"] != null)
{
       foreach (JObject item in (JArray)query["movies"])
       {

Change to

Code:
if (query["episodes"] != null)
{
       foreach (JObject item in (JArray)query["episodes"])
       {