2011-02-26, 08:56
Update: There might be a better solution - I just found this AFTER writing this script tonight. Just for correctness, please check this thing first: http://forum.xbmc.org/showthread.php?tid=77500
Hi,
I did not find a way to pass cookies and other HTTP headers to XBMC for video playback, so I wrote a small python script that can be installed as an XBMC service. It works a bit like a proxy server (remember VeohProxy?) and allows you to specify:
- the URL to download and
- the HTTP headers to send with each request XBMC makes to that URL
It will just pass through the request headers that XBMC sends to the local webserver and add the ones you specified. It will then send back all the data it receives from the real server.
The script might be useful for streaming directly from one-click-hosting services like Rapidshare, FileServe and others. These services typically use an HTML form or some kind of HTTP API to validate the user's credentials and sets a cookie with a session key - without this cookie, there is no way to download the file.
It provides a webserver on 127.0.0.1:64653. To make a request, first encode the URL you want to retrieve in Base64 and do the same with the HTTP headers to be sent. The HTTP headers need to be in the format a web server would expect:
The URL is formed like this:
An example:
if the video URL is
and the header needs to contain the following information:
, the resulting URL is:
You can now pass this URL to XBMC as the video URL.
You can check in your addon if the service is running by querying
, which should return:
Here's the script:
http://pastebin.com/b1mJzTbL
I wrote this only for testing purposes, but figured it might help other people to create better streaming plugins.
Hi,
I did not find a way to pass cookies and other HTTP headers to XBMC for video playback, so I wrote a small python script that can be installed as an XBMC service. It works a bit like a proxy server (remember VeohProxy?) and allows you to specify:
- the URL to download and
- the HTTP headers to send with each request XBMC makes to that URL
It will just pass through the request headers that XBMC sends to the local webserver and add the ones you specified. It will then send back all the data it receives from the real server.
The script might be useful for streaming directly from one-click-hosting services like Rapidshare, FileServe and others. These services typically use an HTML form or some kind of HTTP API to validate the user's credentials and sets a cookie with a session key - without this cookie, there is no way to download the file.
It provides a webserver on 127.0.0.1:64653. To make a request, first encode the URL you want to retrieve in Base64 and do the same with the HTTP headers to be sent. The HTTP headers need to be in the format a web server would expect:
Code:
Key: Value\r\n
Key2: Value2\r\n
Code:
http://127.0.0.1:64653/withheaders/[urlBase64]/[HeadersBase64]
if the video URL is
Code:
http://my.test.com/testfile_needs_cookies.avi
Code:
Cookie: AuthorizedUser0815
Code:
http://127.0.0.1:64653/withheaders/aHR0cDovL215LnRlc3QuY29tL3Rlc3RmaWxlX25lZWRzX2Nvb2tpZXMuYXZp/Q29va2llOiBBdXRob3JpemVkVXNlcjA4MTUNCg==
You can check in your addon if the service is running by querying
Code:
http://127.0.0.1:64653/version
Code:
Proxy: Running
Version: 0.1
Here's the script:
http://pastebin.com/b1mJzTbL
I wrote this only for testing purposes, but figured it might help other people to create better streaming plugins.