Site Configuration Login Not Working

As some of you may know, I’ve been working on the MLB plugin which highly relies on cookie sessions. My biggest hang up is getting the plugin to reliably login before the plex client times out. I figured writing a site configuration to login and then skip loging in on a live session would eliminate most of the issues but I’m having no such luck.



It’s really a bummer that cookies can’t be shared with webkit because I wrote a nice login script in python that works perfectly. I used cookielib and os.path to save cookies in a file locally e.g. /Plug-in Support/Data/com.plexapp.plugins.mlb/LWP.cookies. Is there anyway to import these from the file to webkit? Thanks in advance for any input/ideas.



This is my site configuration and it will not login. Can someone please tell me what I’m missing? Thanks…



<?xml version="1.0" encoding="UTF-8"?><br />
        <site site="http://mlb.mlb.com/shared/flash/"<br />
              plugin="http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MediaPlayer4.swf?"<br />
              agent="Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0"<br />
              identifier="com.plexapp.plugins.mlb"<br />
              initialState="wait-for-frame-load"<br />
              manualLock="true"<br />
              version="1.0"><br />
<br />
              <crop x="0" y="106" width="800" height="450" /><br />
<br />
              <!-- The condition we use several times from within states to check if we're logged in or not --><br />
              <condition name="need-to-login"><br />
                <and><br />
                   <javascript script="document.getElementById('login_form') == null ? 1 : 0" matches="0" /><br />
                </and><br />
              </condition><br />
<br />
              <state name="wait-for-frame-load"><br />
                <event><br />
                  <condition><br />
                    <frameLoaded /><br />
                  </condition><br />
                  <!-- ...then goto the 'check-for-auth' state --><br />
                  <action><br />
                     <goto state="check-for-auth" /><br />
                  </action><br />
                    </event><br />
                      </state><br />
<br />
              <state name="check-for-auth"><br />
                <event><br />
                   <condition><br />
                <!-- If we don't need to login, goto state 'loading' --><br />
                      <not><br />
                         <condition name="need-to-login" /><br />
                      </not><br />
                   </condition><br />
                   <action><br />
                       <goto state="loading" /><br />
                   </action><br />
                </event><br />
            <br />
                <event><br />
                <!-- If we *do* need to login visit login page --><br />
                  <condition><br />
                    <condition name="need-to-login" /><br />
                  </condition><br />
                    <action><br />
                      <visit url="http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&amp;c_id=mlb" /><br />
                      <pause time="500" /><br />
                      <goto state="login" /><br />
                    </action><br />
                      </event><br />
                </state><br />
<br />
                <!-- Javascript to fill in form detail and sumit' --><br />
                <state name="login"><br />
                  <event><br />
                    <condition><br />
                    <javascript script="true ? 1 : 0" matches="1" /><br />
                    </condition><br />
                      <action><br />
                        <run script="var form = document.getElementById('login_form'); form.uri.value='/account/login_register.jsp'; form.registrationAction.value='identify'; form.emailAddress.value='${mlb_user}';               form.password.value='${mlb_pass}'; document.getElementById('login_form').submit();" /><br />
                        <visit url="${url}" /><br />
                        <lockPlugin /><br />
                        <goto state="playing" /><br />
                      </action><br />
                   </event><br />
                </state><br />
                <!-- Load URL from plugin' --><br />
                <state name="loading"><br />
                   <event><br />
                     <condition><br />
                     <javascript script="true ? 1 : 0" matches="1" /><br />
                     </condition><br />
                     <action><br />
                     <visit url="${url}" /><br />
                     <lockPlugin /><br />
                     <goto state="playing" /><br />
                     </action><br />
                   </event><br />
                </state><br />
                <!-- Make sure we're logged in' --><br />
                <state name="check-for-auth-again"><br />
                  <event><br />
                    <condition><br />
                      <not><br />
                      <condition name="need-to-login" /><br />
                      </not><br />
                    </condition><br />
                    <action><br />
                    <visit url="${url}" /><br />
                    <goto state="playing" /><br />
                    </action><br />
                   </event><br />
<br />
                   <!-- If login continues to fail - * This never happens as I always seem to get a false negative @ need-to-login condition--><br />
                   <event><br />
                     <condition><br />
                     <condition name="need-to-login" /><br />
                     </condition><br />
                     <action><br />
                     <goto state="end" param="Please check your username and password in the plugin's settings" /><br />
                     </action><br />
                   </event><br />
                </state><br />
