Skip to content

Instantly share code, notes, and snippets.

@tiegz
Last active October 13, 2020 00:50
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tiegz/4741547 to your computer and use it in GitHub Desktop.
Save tiegz/4741547 to your computer and use it in GitHub Desktop.
Import VUDU rental history into a CSV format readable by Letterboxd.
// 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. Open the Inspector (cmd-ctrl-I on OSX), and un this script (if popups are blocked, temporarily unblock popups from Vudu in your browser)
// 3. Grab the downloaded CSV file (probably with a random name), 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.
//
// Copyright 2013-2020. Code released under the MIT license.
// Authors: Tieg Zaharia, Tyrel Souza
var csv = [["LetterboxdURI", "tmdbID", "imdbID", "Title", "Year", "Directors", "WatchedDate", "CreatedDate", "Rating", "Rating10", "Tags", "Review"].join(",")];
var offset = 0;
const perPage = 100;
function buildCSV(data) {
if (data.fundTransactionGroup) {
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];
console.log(content.title[0], transaction, transactions)
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(","));
}
}
}
}
if (data.moreBelow[0] === 'true') {
offset = offset + perPage;
requestHistory()
} else {
csv = csv.join('\n');
var uri = 'data:application/csv;name=vudu_history.csv;charset=UTF-8,' + encodeURIComponent(csv);
var win = window.open(uri, "VUDUHistory", { "titlebar": "yes" });
win.title = "VUDU History";
alert("CSV opened, please allow popups for VUDU.com if your browswer is asking right now...");
win.alert = "Import the downloaded file into letterboxd.com/import";
win.focus();
}
}
var weakSessionKey;
var userId;
try {
for (i in localStorage) {
if (i.match(/weakSessionKey$/)) {
weakSessionKey = localStorage.getItem(i)
}
if (i.match(/userID$/)) {
userId = localStorage.getItem(i)
}
}
} catch (e) {}
function requestHistory () {
if (offset > 5000) {
alert("Something went wrong! Canceling. Offset is at ", offset);
return;
}
console.log('Getting ' + perPage + ' per page at offset ', offset);
if (weakSessionKey === 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=" + perPage;
url += "&followup=purchases";
url += "&followup=totalCount";
url += "&offset=" + offset;
url += "&sessionKey=" + weakSessionKey;
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);
}
requestHistory();
@tiegz
Copy link
Author

tiegz 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.

@kemajor
Copy link

kemajor commented Sep 28, 2020

I have over 500 purchased movies from Vudu and if you count TV shows by episode that would also be a very large number. Also I would like to export a list of only the items I've purchased separate from rented items. I really appreciate your efforts for exporting Vudu items but in my case with very large libraries there will need to be more options. Is it likely these suggestions may be implemented? Thank you!

@tiegz
Copy link
Author

tiegz commented Oct 3, 2020

@kemajor I just fixed this script and added pagination, so it should theoretically get all your transactions now. I don't see any way to discern purchased vs rented items at the moment, unfortunately. This will also export TV Shows, which Letterboxd doesn't have. Cheers!

@kemajor
Copy link

kemajor commented Oct 4, 2020

Thank you very much. I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment