Kodi Community Forum

Full Version: XBMC-JSON an open source .NET XBMC JSON-RPC Library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
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.
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.
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();
        }
    }
}
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();
        }
    }
}
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
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...
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
Awesome, plain awesome!.

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

Keep up the good work!

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

Latest screenshot of remote:

Image
this is really excellent. It is going to make my life so much easier. Thanks for creating this! Keep up the good work.
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?
If anyone's interested, i'm currently rewriting the library to work entirely asynchronous. Hope to get it done in a couple of days.
Many heartfelt thanks guys.. With all the time and effort you put into these developments, I can't say thank you enough.

Cheers!
Keep up the good work, i'm using it in some of my home automation projects Wink
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"])
       {
Pages: 1 2 3 4