Last active
August 14, 2022 18:26
-
-
Save olifante/17aa76476be5eeb23c02611e4b63547d to your computer and use it in GitHub Desktop.
Export your Netflix ratings as a JSON file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When viewing your Netflix activity at https://www.netflix.com/MoviesYouveSeen | |
// there's a "Download All" button at the bottom that allows you to export | |
// your entire viewing history as a CSV file. | |
// Unfortunately there is no equivalent button to export your ratings. | |
// This short JavaScript fragment lets you export your ratings as a JSON file. | |
// Just navigate to the ratings page, open your browser's Developer Tools, | |
// select the Console tab and paste this fragment. After it has run, you should | |
// be able to copy the output and save it into a file with the ".json" | |
// extension. | |
let ratings = {}; | |
document.querySelectorAll(".retableRow").forEach(function (el, key, parent) { | |
let movie = el.querySelectorAll(".title a")[0]; | |
// The href should be similar to this: /title/60023642 | |
let ID = movie.getAttribute("href").split("/")[2]; | |
let movieURL = `https://www.netflix.com/title/${ID}`; | |
let title = movie.innerHTML; | |
let rating, ratingDescription; | |
// The "arialabel" attribute for the select rating should be one of these: | |
// "Already rated: thumbs down (click to remove rating)" | |
// "Already rated: thumbs up (click to remove rating)" | |
// "Already rated: thumbs way up (click to remove rating)" | |
let ratingElement = el.querySelectorAll("[arialabel^='Already rated:']"); | |
if (ratingElement.length > 0) { | |
rating = ratingElement[0].getAttribute("data-rating"); | |
ratingDescription = ratingElement[0] | |
.getAttribute("arialabel") | |
.slice(15, -25); | |
} | |
ratings[ID] = { title, rating, ratingDescription, movieURL }; | |
}); | |
console.log(JSON.stringify(ratings, null, 2)); | |
// Sample output: | |
// { | |
// "60023642": { | |
// "title": "Spirited Away", | |
// "rating": "3", | |
// "ratingDescription": "thumbs way up", | |
// "movieURL": "https://www.netflix.com/title/60023642" | |
// } | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment