I’m trying to follow the C# example in Javascript to match what was posted on the blog, but I keep getting a 400 Bad Request and the log file says:
Had trouble breaking X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=
My javascript is basically the example given in the blog post but constructs the URL and redirects to it.
<br />
<br />
<script type="text/javascript" src="base64.js"></script><br />
<script type="text/javascript" src="jssha256.js"></script><br />
<script><br />
<br />
function move() {<br />
<br />
part = '/library/parts/1/Jake%20and%20Amir_%20Karate.m4v';<br />
part = encodeURI(part);<br />
myurl = "/video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400" + part + "&3g=0&httpCookies=&userAgent=";<br />
<br />
publicKey = "KQMIY6GATPC63AIMC4R2";<br />
privateKey = decode64("k3U6GLkZOoNIoSgjDshPErvqMIFdE0xMTx8kgsrhnC0=");<br />
time = Math.round(new Date().getTime() / 1000);<br />
<br />
msg = myurl+"@"+time;<br />
redirectURL = msg;<br />
HMAC_SHA256_init(privateKey);<br />
HMAC_SHA256_write(msg);<br />
mac = HMAC_SHA256_finalize();<br />
token = encode64(array_to_string(mac));<br />
<br />
<br />
window.location = 'http://localhost:32400' + redirectURL + "&X-Plex-Access-Key=" + publicKey + "&X-Plex-Access-Time="+ time + "&X-Plex-Access-Code=" + token; <br />
}<br />
<br />
</script><br />
<br />
<body onload="timer=setTimeout('move()',0)"><br />
<br />
It produces something like
http://localhost:32400/video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400/library/parts/1/Jake%2520and%2520Amir_%2520Karate.m4v&3g=0&httpCookies=&userAgent=@1306120533&X-Plex-Access-Key=KQMIY6GATPC63AIMC4R2&X-Plex-Access-Time=1306120533&X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=
And in the log file I get
<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - Request: GET /video/:/transcode/segmented/start.m3u8?identifier=com.plexapp.plugins.library&ratingKey=97007888&offset=0&quality=5&url=http%3A%2F%2Flocalhost%3A32400/library/parts/1/Jake%2520and%2520Amir_%2520Karate.m4v&3g=0&httpCookies=&userAgent=@1306120533&X-Plex-Access-Key=KQMIY6GATPC63AIMC4R2&X-Plex-Access-Time=1306120533&X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU= [::1] (1 live)<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * identifier => com.plexapp.plugins.library<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * ratingKey => 97007888<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * offset => 0<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * quality => 5<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * url => http://localhost:32400/library/parts/1/Jake%20and%20Amir_%20Karate.m4v<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * 3g => 0<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * httpCookies => <br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * userAgent => @1306120533<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * X-Plex-Access-Key => KQMIY6GATPC63AIMC4R2<br />
May 22, 2011 22:15:33 [0xb038d000] DEBUG - * X-Plex-Access-Time => 1306120533<br />
May 22, 2011 22:15:33 [0xb038d000] ERROR - Had trouble breaking X-Plex-Access-Code=3W3wnpyaxPEIfbV+mSg5fPFU3HZHWqRbh9aYfmDAbFU=<br />
May 22, 2011 22:15:33 [0xb038d000] ERROR - ERROR: Parsing request failed.<br />
May 22, 2011 22:15:33 [0xb0c08000] DEBUG - Request: GET /favicon.ico [::1] (1 live)<br />
May 22, 2011 22:15:33 [0xb0c08000] DEBUG - Content-Length of /Users/dan/Library/Application Support/Plex/Plex Media Server.app/Contents/Resources/Graphics/favicon.ico is 1150.<br />
Any ideas on what I'm doing wrong here?