Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Now with less jquery
//1) go to your my-list page, and scroll to the bottom to make sure it's all loaded:
//http://www.netflix.com/browse/my-list
//2) Next, paste this in your developer tools console and hit enter:
[...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label'))
//or use this to copy the list to your clipboard:
copy([...document.querySelectorAll('.slider [aria-label]')].map(ele => ele.getAttribute('aria-label')))
@mataralhawiti

This comment has been minimized.

Copy link

@mataralhawiti mataralhawiti commented Jul 26, 2016

Thanks, very good script. Just a minor issue :
s.setAttribute('src','http://code.jquery.com/jquery.js'); >>>> should run on https not http !

@jonburger

This comment has been minimized.

Copy link

@jonburger jonburger commented Jan 23, 2017

Without jQuery, copies to clipboard - works in Chrome (uses forEach on NodeList, and built in copy function to copy to the clipboard automatically.

(function(list){document.querySelectorAll('.title_card[aria-label]').forEach(function(item){list+='\n'+item.getAttribute('aria-label');});copy(list)}(''));
@arturogutierrez

This comment has been minimized.

Copy link

@arturogutierrez arturogutierrez commented Oct 24, 2017

Netflix changed the class name, it's title-card now, so the Chrome version is:

(function(list){document.querySelectorAll('.title-card[aria-label]').forEach(function(item){list+='\n'+item.getAttribute('aria-label');});copy(list)}(''));
@dre3rd

This comment has been minimized.

Copy link

@dre3rd dre3rd commented Nov 8, 2017

Please help a complete novice. 1. Have done above and have list in text file .txt 2. Have absolutely no idea where to paste this.

Netflix
VM185:2 Search
VM185:2 Notifications
VM185:2 Daniel - Account & Settings
VM185:2 The Daughter of Dawn
VM185:2 Cowboy
VM185:2 The Good, the Bad, the Weird
VM185:2 Christmas Miracle at Sage Creek
VM185:2 Casa de mi Padre
VM185:2 Meek's Cutoff
VM185:2 Strange Empire
VM185:2 The Pinkertons
VM185:2 The Salvation
VM185:2 The Electric Horseman
VM185:2 The Timber
VM185:2 Jane Got a Gun
VM185:2 6 Guns
VM185:2 Kill or Be Killed
VM185:2 The Man from Snowy River
VM185:2 Wynonna Earp
VM185:2 Traded
VM185:2 The Homesman
VM185:2 Gallowwalkers
VM185:2 Stagecoach: The Texas Jack Story
VM185:2 Wild Wild West
VM185:2 Hell on Wheels
VM185:2 The Ridiculous 6
VM185:2 The Hateful Eight
VM185:2 Longmire
VM185:2 Wheelman
VM185:2 Sons of Anarchy
VM185:2 Shooter
VM185:2 House of Cards
(33)

@jpgringo

This comment has been minimized.

Copy link

@jpgringo jpgringo commented Jan 7, 2018

Works great… amazing, thank you!! (I had to change the "http" to "https" in the jQuery loader script to get it to work in Chrome, but otherwise flawless.

@trebor74hr

This comment has been minimized.

Copy link

@trebor74hr trebor74hr commented Jan 22, 2018

I needed to adapt the no-jquery version, added a in selector. For me this worked (I added link of the movie):

(function(){document.querySelectorAll('.title-card a[aria-label]').forEach(
    function(item){
        try {
        console.log('["'+ item.getAttribute('aria-label') + '", "https://www.netflix.com' + item.getAttribute("href").split("?")[0]+'"],')
        } catch(err) { console.log("ERROR: Ignored err", err, item)}
    })}());

producing json-like result like:

VM4342:4 ["Black Mirror", "https://www.netflix.com/watch/70264888"],
VM4342:4 ["Gabriel lglesias: I’m Sorry For What I Said When I Was Hungry", "https://www.netflix.com/watch/80117628"],
VM4342:4 ["Chris Tucker Live", "https://www.netflix.com/watch/80044731"],
VM4342:4 ["Star Trek: Discovery", "https://www.netflix.com/watch/80126024"],
VM4342:4 ["Minions", "https://www.netflix.com/watch/80033394"],
...
@ar2rsawseen

This comment has been minimized.

Copy link

@ar2rsawseen ar2rsawseen commented Apr 23, 2018

For me, this worked (without jquery):

var arr = document.getElementsByClassName("title-card");
for(var i = 0; i < arr.length; i++) {console.log(arr[i].innerText);}
@pedorich-n

This comment has been minimized.

Copy link

@pedorich-n pedorich-n commented May 7, 2018

In case somebody need real JSON, I slightly modified @trebor74hr's version

(function() {
    var list = []
    document.querySelectorAll('.title-card a[aria-label]').forEach(
        function(item) {
            try {
                list.push({
                    name: item.getAttribute('aria-label'),
                    link: "https://www.netflix.com" + item.getAttribute("href").split("?")[0]
                })
            } catch (err) {
                console.error("ERROR: Ignored err", err, item)
            }
        })
    return JSON.stringify(list);
}());
@jhult

This comment has been minimized.

Copy link

@jhult jhult commented Mar 10, 2019

I didn't try the above code snippets but this extension worked great for me: https://github.com/daltonmenezes/netflix-list-exporter

@cliffordp

This comment has been minimized.

Copy link

@cliffordp cliffordp commented Aug 5, 2019

I didn't try these snippets, but I posted https://gist.github.com/cliffordp/122c8eda56e2302926b74aec65be4363 to export Netflix's My List, Watch History, and thumbs up/down or ratings. Hope it helps someone else.

@jordan314

This comment has been minimized.

Copy link
Owner Author

@jordan314 jordan314 commented Aug 5, 2019

Oh wow, didn't realize this was so active. I updated the script to use https. I'm surprised it still works but it does. Thanks all

@chr1xm

This comment has been minimized.

Copy link

@chr1xm chr1xm commented Sep 18, 2019

Thank you help me to migrate my account :) and it worked.

@jordan314

This comment has been minimized.

Copy link
Owner Author

@jordan314 jordan314 commented Dec 11, 2019

Updated this to not use jquery. In my other gists I also made a script to export a soundcloud playlist

@joyblanks

This comment has been minimized.

Copy link

@joyblanks joyblanks commented Jan 5, 2020

Thanks! I could export all titles and then I had to figure out how to add them to my new profile.
Found a very patchy way but did the job. Hope someone will need this.

1. Login & Select your old Account -> Profile
2. Go to My List (old profile)
3. Run this code in your Browser Developer console to Export and save My List

var tmpList = (function() {
    var list = []
    document.querySelectorAll('.title-card a[aria-label]').forEach(
        function(item) {
            try {
                list.push({
                    name: item.getAttribute('aria-label'),
                    link: ("https://www.netflix.com" + item.getAttribute("href").split("?")[0]).replace('watch', 'title')
                })
            } catch (err) {
                console.error("ERROR: Ignored err", err, item)
            }
        })
    return (JSON.stringify(list));
}());
localStorage.setItem('tmpList',tmpList);

4. Logout old account
5. Login & Select your new Account -> Profile
6. Run this Code in your Browser Developer console to Import My List saved in step 3

(function(){
  var list = JSON.parse(localStorage.getItem('tmpList'))
  var counter = 0;
  function openWin(e){
    var popup;
    popup = window.open(list[e].link);
    popup.onload = function(){
      setTimeout(function(){
        if(popup.document.querySelector('.nf-flat-button-icon-mylist-add + span')){
          popup.document.querySelector('.nf-flat-button-icon-mylist-add + span').click();
          setTimeout(function(){popup.close()}, 500);
          console.log('Added', list[e].name);
        } else {
          popup.close();
          console.log('Already added', list[e].name);
        }
      }, 500)
    }
    var timer = setInterval(function() { 
      if(popup && popup.closed) {
        clearInterval(timer);
        if(list.length-1 > counter){
          openWin(++counter);
        } else {
          console.log('Added');
          localStorage.removeItem('tmpList');
        }
      }
    }, 1000);
  }
  openWin(counter)
}())

7. Done

@jordan314

This comment has been minimized.

Copy link
Owner Author

@jordan314 jordan314 commented Jan 6, 2020

@joyblanks Fancy! Thanks!

@jonathanklingberg

This comment has been minimized.

Copy link

@jonathanklingberg jonathanklingberg commented Jan 16, 2020

@joyblanks, Awesome!

@mehmet-demir

This comment has been minimized.

Copy link

@mehmet-demir mehmet-demir commented Feb 19, 2020

jhult's suggestion - "netflix-list-exporter" extension was an easier solution. Thanks.

@shahsahilj

This comment has been minimized.

Copy link

@shahsahilj shahsahilj commented Mar 27, 2020

Is there a way to transfer the viewing history from one account? I know I can export it to a file, but then how do I import it in another profile?

@kghastie

This comment has been minimized.

Copy link

@kghastie kghastie commented Apr 19, 2020

This works for me to generate a json or unquoted csv version of the titles and suggested ratings from the DVD In Queue page. (Yes, I still have a DVD account what do you want from me!?) Doesn't pull "Saved items" (the ones that aren't available at this time).

titles=[...document.querySelectorAll('#inqueueList .title.ondelhide')].map(ele => ele.text)
ratings=[...document.querySelectorAll('#inqueueList .starbar')].map(ele => ele.getAttribute('data-rating'))

titles_ratings = []
for (var i = 0; i < titles.length; i++) {
 titles_ratings.push([titles[i].replace('\\"', ''), ratings[i]]) 
}

json = JSON.stringify(titles_ratings)

csv = titles_ratings.map(function(d){
    return d.join();
}).join('\n');

Example csv output:

Hamlet,3.3
The Lion King,4.1
Westworld,4.2
Westworld,4.2
Westworld,4.2
Alien vs. Predator,2.3
@PetrusKiendys

This comment has been minimized.

Copy link

@PetrusKiendys PetrusKiendys commented Jul 2, 2020

Is there a way to transfer the viewing history from one account? I know I can export it to a file, but then how do I import it in another profile?

@shahsahilj You can't. The only reason this script works is because it scrapes DOM elements that are already exposed by the Netflix website.
To make an import script you would have to create a script to automate the reinsertion of the data. Which can be as easy as pushing it to the Netflix API if you can reverse engineer it or hope that there's an officially supported way.

TL;DR Exporting account info such as "My List" is easy.
Importing the same info is a bit more tricky.

@agwosdz

This comment has been minimized.

Copy link

@agwosdz agwosdz commented Sep 5, 2020

Thanks! I could export all titles and then I had to figure out how to add them to my new profile.
Found a very patchy way but did the job. Hope someone will need this.

1. Login & Select your old Account -> Profile
2. Go to My List (old profile)
3. Run this code in your Browser Developer console to Export and save My List

var tmpList = (function() {
    var list = []
    document.querySelectorAll('.title-card a[aria-label]').forEach(
        function(item) {
            try {
                list.push({
                    name: item.getAttribute('aria-label'),
                    link: ("https://www.netflix.com" + item.getAttribute("href").split("?")[0]).replace('watch', 'title')
                })
            } catch (err) {
                console.error("ERROR: Ignored err", err, item)
            }
        })
    return (JSON.stringify(list));
}());
localStorage.setItem('tmpList',tmpList);

4. Logout old account
5. Login & Select your new Account -> Profile
6. Run this Code in your Browser Developer console to Import My List saved in step 3

(function(){
  var list = JSON.parse(localStorage.getItem('tmpList'))
  var counter = 0;
  function openWin(e){
    var popup;
    popup = window.open(list[e].link);
    popup.onload = function(){
      setTimeout(function(){
        if(popup.document.querySelector('.nf-flat-button-icon-mylist-add + span')){
          popup.document.querySelector('.nf-flat-button-icon-mylist-add + span').click();
          setTimeout(function(){popup.close()}, 500);
          console.log('Added', list[e].name);
        } else {
          popup.close();
          console.log('Already added', list[e].name);
        }
      }, 500)
    }
    var timer = setInterval(function() { 
      if(popup && popup.closed) {
        clearInterval(timer);
        if(list.length-1 > counter){
          openWin(++counter);
        } else {
          console.log('Added');
          localStorage.removeItem('tmpList');
        }
      }
    }, 1000);
  }
  openWin(counter)
}())

7. Done

Thanks, but the code is not working for me.... Getting a cannot set property 'onload' of null

Any ideas?

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.