<br />
<br />
                <!-- PLAYING --><br />
                <state name="playing"><br />
                  <event><br />
                    <condition><br />
                    <command name="pause" /><br />
                    </condition><br />
                    <action><br />
                    <click x="223" y="533" /><br />
                    <goto state="paused" /><br />
                    </action><br />
                  </event><br />
                </state><br />
        <br />
                <!-- PAUSED --><br />
                <state name="paused"><br />
                  <event><br />
                    <condition><br />
                    <command name="play" /><br />
                    </condition><br />
                     <action><br />
                     <click x="223" y="533" /><br />
                     <goto state="playing" /><br />
                     </action><br />
                   </event><br />
                </state><br />
<br />
            </site>

After many relentless hours of reconfiguring and trying everything under the sun I’ve come to the simple conclusion that site config is garbage for logging in to an account! Hopefully the people developing Plex realize this and find a way to let cookies be shared between python and webkit. This way site config and webkit can worry about loading video instead of all this other stuff. Until then, I surrender to v2 framework :frowning:

I’m sorry you’ve been having a difficult time with the Site Config, I know they can be tough. It’s hard to give advice by simply reading it, but one thing I did notice is this:



<br />
<run script="var form = document.getElementById('login_form'); form.uri.value='/account/login_register.jsp'; form.registrationAction.value='identify'; form.emailAddress.value='${mlb_user}';form.password.value='${mlb_pass}'; document.getElementById('login_form').submit();" /><br />
<visit url="${url}" /><br />




I don't believe that the run will wait until the page has fully be submitted. It might be best to add a pause afterwards, before navigating to the URL. If that doesn't help, maybe you could also attach a copy of 'Plex Media Server.log' which will include details of whats going on. If you do so, might be worth to ensure that any username/passwords are not included in the log...

Ian

Thanks for your reply IanB! I did add a pause as you suggested and I’m also now using cookies (document.cookie.indexOf) as the need-to-login verifier. I’m getting a match of -1 so that part works as it should however everything stops functioning after running the login script. I don’t understand why as I know the script is good, it works fine when I use a more basic site config that doesn’t attempt to verify a login session. Here’s my new site config along with plex media server.log





?xml version="1.0" encoding="UTF-8"?><br />
<site site="http://.*mlb\.com/shared/flash/"<br />
    plugin="http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MediaPlayer4.swf"<br />
    agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13"<br />
    initialState="wait-for-frame-load"<br />
    version="1.0"<br />
    identifier="com.plexapp.plugins.mlb"<br />
    manualLock="true"><br />
<br />
    <crop x="0" y="106" width="800" height="450" /><br />
    <br />
    <seekbar type="simple"><br />
    <start x="390" y="528" /><br />
    <end x="745" y="528" /><br />
    <played><br />
    <color rgb="4f4f4f" /><br />
    <color rgb="616161" /><br />
    </played><br />
    </seekbar><br />
<br />
<!-- The condition we use several times from within states to check if we're logged in or not --><br />
    <condition name="need-to-login"><br />
        <and><br />
            <!-- Check if a specific element exists in the page --><br />
            <!-- Returns true if we need to login --><br />
            <javascript script="document.cookie.indexOf('appacc=mlb')" matches="-1" /><br />
        </and><br />
    </condition><br />
<br />
    <!-- Wait for frame to load --><br />
    <state name="wait-for-frame-load"><br />
        <event><br />
            <condition><br />
                <!-- Wait for the DOM to load... --><br />
                <frameLoaded /><br />
            </condition><br />
            <action><br />
                <!-- ...then goto the 'check-for-auth' state --><br />
                <goto state="check-for-auth" /><br />
            </action><br />
        </event><br />
    </state><br />
<br />
    <!-- Check for auth --><br />
    <state name="check-for-auth"><br />
        <event><br />
            <condition><br />
                <!-- If we don't need to login, goto state 'loading' --><br />
               <not><br />
                 <condition name="need-to-login" /><br />
               </not><br />
            </condition><br />
            <action><br />
                <goto state="loading" /><br />
            </action><br />
        </event><br />
        <event><br />
            <!-- If we *do* need to login, try to login --><br />
            <condition><br />
                <condition name="need-to-login" /><br />
            </condition><br />
            <action><br />
                <visit url="http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&amp;c_id=mlb" /><br />
                <run script="var form = document.getElementById('login_form'); form.uri.value='/account/login_register.jsp'; form.registrationAction.value='identify'; form.emailAddress.value='${mlb_user}'; form.password.value='${mlb_pass}'; document.getElementById('login_form').submit();" /><br />
                <pause time="3000" /><br />
                <goto state="check-for-auth-again" /><br />
            </action><br />
        </event><br />
    </state><br />
    <br />
    <!-- Check for auth again --><br />
    <state name="check-for-auth-again"><br />
        <event><br />
            <condition><br />
                <!-- If login was successful we should now not need to login and can go to the state 'loading' --><br />
                <not><br />
                    <condition name="need-to-login" /><br />
                </not><br />
            </condition><br />
            <action><br />
                <goto state="loading" /><br />
            </action><br />
        </event><br />
        <event><br />
            <condition><br />
                <!-- If we still need to login after we've tried to login, something is wrong... --><br />
                <condition name="need-to-login" /><br />
            </condition><br />
            <action><br />
                <goto state="end" param="Please check your username and password in the plugin's settings" /><br />
            </action><br />
        </event><br />
    </state><br />
    <br />
    <state name="loading"><br />
        <event><br />
            <condition><br />
                <javascript script="true ? 1 : 0" matches="1" /><br />
            </condition><br />
            <action><br />
                <visit url="${url}" /><br />
                <lockPlugin /><br />
                <goto state="playing" /><br />
            </action><br />
        </event><br />
    </state><br />
<br />
      <!-- PLAYING --><br />
    <state name="playing"><br />
        <event><br />
            <condition><br />
                <command name="pause" /><br />
            </condition><br />
            <action><br />
                <click x="223" y="533" /><br />
                <goto state="paused" /><br />
            </action><br />
        </event><br />
    </state><br />
              <br />
      <!-- PAUSED --><br />
    <state name="paused"><br />
        <event><br />
            <condition><br />
                <command name="play" /><br />
            </condition><br />
            <action><br />
                <click x="223" y="533" /><br />
                <goto state="playing" /><br />
            </action><br />
        </event><br />
    </state><br />
<br />
</site><br />







