Control over requesting and streaming of online content, custom headers?
#1
There is a website that requires certain cookies & certain headers to be sent in the query to stream the video url...

How much control do I have in python in controlling how xbmc streams & downloads the online url, for any scheme.. http or rtsp..etc..?

For example, in python I can use urllib2 to send custom headers & cookies to the online video, and being downloading the file in chunks.. can I send these chunks to the xbmc play buffer, and send commands to being playing the parts that I downloaded..? Are there functions for this for controlling the way xbmc plays & downloads things via python?
I looked in:
http://home.no.net/thor918/xbmc/xbmc.html

All I saw where functions to "play" a file but no control over how it is requested and played..etc...
Spread the knowledge, nothing else.Image
Reply
#2
bump
No one has a clue?
Spread the knowledge, nothing else.Image
Reply
#3
From the lack of responses and lack of documenation or functions in the API to doing anything remotely close to what I was talking about...
I assume that python scripters have absolutely NO control over how xbmc plays a stream (changing the buffer, etc..), and how it requests the stream (headers, etc..).

This sucks! Sad
Advanced authentication to online content is the big keyword for web 2.0. Its ironic how an application all about MEDIA does not give scripters any API or ability to program in its primary purpose, playing media. I think there should be an API made for python scripting to have control over these things. I'd like to manually add things to the play buffer, send cookies with the request, https & ssl when requesting, headers, referers, useragents..etc..

We lose a LOT of access to online content from our xboxes if we do not have ability to control these things.
Spread the knowledge, nothing else.Image
Reply
#4
Unfortunately there's very few (read pretty much noone) actively working on the web API. If you want to alter things at the playing buffer level, then you'd probably want to be able to setup an additional layer at the virtual filesystem level.

We have a plugin api for directories, but nothing for files at the within-buffer level at all (and I suspect that'd be quite tricky). The plugin can request a URL using whatever system they need in order to get a valid session URL or whatever - some plugins (there's a youtube one floating around I think?) do this. Much more than this would ofcourse require some way to configure curl or similar.

You have a lot of ideas which is the first step. The next step, unfortunately, relies on those with the time, inclination, and skill to implement something such as this. If you are not such a person, you'll have to wait on those who are.

Cheers,
Jonathan
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
Reply
#5
Well you could run a server and have XBMC attempt to connect to itself. This is what I attempted with the iPlayer, and worked perfectly on Linux, but not on the XBOX due to threading issues.

Source is here if you're interested:
http://code.google.com/p/xbmc-iplayer/so...er.py?r=69
(note the code uses the old iPlayer 1.0 library which is useless on the new iPlayer site)

It's not neat or simple, but it's currently the only way.
Reply
#6
Trying to figure this out, but I need it to work on the XBOX.

I have so far, gotten the file downloading, and at 10 percent. It starts to
play the file, from the XBOX ftp server. The file continues to download and completes downloading before reaching 10%, but it will only play to 10%

Can I fix this with cache options, use the smb server?
Reply
#7
Look at veoh proxy for xbox
Reply
#8
I fixed this by using the file.truncate() using the size that is returned from

headers = page.info()
size = int(headers["Content-Length"])

This will make a file that is the total size, so even if playback starts at 10% it will stream the entire file.
Reply
#9
Can you please post your plugin when your done. i would like to see the code.
Reply
#10
ok, i have put up my code at http://www.veracrest.com/rapidshare.py

its somewhat crappy and incomplete

the part most relevant to this thread is under

def downloadURL

I will actually post the whole of that function here.

Code:
def downloadURL(self,source, destination, rarfile):        
    try:
      self.label.setLabel('hello')
      req = urllib2.Request(source)
      req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
      page = urllib2.urlopen(req);response=page.read();page.close()
      req = urllib2.Request(source)#send the new url with the cookie.
      req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')
      req.add_header('Cookie',rapidcookie)
      page = urllib2.urlopen(req)#;response=page.read();page.close()
      newsource = page.geturl()
      headers = page.info()
      self.message(page.geturl())
      
      dp = xbmcgui.DialogProgress()
      dp.create("RapidShare","Downloading File",source)
      
      bs = 1024*8
      size = -1
      read = 0
      blocknum = 0
      fout = open(destination, "wb")
      
      if "content-length" in headers:
            size = int(headers["Content-Length"])
      
      xk = 1
      
      while 1:
        block = page.read(bs)
        if block == "":
          break
        read += len(block)
        fout.write(block)
        fout.truncate(size)
        blocknum += 1  
        if dp.iscanceled():
           dp.close()
           break
        percent = int(blocknum*bs*100/size)
        if percent > 101:
         if xk == 1:
            
            self.playrar(rarfile)
            #xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play('smb://kingpin/k/k.mp3')
            xk = 0
        dp.update(percent)
        self.label.setLabel(str(percent) + ' percent ' + str((blocknum * bs) / 1000 ) + ' of ' + str(size / 1000))
    
      fout.close()
      #xbmc.Player(xbmc.PLAYER_CORE_MPLAYER).play(destination)  
    except:
      self.message('download failed')
Reply
#11
It's late, but here's a better solution: http://forum.xbmc.org/showthread.php?tid=95369
Reply

Logout Mark Read Team Forum Stats Members Help
Control over requesting and streaming of online content, custom headers?0