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&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>
