Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tyrelsouza/ca482257e3fd761d15850319881bc31d to your computer and use it in GitHub Desktop.
Save tyrelsouza/ca482257e3fd761d15850319881bc31d to your computer and use it in GitHub Desktop.
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment