Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import VUDU rental history into a CSV format readable by Letterboxd. Currently only grabs up to 100 items.
// Run this in the browser bar: var el = document.createElement("script"); el.src=URL; document.body.appendChild(el);
//
// 1. Login to http://my.vudu.com
// 2. Run this script (if popups are blocked, temporarily unblock popups from Vudu in your browser)
// 3. Grab the downloaded CSV file, and load at http://letterboxd.com/import
//
// How it works: this script is inserted into the Vudu page via a bookmarklet, grabs your session key, and
// makes a call to Vudu's api. Then it parses the response and creates a CSV, which it then opens in a page as a data-uri.
function buildCSV(data) {
var csv = [];
csv.push(["LetterboxdURI", "tmdbID", "imdbID", "Title", "Year", "Directors", "WatchedDate", "CreatedDate", "Rating", "Rating10", "Tags", "Review"].join(","));
for(var g = 0; g < data.fundTransactionGroup.length; g++) {
transactions = data.fundTransactionGroup[g].fundTransactions[0].fundTransaction;
for (var t = 0; t < transactions.length; t++) {
if (transactions[t].purchase) {
transaction = transactions[t];
content = transaction.purchase[0].content[0];
csv.push([
"", // "LetterboxdURI"
"", // "tmdbID"
"", // "imdbID"
content.title[0].replace(/'/, "\\'"), // "Title"
content.releaseTime[0].substr(0,4), // "Year"
"", // "Directors"
transaction.purchase[0].completedTime[0].substr(0, 10), // "WatchedDate"
transaction.purchase[0].purchaseTime[0].substr(0, 10), // "CreatedDate"
"", // "Rating"
"", // "Rating10"
"", // "Tags"
"", // "Review"
].join(","));
}
}
}
csv = csv.join('\n');
var uri = 'data:application/csv;charset=UTF-8,' + encodeURIComponent(csv);
var win = window.open(uri, "VUDUHistory", {"titlebar":"yes"});
win.title = "VUDU History";
win.alert = "Import the downloaded file into letterboxd.com/import";
win.focus();
}
try {
var sesh = document.cookie.match(/myvudu.sessionKey=([^;]*);/)[1];
var userId = document.cookie.match(/myvudu.userId=([^;]*);/)[1];
} catch (e) {}
if (sesh === undefined || userId === undefined) {
alert('Login and try again!');
} else {
var url = accountConfig.secureApi;
url += "?format=application/json";
url += "&callback=buildCSV";
url += "&_type=fundTransactionGroupSearch";
url += "&accountId=" + userId;
url += "&count=100";
url += "&followup=purchases";
url += "&followup=totalCount";
url += "&offset=0";
url += "&sessionKey=" + sesh;
url += "&sortBy=-transactionTime";
url += "&transactionState=pending";
url += "&transactionState=reserved";
url += "&transactionState=accepted";
url += "&transactionState=canceledAfterClose";
}
var script_element = document.createElement('script');
script_element.type = 'text/javascript';
script_element.async = true;
script_element.src = url;
document.body.appendChild(script_element);
@tiegz

This comment has been minimized.

Copy link
Owner Author

commented Feb 9, 2013

Steps:

  1. Login to http://my.vudu.com
  2. Enter this code into the url bar (check url bar for popup warnings if nothing happens, and temporarily allow popups):
javascript:var%20el%20%3D%20document.createElement%28%27script%27%29%3B%20el.src%3D%27https%3A//gist.github.com/tiegz/4741547/raw/f5c434e5f08eb9f5f324229a340952537ad18d95/generate_letterboxd_csv_from_vudu.js%27%3B%20document.body.appendChild%28el%29%3B

(ensure the javascript: part doesn't get cut off when you paste it)
4. After a few seconds look for the file in your downloads folder, and import it at http://letterboxd.com/import

Note: this only gets up to 100 items. Leave a note if you have more than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.