Apr 18, 2012 13:59:28 [9148] DEBUG - (Capabilities) Adding WebKit.<br />
Apr 18, 2012 13:59:28 [9148] DEBUG - (Capabilties) Passing down capabilities of 'protocols=http-video,shoutcast,webkit;videoDecoders=h264{profile:high&resolution:1080&level:51};audioDecoders=mp3,aac' to plug-in.<br />
Apr 18, 2012 13:59:29 [9012] DEBUG - Request: GET / [127.0.0.1] (2 live)<br />
<br />
Apr 18, 2012 13:59:29 [9012] DEBUG - It took 0.001000 sec to serialize a list with 15 elements.<br />
Apr 18, 2012 13:59:30 [9148] DEBUG - HTTP request to: http://127.0.0.1:65100/video/mlb/:/function/ScoreboardArc?function_args=Y2VyZWFsMQozCmRpY3QKZGljdApGcmFtZXdvcmsub2JqZWN0cy5JdGVtSW5mb1JlY29yZAoyCnM2NQpodHRwOi8vZ2R4Lm1sYi5jb20vY29tcG9uZW50cy9nYW1lL21sYi8veWVhcl8yMDEyL21vbnRoXzAzL2RheV8wN3MzCnVybHIyCnM2CnNlbmRlcjUKczMKN3RoczkKaXRlbVRpdGxlczIxCk1ham9yIExlYWd1ZSBCYXNlYmFsbHM2CnRpdGxlMXM1Ck1hcmNoczYKdGl0bGUyczUxCi92aWRlby9tbGIvOi9yZXNvdXJjZXMvYXJ0LWRlZmF1bHQuanBnP3Q9MTMwMjg5NDUzMHMzCmFydHM1MgovdmlkZW8vbWxiLzovcmVzb3VyY2VzL2ljb24tZGVmYXVsdC5wbmc%40dD0xMzAyODk0NTMwczUKdGh1bWJyMQpyMAo_<br />
Apr 18, 2012 13:59:30 [9148] DEBUG - [com.plexapp.plugins.mlb] HTTP reply status 200, with 7488 bytes of content.<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - Request: GET /video/:/webkit?url=http%3A%2F%2Fmlb.mlb.com%2Fshared%2Fflash%2Fmediaplayer%2Fv4.3%2FR1%2FMP4.jsp%3Fcalendar_event_id%3D14-332165-2012-03-07%26content_id%3D%26media_id%3D%26view_key%3D%26media_type%3Dvideo%26source%3DMLB%26sponsor%3DMLB%26clickOrigin%3D%26affiliateId%3D%26team%3Dmlb&prefix=/video/mlb [127.0.0.1] (1 live)<br />
Apr 18, 2012 13:59:32 [9012] DEBUG -  * url => http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MP4.jsp?calendar_event_id=14-332165-2012-03-07&content_id=&media_id=&view_key=&media_type=video&source=MLB&sponsor=MLB&clickOrigin=&affiliateId=&team=mlb<br />
Apr 18, 2012 13:59:32 [9012] DEBUG -  * prefix => /video/mlb<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - WebKit: [mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MP4.jsp?calendar_event_id=14-332165-2012-03-07&content_id=&media_id=&view_key=&media_type=video&source=MLB&sponsor=MLB&clickOrigin=&affiliateId=&team=mlb]<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - Found corresponding plug-in: C:\Users\AppData\Local\Plex Media Server\Plug-in Support/Data\com.plexapp.plugins.mlb<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - WebKit: Resetting to state wait-for-frame-load.<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - Using C:\Users\AppData\Local\Plex Media Server\Plug-ins\MLB-2012-beta3.bundle\Contents/Site Configurations\mlb_live.xml with score of 32.<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - WK_BrowseToURL http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MP4.jsp?calendar_event_id=14-332165-2012-03-07&content_id=&media_id=&view_key=&media_type=video&source=MLB&sponsor=MLB&clickOrigin=&affiliateId=&team=mlb<br />
Apr 18, 2012 13:59:32 [13252] DEBUG - WebKit successfully loaded http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MP4.jsp?calendar_event_id=14-332165-2012-03-07&content_id=&media_id=&view_key=&media_type=video&source=MLB&sponsor=MLB&clickOrigin=&affiliateId=&team=mlb<br />
Apr 18, 2012 13:59:32 [9012] DEBUG - WebKit: Sending line: HELLO<br />
Apr 18, 2012 13:59:32 [13252] DEBUG - WebKit: Received title [MLB.com: Media Player].<br />
Apr 18, 2012 13:59:34 [13252] DEBUG - Plugin loaded (application/x-shockwave-flash, http://mlb.mlb.com/shared/flash/mediaplayer/v4.3/R1/MediaPlayer4.swf?v=14, 7ED3AFA0, 0, 0, 800, 579, mpContainer)<br />
Apr 18, 2012 13:59:34 [13252] DEBUG - WebKit: Plug-in changed frame size to 1024 x 768<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Frame was loaded, processing event.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executing Moving to state check-for-auth.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executed 'document.cookie.indexOf('appacc=mlb') ' and now seeing if [-1] matches [-1].<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executed 'document.cookie.indexOf('appacc=mlb') ' and now seeing if [-1] matches [-1].<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executing Visiting http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&c_id=mlb.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - Browsing to URL: http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&c_id=mlb<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WK_BrowseToURL http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&c_id=mlb<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Stopping execution, waiting for state 1.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Saving pendingContext: 02B9AC48 pendingEvent: 02BACE78 in state check-for-auth.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Frame was loaded, processing event.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executing Javascript(var form = document.getElementById('login_form'); form.uri.value='/account/login_register.jsp'; form.registrationAction.value='identify'; form.emailAddress.value='${mlb_user}'; form.password.value='${mlb_pass}'; document.getElementById('login_form').submit();).<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Executing Pausing 3000ms.<br />
Apr 18, 2012 13:59:35 [13252] DEBUG - WebKit: Stopping execution, waiting for state 2.<br />
Apr 18, 2012 13:59:36 [13252] DEBUG - WebKit: Got frame loaded, was waiting for something else (pendingContext: 02B9AC48 pendingEvent: 02BACE78)<br />
Apr 18, 2012 13:59:36 [13252] DEBUG - WebKit successfully loaded http://mlb.com/index.jsp/enterworkflow.do?flowId=registration.ajax.wizard&c_id=mlb<br />
Apr 18, 2012 13:59:37 [13252] DEBUG - WebKit: Got frame loaded, was waiting for something else (pendingContext: 02B9AC48 pendingEvent: 02BACE78)<br />
Apr 18, 2012 13:59:37 [13252] DEBUG - WebKit: Got frame loaded, was waiting for something else (pendingContext: 02B9AC48 pendingEvent: 02BACE78)<br />
Apr 18, 2012 13:59:37 [13252] DEBUG - WebKit: Got frame loaded, was waiting for something else (pendingContext: 02B9AC48 pendingEvent: 02BACE78)

Are you using Windows or OSX PMS? Also what version? I reported an issue a while back where PMS would not move to the next appropriate state following a ‘pause’ which appears to be similar to what you are seeing. However, i’m pretty sure the issue was resolved in the latest betas. Are you using them?

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