Create a login in start()

Hey,



In the plex dev site it is said that performing a login to gain access to certain content on websites should be possible, however on this forum as well as in the dev part of the plex website I cannot find ways to perform a login.

So here is my question. How can I create a login that allows plex to login at a certain website and gain access to user restricted content.

Hi David,



there’s no one mechanism since every web site deals with the differently. You need to figure out how the web site does it (url, parameters, etc) and then issue a HTTP.Request against that mechanism. Most plugins use the Preferences support to get the name and password from the user to use as parameters for the login.



Jonny

The Vimeo plugin has a login, you can use that as a starting point. The idea is to check for a certain piece of information. If it’s there it means you’re logged in, if not, you’re not.


<br />
####################################################################################################<br />
<br />
def GetMyStuff(sender):<br />
  ...<br />
  ...<br />
  # See if we have any creds stored.<br />
  if not Prefs.Get('email') and not Prefs.Get('password'):<br />
    return MessageContainer(header='Logging in', message='Please enter your email and password in the preferences.')<br />
<br />
  # See if we need to log in.<br />
  xml = XML.ElementFromURL(VIMEO_URL + 'subscriptions/channels/sort:name', True, cacheTime=0)<br />
  if xml.xpath('//title')[0].text != 'Your subscriptions on Vimeo':<br />
    Login()<br />
<br />
  # Now check to see if we're logged in.<br />
  xml = XML.ElementFromURL(VIMEO_URL + 'subscriptions/channels/sort:name', True, cacheTime=0)<br />
  if xml.xpath('//title')[0].text != 'Your subscriptions on Vimeo':<br />
    return MessageContainer(header='Error logging in', message='Check your email and password in the preferences.')<br />
  else:<br />
  ...<br />
  ...<br />
  ...<br />
<br />
####################################################################################################<br />
<br />
def Login():<br />
  values = {<br />
     'sign_in[email]' : Prefs.Get('email'),<br />
     'sign_in[password]' : Prefs.Get('password')<br />
  }<br />
<br />
  x = HTTP.Request("http://www.vimeo.com/log_in", values)<br />


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.