Ricardo / IMDb "My Movies" enhancer

The script doesn't recognize movies that have a double quote character.

For example:
http://www.imdb.com/title/tt0095675/
Mujeres al borde de un ataque de "nervios" (1988)

A fragment from an exported csv:
"1753","tt0095675","Wed Dec 28 00:00:00 2011","","","Mujeres al borde de un ataque de "nervios","Feature Film","Pedro Almodóvar","5","7.6","90","1988","comedy, drama","21371","1988-03-14","http://www.imdb.com/title/tt0095675/"

I assume the issue is with the regex from the function downloadOK, which doesn't expect badly formed CSVs from IMDb:
var regex = /"tt[0]*(\d+)","[^"]*","[^"]*","[^"]*","[^"]*","[^"]*","[^"]*","([^"]*)","([^"]*)"/;

This change seems to help (unless there's a movie with a title like "Breaking", Bad CSVs, in which case the regex will probably need to match whole lines up to the line break):
var regex = /"tt[0]*(\d+)","[^"]*","[^"]*","[^"]*",".*?","[^"]*","[^"]*","([^"]*)","([^"]*)"/;

Re: @monk-time:
Nice catch, monk-time! Thanks for the great bug report!

Yes, I was lazy an naive, so I trusted that IMDb would always produce a valid CSV file. It doesn't. So I changed the code from using regex to something hopefully more robust and legible. At first it seemed to work fine, but then I found another problem with the IMDb data (notice the line feed after "Morto":
"798","tt0365748","Thu Feb 16 11:00:00 2006","Wed Aug 10 20:05:39 2011","Todo Mundo Quase Morto (ou Zombies Party - Uma Noite... de Morte?)","Shaun of the Dead","Feature Film","Edgar Wright","10","8.0","99","2004","comedy, horror","330366","2004-03-29","http://www.imdb.com/title/tt0365748/"

Now this will cause the following output in the console:

[!] 5 fields in "798","tt0365748","Thu Feb 16 11:00:00 2006","Wed Aug 10 20:05:39 2011","Todo Mundo Quase Morto [!] 12 fields in (ou Zombies Party - Uma Noite... de Morte?)","Shaun of the Dead","Feature Film","Edgar Wright","10","8.0","99","2004","comedy, horror","330366","2004-03-29","http://www.imdb.com/title/tt0365748/" [X] Error getting IMDb const from: (ou Zombies Party - Uma Noite... de Morte?)","Shaun of the Dead","Feature Film","Edgar Wright","10","8.0","99","2004","comedy, horror","330366","2004-03-29","http://www.imdb.com/title/tt0365748/"

Well, I don't think it's worth working around all possible CSV problems, so I think I'll try to submit a bug report to IMDb. As lazy as I am, I noticed that the code still works for me even with the error above, but let me know if you have any problem.

FIY, here are the changes I've made:

  var lines = request.responseText.split("\n");
  var res, movieCode;
  for (var i=0; i < lines.length; i++) {
     if (lines[i].length < 50) continue;
     fields = lines[i].split('","');
     // 00:position   | 06:Title type    |12:Genres                       
     // 01:const      | 07:Directors     |13:Num. Votes
     // 02:created    | 08:You rated     |14:Release Date (month/day/year)
     // 03:modified   | 09:IMDb Rating   |15:URL
     // 04:description| 10:Runtime (mins)|
     // 05:Title      | 11:Year          |
     if (fields.length != 16) console.warn(fields.length + " fields in " + lines[i]);
     var tt = fields[1];
     if (tt == 'const') continue; // skip first line of csv file
     var ratingMine = fields[8];
     var ratingIMDb = fields[9];
     if (tt.substr(0,2) != 'tt') {
        console.error("Error getting IMDb const from: "+lines[i]);
        continue;
     }
     ttNum = parseInt(tt.substr(2));

     // I "encode" the movie number with "base 36" to save memory
     movieCode = ttNum.toString(36);
     myLists[idx].movies[movieCode] = {m:ratingMine, i:ratingIMDb};
  }