Dvblink Remote API

DVBLink Remote API clients and tools

Dvblink Remote API

Postby DSD » Wed Apr 11, 2012 1:01 pm

Hello,

My goal is to develop an add-on for XBMC from which I can watch Live TV through DVBLink, very much like the Boxee app.
But my knowledge of developing XBMC add-ons are very limited so I'm not quite sure how far I will get...

In order to get this working I first have to familiarize myself with the DvbLink Remote API.
Since I'm a C# developer my first step is to the get the API working in familiar surroundings, so I started with a sample application in C# which use the Dvblink Remote Api...

But I've not been able to connect to my Dvblink server, it returns error 401 - permission denied.
I've included the sample code which I use, perhaps you can spot if I'm doing something wrong when calling the API.

The documentation for the Dvblink Remote API has version 0.1, are there any plans to update this documentation with some more info?

Start of sample code

private string GetResponse(string url)
{
// Create request for the web stream
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

string username = "user";
string password = "test";
string usernamePassword = username + ":" + password;

req.ContentType = "application/x-www-form-urlencoded";

CredentialCache mycache = new CredentialCache();
mycache.Add(new Uri(url), "Basic", new NetworkCredential(username, password));
req.Credentials = mycache;
req.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes(usernamePassword)));

// Return request in a response stream
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);

return sr.ReadToEnd();
}

private void button1_Click(object sender, EventArgs e)
{

string url = "http://htpc:8080/cs/command=get_channels";

string result = GetResponse(url);

textBox1.Text = result;
}

End of sample code

Regards

/Mattias
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am


Re: Dvblink Remote API

Postby Oberon » Wed Apr 11, 2012 3:18 pm

I think the issue in your case is that you use GET request instead of POST.
In any case I suggest that you have a look at our just published C# library that works with DVBLink Remote API:
viewtopic.php?f=61&t=18012

And as for XBMC client development - I find it really wonderful idea! We have also python library that works with DVBLink Remote API, which we also going to publish soon. It will provide you with the kick-start experience for XBMC plugin development. Moreover, should you decide to make the project open-source we will gladly participate (to certain extent) in development.
Oberon
 
Posts: 11763
Joined: Thu Sep 06, 2007 5:04 am

Re: Dvblink Remote API

Postby DSD » Wed Apr 11, 2012 4:32 pm

thank you for the C# sample project.
Unfortunately when using your sample project I still get error 401 - Unauthorized when trying to call get_channels.
When I use the same credentials via my web browser it works just fine.

Do you have any suggestion as to what may be causing this behavior?

Here's the code I'm using when calling your sample code:
The form in this case has implemented the interface IDataProvider.

DataProvider prov = new DataProvider("192.168.0.193", 8080, "user", "test", this);
ChannelsRequest result = new ChannelsRequest();
prov.GetChannels(result);
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby Realman » Wed Apr 11, 2012 6:31 pm

Set log level to Info and attach dvblink_server.log, dvblink_webserver.log
Realman
 
Posts: 805
Joined: Fri Mar 07, 2008 7:57 am

Re: Dvblink Remote API

Postby DSD » Wed Apr 11, 2012 9:05 pm

Here's the data from dvblink_webserver.log after I the log level was changed to Info and extended info and I tried to call the API get_channels.
But from what I can tell the log level does not produce any new data when changed.

[11/Apr/2012:21:42:18] DVB.CONNECT!.CNG Get the list of channels.
[11/Apr/2012:21:42:19] DVB.CONNECT!.CNG List len 119.
[11/Apr/2012:21:42:19] DVB.CONNECT!.CNG Get the current program.
[11/Apr/2012:21:44:00] DVB.CMN.SS Get server settings.
[11/Apr/2012:21:44:51] DVB.CMN.SS Save server settings. ({'ll': u'2', 'sp': u'3', 'bsp': u'8080', 'ssoe': u'1', 'un': u'user', 'bp': u'39876', 'cp': u'0', 'psswd': u'****'},)
[11/Apr/2012:21:44:51] DVB.CMN.SS Get server settings.

The other logfile, dvblink_server.log did not contain any new information, but the last rows are below:

2012-Apr-10 21:48:43: [E] Could not open mutex. GLE = 0
2012-Apr-10 21:48:43: [E] mc_recorder_t::command_processing. Error processing a DvbLink_RecorderGetChannels
2012-Apr-11 17:07:03: [E] Could not open mutex. GLE = 0
2012-Apr-11 17:07:03: [E] mc_recorder_t::command_processing. Error processing a DvbLink_RecorderGetChannels
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby Oberon » Thu Apr 12, 2012 11:25 am

DSD wrote:Here's the data from dvblink_webserver.log after I the log level was changed to Info and extended info and I tried to call the API get_channels.
But from what I can tell the log level does not produce any new data when changed.

