Not content to leave well enough alone, I was hacking on my bookmarklet some more. It can now handle crossing between seasons. There is also a bit less guessing going on now, so I am more confident in it.
For the record, I want to say, I hope Netflix does not get upset about this, if they want me to remove it I will.
To use this:
1. Drag the link below on to your bookmarks bar.
2. Start watching a TV show on Netflix.
3. Click the bookmark and enter then number of episodes you want to watch.
Note: I have now tested this in IE. It does NOT work. But you wouldn’t use IE anyway, would you?
Netflix Autoplay Bookmarklet – With Multiple Season Support![/raw]
javascript:(function(netflix, undefined) {
var seasonId = 0,
episodeId = 0,
numWatched = 0,
numToWatch = 3,
epIdRegex = /,EpisodeMovieId=\d*,/,
idregx = /\d+/,
done = false,
sl,
init,
currrentEpisodeId,
currentMovieId,
seasons,
showData,
waitTimer,
node;
if(!netflix || !netflix.Silverlight || !netflix.Silverlight.MoviePlayer || !netflix.Silverlight.MoviePlayer.getPlugin() || !netflix.Silverlight.MoviePlayer.getPlugin().settings.initParams) {
alert('You do not appear to have a show playing, please start a show first');
return;
}
//grab the things we need
sl = netflix.Silverlight.MoviePlayer.getPlugin().getScriptInterface();
init = netflix.Silverlight.MoviePlayer.getPlugin().settings.initParams;
currrentEpisodeId = parseInt(idregx.exec(epIdRegex.exec(init)), 10);
currentMovieId = parseInt(netflix.Silverlight.MoviePlayer.getPlugin().settings.movieId, 10);
//Check if the user has already loded teh bookmarklet
var autoplayElement = document.getElementById('NetflixAutoplay');
if(autoplayElement) {
alert('You have already loaded the autoplay bookmarklet, click the text at the botton to change number of episodes.');
return;
}
//grab the metadata and decode it
try {
showData = JSON.parse(decode64(netflix.Silverlight.MoviePlayer.getPlugin().settings.metadata));
} catch(e) {
alert('Error processing data =(');
return;
}
if(showData.Movie) {
alert('This appears to be a movie not a TV show. This bookmarklet only works on TV show.');
return;
}
//set our pointest to match the episode we are currently on
seasons = showData.Show.Seasons;
for(seasonId = 0; seasonId < seasons.length; seasonId++) { for(episodeId = 0; episodeId < seasons[seasonId].Episodes.length; episodeId++) { if(seasons[seasonId].Episodes[episodeId].MovieId === currentMovieId || seasons[seasonId].Episodes[episodeId].MovieId === currrentEpisodeId) { done = true; break; } } if(done) { break; } } //check if we were able to find the episode the user is on if(seasonId === seasons.length) { alert('Error: Already of final episode, or episode data could not be found.'); return; } //Prompt user for number of episodes function getNumberOfEpisodesToWatch() { var newNum; do { newNum = prompt('How many episodes would you like to play?', (numToWatch - numWatched)); } while (isNaN(newNum)); numWatched = 0; numToWatch = parseInt(newNum, 10); //set the text if(numToWatch > 0) {
autoplayElement.innerHTML = 'Netflix autoplay on, Episodes left: ' + numToWatch;
} else {
autoplayElement.innerHTML = 'Netflix autoplay off';
}
}
//create the text that shows how many episodes left & insert it
node = document.createElement('span');
autoplayElement = document.body.appendChild(node);
autoplayElement.id = 'NetflixAutoplay';
autoplayElement.innerHTML = 'Netflix autoplay on, Episodes left: ' + numToWatch;
//attach a click handler so people can change number of episodes
autoplayElement.addEventListener('click', getNumberOfEpisodesToWatch, false);
//prompt the user for number of episodes for the first time
getNumberOfEpisodesToWatch();
//handle when the episode ends
sl.OnMovieWatched = function() {
if(numWatched < numToWatch && !waitTimer) { //Check if done autoplaying waitTimer = setTimeout(function() { //Set our timer so we do not end early var epp, numLeft; //move episode/season counters properly if(seasons[seasonId].Episodes[episodeId+1]) { episodeId++; } else { episodeId = 0; seasonId++; } //if there is a next episode, grab it if(seasons[seasonId] && seasons[seasonId].Episodes[episodeId]) { epp = seasons[seasonId].Episodes[episodeId]; } //if there is a next episode, play it and update the text if (epp) { sl.PlayMovie({movieId: epp.MovieId, episodeMovieId: 0, trackId: 0}); numWatched++; numLeft = numToWatch - numWatched; if(numLeft > 0) {
autoplayElement.innerHTML = 'Netflix autoplay on, Episodes left: ' + numLeft;
} else {
autoplayElement.innerHTML = 'Netflix autoplay completed.';
}
}
//cleanup
clearTimeout(waitTimer);
waitTimer = null;
}, 2*60*1000);
}
};
//This is just a bse64 decoder
function decode64(input) {
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
output = '',
chr1, chr2, chr3 = '',
enc1, enc2, enc3, enc4 = '',
i = 0,
base64test = /[^A-Za-z0-9\+\/\=]/g;
input = input.replace(base64test, '');
do {
enc1 = keyStr.indexOf(input.charAt(i++));
enc2 = keyStr.indexOf(input.charAt(i++));
enc3 = keyStr.indexOf(input.charAt(i++));
enc4 = keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); } chr1 = chr2 = chr3 = ''; enc1 = enc2 = enc3 = enc4 = ''; } while (i<input.length); return unescape(output); } })(window.netflix);
In addition to handling moving between seasons, it now also adds a little text below the movie to tell you that it is on. You can click this text to change the number of episodes it will play. Entering 0 for the number of episodes will turn this off.
This isn’t working. (Firefox). I begin an episode of Andy Griffith, Click on the bookmark, enter “3” for episodes, skip to the end (which may be messing it up – don’t know, will try without skipping), then wait till the end. It just stays there. If it works without skipping, I’ll try and get back so you don’t waste any time.
Thanks!
Hey, tried it again with no fast forwarding, worked! Does it have to be on full screen like other ones?
Other ones being other programs.
There is no need for it to be full screen. Fast-forwarding can however mess it up. Actually if you had let it sit for 2 minutes it probably would have started the next episode. I have not found a good way to tell when the episode is over, Netflix has a “episode end” event I am using, but it fires about 2 minutes before the episode is actually over, so I am starting a timer that waits 2 minutes before starting the next episode.
Glad it worked for you the next time though!
cool. It does end some early, but hey, it’s a great fix!
I look forward to any tweaks, but appreciate your work either way!
RTPMatt,
I really like this. I greatly appreciate the work you have done. It does occasionally cut episodes a little short, but its usually in the credits so I don’t really care. I hope you don’t mind, but I posed this to Facebook, as many of my friends use Netflix and thought they could benefit from your hard work.
Would you mind if I posted this on my site as one of my discoveries? I really like it and I am a major supporter of Open Source Code/Software. If you allow me, then I will gladly reference you as the author and can even send you a link when I post it to make sure you approve of the post.
Sincerely,
smleimberg
Glad you like it! Feel free to post it wherever, as long as you don’t try to take credit for it, it does not bother me! I do need to find a better solution for determining when an episode ends. I have some other cool ideas for things I could do with it, but at this point I am not really sure how much further I want to take it.
Hey, RTPMatt. Here is my post.
That is awesome man, I will keep you posted on any updates!
Pingback: Autoplay Next Netflix Episode Bookmarklet! | s.m.leimberg.com
Hi, this looks awesome, but doesnt seem to work for me.
I have two screens up and often have one screen showing netflix, fullscreened on the secondary screen, whilst working on the first (chrome, Windows 7).
I assume that because the javascript window isnt the active window? if so is there any way around it?
Hmm, no, I do the same thing, I have not had any problems. I am assuming you are at least getting the dialog asking how many episodes you want to watch when you hit the bookmarklet? Can you tell me what show it is? Perhaps there is a problem with that show. Otherwise, maybe hit F12 and see if you are getting any errors? If so, send them to me and I will take a look.
I’m having an issue with the autoplay in Chrome to where it skips to the beginning of the season and starts playing there, not from the current episode. Is there a fix to this?
I am not sure, can you tell me what show it was so I can take a look? Can you reproduce the problem?
Awesome Matt, Simply brilliant. Cheers! Works like a championnnnnn
Fantastic! I am glad it is working for you.
You, sir, are a genius. GENIUOS!!!! Thank you so much. It works perfectly in FF.
HAHA! Thank you! I knew I couldn’t be the only person who really wanted this feature for Netflix!
Definitely not the only one. Mad Props. Trying it out now.
Works great… *MOST* of the time. I’m still having a occasional issue where it will repeat the same episode… or go back to a certain episode (if say I click “next episode”). Wonder if I’m the only one having this issue.
Yes, this is a known bug. Unfortunately I have not found a way to get the current episode, so I have to go based on what episode it appears that you started at. It would be nice if I could fix this. Currently my advice load a new tab of Netflix, and start it playing on the first episode you want to watch. If I find a way to fix this, I will put out an update.
There is a much simpler implementation of the same concept available. Next-Flik works with all browsers and supports multiple seasons. It runs in the background and only works when Netflix is open and full screen.
http://www.next-flik.com
From what I see, it also costs $5 and is not open source. There is also autoflix which I have not tried either. Do you have experience with them?
autoFlix is open source, but also cost $5 dollars (since I’m a broke programmer trying to make a living). Next-Flik has recently come to my attention but its just a rip off of autoFlix, with less features. You’re bookmarklet is pretty impressive. Good job on the app.
also we have an iPhone/Android app about to be released, allowing you to remotely control Netflix. Free for autoFlix users. I’ll send you a free download Matt.
http://24.media.tumblr.com/tumblr_m27j5iuXPb1qz6oq7o1_500.png
Hah, no way man, I was actually just starting to look into making the same thing myself. I would love a download.
All of the shows that aren’t instant have discs that you can order and get sent to you on Netflix. Just click Add Discs and it will be in you queue and be sent as soon as your most rencet order has been returned
So I tried this out and it worked perfectly. The only thing is that shows with long credits are not exact, as I must wait a few minutes. Overall this is great, and I’ve been looking for something like this because I play games while watching this. Thanks 😀
Am I missing something? I’m trying to follow the three steps you outlined in every variety I can think of, and it’s not that it isn’t working, it’s that nothing’s happening. I copied and pasted “the link below” (for this I tried the 174 line thing, right-clicking the hyperlink in Chrome and clicking copy link address, and even copying and pasting the hyperlink itself), into the only bar in Chrome, and the only thing that ever happened was Google telling me the URL is too big to process. I’ve tried every combination of bookmark-pressing and copying/pasting I can think of, but so far all I have is 3 apparently simple instructions that don’t actually do anything.
Well, I am not exactly sure what the problem is. You need to make sure you have done this:
http://www.youtube.com/watch?v=0kh1dgcCUME
Then drag the link onto that bookmark bar. Hope that helps?
It is cutting off the end of the shows about 5 minutes early. Would this be looked into please? Thanks so much!
This seems to be a problem with some shows. The issue is that Netflix does not provide a reliable way to tell when a show ends so I am unfortunately using a timer to guess when it ends. If I find a better solution, I will post it.
awwww….Netflix updated their player and the bookmarklet no longer works. 🙁 It was great while it lasted.
Yeah. They did an update. Crap. I was really enjoying the autoplay feature.
I should have a fix out soon.
You are my hero sir. 🙂
raging at the fact that it no longer works. stupid netflix. the new layout is ugly.
Never fear, I already have the basics of a fix working, should be out soon, check back in the next day or two.
Like.
Awesome! So glad. My laziness thanks you.
Does this work with OS X? I’ve added it to my bookmarks in safari, chrome, and firefox, and tried clicking it with an episode running and nothing happens.
autoFlix works with Mac OS X now.
Download
Awesome man. As long as I am linking you, would you mind passing a link back my way?
I almost feel like we should combine our forces on this Netflix thing seeings as we appear to be the only peoples doing it, and it seems quite popular.
How long until a new update? I just discovered this and it would help me so much. I use netflix to go to sleep and with season that contain 22 minute episodes it would be amazing to not have to arise from sleep to start the next one
http://www.mattevanoff.com/2012/05/i-know-my-netflix-bookmarklet-broken/
I thought you would like to know, it looks like you’ve misspelled the word “refrence” on your website. Silly mistakes can ruin your site’s credibility. In the past I’ve used a tool like SpellingScan.com to keep mistakes off my website.
-Scott Matthews Sr.
I totally believe that could be true. I’m not currently seeing it, but I would believe it. Thanks!