XBMC-JSON an open source .NET XBMC JSON-RPC Library

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Thumbs Up  XBMC-JSON an open source .NET XBMC JSON-RPC Library
Post: #1
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.

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
(This post was last modified: 2011-01-10 00:00 by dstruktiv.)
find quote
Tolriq Offline
Donor
Posts: 2,186
Joined: Jun 2009
Reputation: 67
Location: France
Post: #2
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.

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Post: #3
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();
        }
    }
}

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
find quote
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Post: #4
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();
        }
    }
}

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
find quote
Johnsel Offline
KinEmote Co-Founder
Posts: 77
Joined: Oct 2009
Reputation: 10
Location: Maastricht, Netherlands
Post: #5
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
find quote
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Post: #6
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...

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
find quote
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Post: #7
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: 1280184077-xbmcremote4.png]

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
find quote
topfs2 Offline
Team-XBMC Developer
Posts: 3,962
Joined: Dec 2007
Reputation: 9
Post: #8
Awesome, plain awesome!.

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

Keep up the good work!

Cheers,
Tobias

If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
find quote
dstruktiv Offline
Member
Posts: 66
Joined: Jul 2010
Reputation: 0
Location: New Zealand
Post: #9
Thanks topfs2 we've spent heaps of time getting the lib up to scratch Smile

Latest screenshot of remote:

[Image: 1280265482-xbmcremote5.png]

XBMC Remote7 an XBMC library browser/remote for Windows Phone 7.
Xbmc-Json a .NET XBMC JSON API Library.
Xbmc-Remote-Control a .NET based XBMC library browser and remote for Windows, Linux and OS X.
find quote
jitterjames Offline
VoxCommando Founder
Posts: 297
Joined: Aug 2008
Reputation: 0
Location: canada
Post: #10
this is really excellent. It is going to make my life so much easier. Thanks for creating this! Keep up the good work.
find quote
dora Offline
Junior Member
Posts: 31
Joined: Sep 2010
Reputation: 0
Post: #11
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?
find quote
Johnsel Offline
KinEmote Co-Founder
Posts: 77
Joined: Oct 2009
Reputation: 10
Location: Maastricht, Netherlands
Post: #12
If anyone's interested, i'm currently rewriting the library to work entirely asynchronous. Hope to get it done in a couple of days.
find quote
MigaXBMC Offline
Junior Member
Posts: 1
Joined: Dec 2010
Reputation: 0
Post: #13
Many heartfelt thanks guys.. With all the time and effort you put into these developments, I can't say thank you enough.

Cheers!
find quote
bartdesign Offline
Member
Posts: 75
Joined: Jun 2008
Reputation: 0
Location: Netherlands
Post: #14
Keep up the good work, i'm using it in some of my home automation projects Wink
find quote
bartdesign Offline
Member
Posts: 75
Joined: Jun 2008
Reputation: 0
Location: Netherlands
Post: #15
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"])
       {
find quote
Post Reply