[11/Apr/2012:21:42:18] DVB.CONNECT!.CNG Get the list of channels.
[11/Apr/2012:21:42:19] DVB.CONNECT!.CNG List len 119.
[11/Apr/2012:21:42:19] DVB.CONNECT!.CNG Get the current program.
[11/Apr/2012:21:44:00] DVB.CMN.SS Get server settings.
[11/Apr/2012:21:44:51] DVB.CMN.SS Save server settings. ({'ll': u'2', 'sp': u'3', 'bsp': u'8080', 'ssoe': u'1', 'un': u'user', 'bp': u'39876', 'cp': u'0', 'psswd': u'****'},)
[11/Apr/2012:21:44:51] DVB.CMN.SS Get server settings.

The other logfile, dvblink_server.log did not contain any new information, but the last rows are below:

2012-Apr-10 21:48:43: [E] Could not open mutex. GLE = 0
2012-Apr-10 21:48:43: [E] mc_recorder_t::command_processing. Error processing a DvbLink_RecorderGetChannels
2012-Apr-11 17:07:03: [E] Could not open mutex. GLE = 0
2012-Apr-11 17:07:03: [E] mc_recorder_t::command_processing. Error processing a DvbLink_RecorderGetChannels

Looks like you do not have any DVBLink default recorder set. That's why you get empty channel list.
Oberon
 
Posts: 11763
Joined: Thu Sep 06, 2007 5:04 am

Re: Dvblink Remote API

Postby DSD » Thu Apr 12, 2012 3:58 pm

Thank you for the suggestion but I've just tried that and it returns the same error "STATUS_UNAUTHORISED".
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby Realman » Thu Apr 12, 2012 6:07 pm

Please zipped logs and attach here.
Realman
 
Posts: 805
Joined: Fri Mar 07, 2008 7:57 am

Re: Dvblink Remote API

Postby DSD » Thu Apr 12, 2012 6:20 pm

I've attached the two logfiles, but I cannot find anything strange in them.
Also I've changed the log level to info before I tried to call get_channels.
Attachments
Logfiles.zip
(14.15 KiB) Downloaded 811 times
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby DSD » Fri Apr 13, 2012 8:20 pm

This is very strange, I found some info in your forum how to retrieve a list of all the channels in M3U-format.
http://dvblogic.com/phpBB3/viewtopic.php?f=61&t=18013

This works, but calling the get_channels API does not.
Perhaps I'm doing something wrong here...
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby Oberon » Fri Apr 13, 2012 8:29 pm

DSD wrote:This is very strange, I found some info in your forum how to retrieve a list of all the channels in M3U-format.
viewtopic.php?f=61&t=18013

This works, but calling the get_channels API does not.
Perhaps I'm doing something wrong here...

The thing is that this call does not require authentication via headers - user/password are part of url - and that's why it works.
Apparently for .net code you need to create an authorization header yourself as standard mechanism does not work for one or another reason. You need to add something like this:
Code: Select all
web_client_.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes("user:admin")));

We have received your code and we will fix library soon. Please hold on for some time as it also has a de-serialization bug (it works in silverlight, but does not wok using .net).
Oberon
 
Posts: 11763
Joined: Thu Sep 06, 2007 5:04 am

Re: Dvblink Remote API

Postby DSD » Mon Apr 16, 2012 6:31 am

I've actually gotten my XBMC add-on to work against my Dvblink Connect Server.
I'm using the api through python and it works. Although I'm currently using the get_playlist_m3u api.
Is the api get_playlist_m3u also available in xml format?

When my xbmc add-on is a bit more polished I will publish it here.
The functionality is somewhat basic with a list of channels and selecting one will automatically stream that channel.
I've not looked at the EPG yet.
DSD
 
Posts: 188
Joined: Sun Jul 19, 2009 7:29 am

Re: Dvblink Remote API

Postby Realman » Mon Apr 16, 2012 11:11 am

DSD wrote:Is the api get_playlist_m3u also available in xml format?

No, only m3u format.
Realman
 
Posts: 805
Joined: Fri Mar 07, 2008 7:57 am

Re: Dvblink Remote API

Postby azebro » Wed Oct 31, 2012 11:04 pm

Hello,

I'm trying to retrieve the list of recordings using the remote API.
I invoke the get_recordings function, but can receive only active recordings. Is that correct?
Tried to access the get_object, but stuck on the DVBLInk Server container, as no children are retrieved.
Please help...

Thanks,
Adam
azebro
 
Posts: 16
Joined: Fri Sep 25, 2009 2:36 pm

Re: Dvblink Remote API

Postby ralphFFM » Mon Jul 29, 2013 7:29 pm

Did anyone ever figure this out?

I too am coding in .NET and am having the same Problem.
Connecting with the remote API returns status code 401. I am setting the request header Authorization
to Basic and am supplying the User:Password.

Example:
web_client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new ASCIIEncoding().GetBytes("user:admin")));

or

string credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("user:admin"));
web_client.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", credentials);
ralphFFM
 
Posts: 19
Joined: Sat Jul 27, 2013 12:53 pm

Next

Return to Development corner

Who is online

Users browsing this forum: No registered users and 1 guest