Logging into sites from plugin
#1
Star 
Hi,

I am new to writing XBMC plugins, and have written one successful plugin so far, mostly for learning purposes. I just took on a new project to write a plugin that would first have to login to a site using username and password. I think I have figured that part out, but I think when I try to access the actual page that has the stream, I get the response as if the site did not take my login info, or somehow lost it. I would think, I would probably need to do something along the cookies side, but don't know how... Below is my code so far. Can someone be kind enough to guide me what else I need to do to make it work?

Below is the code... At the end the link statement should show me MMS links in between if the site logs me in, else it shows the same page source except the MMS link, which is what I am getting...

import os,sys,urllib2,re,mechanize,ClientForm

url='http://asx.jumptv.com/playlist.asx?lang=en&productId=291'
# Login Site
loginurl='http://www.jumptv.com/en/signin?wid=9074'

username='<actual username>'
password='<actual password>'

print 'Login Started'

browser = mechanize.Browser()
lreq = urllib2.Request(loginurl)
lreq.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
lresponse = urllib2.urlopen(lreq)

forms = ClientForm.ParseResponse(lresponse, backwards_compat=False)
form = forms[0]
form['data[SignIn][Account][signInName]'] = username
form['data[SignIn][Account][password]'] = password

browser.open(form.click())

print 'Login Finished'

req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()

link
Reply

Logout Mark Read Team Forum Stats Members Help
Logging into sites from plugin1