Part 2: A simple script to pull information


  • administrators

    At a very basic level the first thing you need to do is authenticate with your Netflix account, once this is done you can use a combination of the Netflix generated cookie data (will show you how to get this shortly) and the pathEvaluator url

    https://www.netflix.com/api/shakti/0feb190f/pathEvaluator?withSize=true&materialize=true&model=harris
    

    to interact with the API. There are a variety of ways you can pull the cookie information you need. As the cookie data lasts for weeks, I have just been grabbing it from the response headers. To do this, inspect the Netflix web-page as we did in Part 1, click on the pathEvaluator url, click on 'Headers' and under Request Headers copy the cookie data all in one block. (That is the block of data directly after Cookie: <this data>).

    0_1487511066018_cookie.JPG

    Armed with the pathEvaluator url and our cookie we can now use this information to pull data with our script.

    The basic script I am using for this tutorial is written in python, but the simple tenants hold true for whatever scripting language you choose.

    I am assuming that you have python installed so that is not going to be relevant to this tutorial.

    Without further ado here is the script:

    #!/usr/bin/python
    import requests
    import json;
    
    cookie='<insert your cookie details here>';
    
    headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0',
    'Cookie':cookie,
    'Accept':'application/json, text/javascript, */*',
    'Accept-Language':'en-GB,en;q=0.5',
    'Accept-Encoding':'gzip, deflate, br',
    'Content-Type':'application/json',
    'DNT':'1',
    'Referer':'https://www.netflix.com'}
    
    genres='0,"to":1'
    rmax='5'
    base='[["newarrivals",{"from":'+genres+'},{"from":0,"to":'+rmax+'},["title","availability"]],["newarrivals",{"from":'+genres+'},{"from":0,"to":'+rmax+'},"boxarts","_342x192","jpg"]]';
    data='{"paths":'+base+'}'
    
    #use the pathEvaluator from your session here
    url='https://www.netflix.com/api/shakti/blah/pathEvaluator?withSize=true&materialize=true&model=harris';
    
    response=requests.post(url,data=data,headers=headers)
    
    rjson=response.json()
    
    videos=rjson['value']['videos']
    for vid in videos:
        if vid.isnumeric():
            vo=videos[vid]
            title=vo['title']
            boxart=vo['boxarts']['_342x192']['jpg']['url']
            isplayable=vo['availability']['isPlayable']
            retjson='{"netflixid":"'+str(vid)+'","title":"'+str(title)+'","playable":'+str(isplayable)+',"boxart":"'+str(boxart)+'"}';
            print retjson
    
    
    

    This script could be a lot more concise but I wanted to make it as simple as possible so its clear exactly what it is doing. If there are any questions or suggestions please reply to this thread.

    good luck!
    -admin



  • Thanks for this, it was very helpful. Just a couple of questions.

    How do you get all the available boxart/image sizes for a title/id (or, if you can't poll them, what are the standard sizes/names)?

    What is less "intrusive", doing individual API calls for different titles or combining multiple ID's/titles in as fewer API calls as possible (for example, requesting availability info for a dozen titles from the database)?


  • administrators

    If you are getting lots of details on a title, episodes etc I would query 1 title at a time as the response times get poorer as you stack titles.

    In regard to the boxart, there is no way that I can work out on how to 'dump' all the different formats. What I have is pieced together over months of trial and error.

    Depending on how well these posts are received, I may do an additional appendix of different queries including boxart/image details.

    stay tuned

    -admin



  • What's the method for the 166x233 boxart? That's the only one I actually need, but it's used on by their windows app so I can't inspect it in Chrome.



  • Also I would gladly knew the answer to this question



  • @hunterdaver
    One of the ways I've found is to use the Windows 8.1 Store app API at

    https://api-global.netflix.com/win/2.20/get?method=get&path=URLENCODED_PATH&format=json&progressive=true&languages=en-US
    

    Requesting the path ["shows","80133311","browse"] will return:

    {
    	"path": ["shows",
    	"80133311",
    	"browse"],
    	"value": {
    		"title": "Riverdale",
    		"box": "http://art-2.nflximg.net/64e83/a6af224ff11187c2cbfb82d996864b68f4864e83.jpg"
    	}
    }
    


  • @admin said in Part 2: A simple script to pull information:

    lot more concise but I wanted to ma

    I would like to pull just the titles /subtitle/he for example.
    i'd like to pull all title in that case

    how can it be done?



  • @FrankieD Thank you very much for your help :) I have another question on how to download information on the availability of subtitles and languages? I can see this information appears in the source page. Is there a way to download the information from the API?



  • @hunterdaver Subtitle and language info is available on the standard browser API described in the first post. The API call when you open a single item looks something like this:

    [["videos",80097003,["availability","synopsis","queue","episodeCount","info","maturity","runtime","seasonCount","releaseYear","userRating","numSeasonsLabel","bookmarkPosition","watched"]]
    

    Add "subtitles" and "audio" to the this list. It used to be there until a few days (weeks?) ago, but for some reason they removed the language info and availability from the detailed info page.


 

Looks like your connection to uNoGS Forum was lost, please wait while we try to reconnect.