Any success in doing authentication via python?
#1
Voinage (or any other python guru out there)

following this http://forum.xbmc.org/showthread.php?tid=33713 ...

I have a question: is it possible for an XBMC python plugin or script to authenticate itself (session? cookies?) on a website as we do via the browser?

I am finalized an script for Globo.com. I can parse all files, find the correct video files, provided I am authenticated, which I can only do via my browser on the PC.

Any clue on how to pass user/pwd information via a python script.

Here an example of video links protected behind authentication. I am subscriber of this website service, and have a proper login. I just want to know whether it is possible to somehow login via python on XBMC.

http://video.globo.com/Videos/Busca/0,,7...3%ADntegra


Regards
Ricardo.
Reply
#2
You need to use cookie lib.

Search for the sirius radio script and look at the cookie auth within that.

I`m a bit tied up at the moment to help more . sorry.
Reply
#3
Tks Voinage

I will have a look. Don't spend your time in Globo.com request (other than the auth if you can). I can do a very basic script (not plugin) that will do the job for me (and I guess for quite some other brazilian users). I just need some insight on the auth part.

I will have a look on Sirius auth mechanism.

Regards
Ricardo.
Reply
#4
Voinage,

I will not let this beat me ! Big Grin

Had a look on Sirius, and they cleverly parse the HTML-based login page to get what they need (even across an image confirmation, making it difficult).

Globo is using embedded Javascript Oo

I had to resort to watching my HTTP traffic and look what I have found with HTTPDebugger:


POST /webmedia/player/GMCLogin HTTP/1.1
Host: playervideo.globo.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://playervideo.globo.com/webmedia/pl...3653034618
Cookie: RMID=5bb08424484599c0; ntr=true; GloboCookie1=2333673994.16671.0000; JSESSIONID=Gp1gLWfTnk2c0qzgznLLpFh77R7pLTNxS8GYP1L39JFBtQJnFQ24!-1844461385
Content-Type: application/x-www-form-urlencoded
Content-Length: 137

login=MYLOGINHERE&senha=MYPWDHERE&ntr=true&escondeFimVideo=true&nocache=1213653034618&pp=true&midiaId=841754&autoStart=true


Now I have to put all pieces together. Firts setup a cookie using urlencode with something like the code above, then finally get to the final video file links once authenticated.

More to come ...

Ricardo.
Reply
#5
Any luck with this, trying to figure out how to authenticate rapidshare
Reply
#6
Use wireshark then use urllib2.

cookie=response.info()['Set-cookie']
to get the cookie

then use a header request to send the cookie along with the Auth data.
Reply
#7
Don't know if this helps anything, but I have used something like this in one of my plugins that uses cookies.

Code:
urlopen = urllib2.urlopen
cj = cookielib.LWPCookieJar()
Request = urllib2.Request

if cj != None:
  if os.path.isfile(os.path.join(resDir, 'cookies.lwp')):
    cj.load(os.path.join(resDir, 'cookies.lwp'))
  opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
  urllib2.install_opener(opener)

def openURL(self, url):
  req = Request("http://www.domain.com/index.sl?username="+xbmcplugin.getSetting("username")+"&password="+xbmcplugin.getSetting("password"))
  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')
  data=""  
  try:
    cFile = opener.open(req)
    data = cFile.read()
    cFile.close()
  except urllib2.URLError,value:
    print str(value)
    return -1
  return data
Reply

Logout Mark Read Team Forum Stats Members Help
Any success in doing authentication via python?0