andrewleech / plugin.video.netflixbmc

NetfliXBMC - Unofficial Netflix Add-on (Win/OSX/Linux)
http://forum.kodi.tv/showthread.php?tid=211574
GNU General Public License v2.0
56 stars 29 forks source link

TV Shows seasons and episodes #64

Open badcrc opened 8 years ago

badcrc commented 8 years ago

Seems that calls to api-global.netflix.com/desktop/odp/episodes... stoped working.

I made it work again parsing html from http://www.netflix.com/title/"+seriesID, not pretty but it works.

My changes are here: https://github.com/badcrc/plugin.video.netflixbmc

I don't dare making a PR because the code isn't pretty and i'm sure there are lots of debugs still printed, etc... anyway I hope it helps!

andrewleech commented 8 years ago

Yeah thanks, I know the whole thing is quite broken now. I've started down a path that's close to a complete rewrite to make the plugin faster and easier to maintain, with more consistent results for anyone who tries it. Once I get the new structure in place I'll be needing parsing patterns like this, any mix of alternate sources to give us a complete system will be good. It's been slow progress though with work commitments lately, been slammed. I'm hoping to move forward soon though.

krutoileshii commented 8 years ago

I figured out some of the calls so far. I am able to get a list of episodes in json so no need to hack through the actual HTML. Right now i am working on tracking down the images, descriptions for episodes, ratings and the watched flag. Do you have a place you would want it posted?

So far the best way to use the calls is the following:

Get Show ID->Get Show Description (Season list, Title, Number of Seasons) ->request season list (Season Name, Episode List)->get Episode Info. trying to get this into one call though at the moment to cut down the round trip.

krutoileshii commented 8 years ago

Take a look at the below I can likely track down the rest of the pieces for you if it will help.

I checked the current code, so far looks like you have the rest of the information. Also, IMDB might be a better source for episode descriptions and season info as well as easier to obtain.

Call to retrieve Show Information.

post method to the following URI: http://www.netflix.com/api/shakti/ebd809fd/pathEvaluator?withSize=true&materialize=true&model=harris&fallbackEsn=WWW

Note: the ebd809fd part changes depending on who you are. it can be parsed off the main page however.

Call:

   "paths":[
      [  
         "videos",
         [  
            70153404
         ],
         [  
            "availability",
            "synopsis",
            "episodeCount",
            "info",
            "maturity",
            "runtime",
            "seasonCount",
            "releaseYear",
            "userRating",
            "watched",
            "seasonList",
            "current"
         ]

      ]  
   ],

   "authURL":"1447121937288.B3WL/SujIt/5twW39Yaw/pN795o="
}

Return:

{
    "value": {
        "$size": 622,
        "size": 622,
        "videos": {
            "70153404": {
                "$size": 622,
                "size": 622,
                "availability": {
                    "isPlayable": true,
                    "$type": "leaf",
                    "$size": 29,
                    "size": 29
                },
                "info": {
                    "narrativeSynopsis": "Love, laughter and the best friends you could ask for. Just like real life. But with really nice apartments.",
                    "evidence": {
                        "type": "hook",
                        "priority": 2,
                        "value": {
                            "kind": "TvRatings",
                            "text": "This smash-hit sitcom made stars of its six leads and finished in primetime TV's top 10 every season."
                        }
                    },
                    "message": null,
                    "$type": "leaf",
                    "$size": 320,
                    "size": 320
                },
                "maturity": {
                    "rating": {
                        "value": "TV-14",
                        "maturityDescription": "Parents strongly cautioned. May be unsuitable for children ages 14 and under.",
                        "maturityLevel": 90,
                        "reasons": null
                    },
                    "$type": "leaf",
                    "$size": 165,
                    "size": 165
                },
                "runtime": {
                    "$type": "sentinel",
                    "value": null,
                    "$size": 28,
                    "size": 28
                },
                "seasonCount": 10,
                "releaseYear": 2003,
                "synopsis": "Love, laughter and the best friends you could ask for. Just like real life. But with really nice apartments.",
                "episodeCount": 235,
                "userRating": {
                    "average": 3.8860173,
                    "predicted": 2.8,
                    "userRating": null,
                    "type": "star",
                    "$type": "leaf",
                    "$size": 74,
                    "size": 74
                },
                "current": [
                    "videos",
                    "70274223"
                ],
                "watched": true
            },
            "$size": 622,
            "size": 622
        }
    },
    "paths": [
        [
            "videos",
            [
                70153404
            ],
            [
                "availability",
                "synopsis",
                "episodeCount",
                "info",
                "maturity",
                "runtime",
                "seasonCount",
                "releaseYear",
                "userRating",
                "watched",
                "seasonList",
                "current"
            ]
        ]
    ]
}

This gives you the most info to get episodes.

Next call should be the following (since we now have the episode count) which will return a json object with all of the seasons and their ID's. Still trying to figure out how to add episode count to this.

   "paths":[
      [  
         "videos",
         [  
            70153404
         ],
         [  
            "seasonList"
         ],
         [
            70153404,
            "seasonList",
            {
                "from":0,
                "to":9
            }
         ]
      ]  
   ],

   "authURL":"1447121937288.B3WL/SujIt/5twW39Yaw/pN795o="
}

Then we can just request the following for each season and get picture/description/etc for each episode

   "paths":[  
      [  
         "seasons",
         60030455,
         "episodes",
         {  
            "from":-1,
            "to":40
         },
         [  
            "summary",
            "synopsis",
            "title",
            "runtime",
            "bookmarkPosition"
         ]
      ],
      [  
         "seasons",
         60030455,
         "episodes",
         {  
            "from":-1,
            "to":40
         },
         "interestingMoment",
         "_260x146",
         "jpg"
      ],
      [  
         "seasons",
         60030455,
         "episodes",
         "summary"
      ]
   ],
   "authURL":"1447125392080.6XOcbOumZh4T0/A+H7n6lLobi9k="
}

this is way easier to parse as you get json and links to images as well at the same time which we can cache.

andrewleech commented 8 years ago

That looks good! Yes I'm going to be putting a strong emphasis on finding json api's for as much as possible, we really need to avoid scraping html as much as possible.

On a related note, a google search of "netflix api shakti" does bring up some other useful looking links, like: https://gist.github.com/hubgit/2019f4a3eaaa25bcbe12

krutoileshii commented 8 years ago

I've been playing around with Python trying to get a standalone class to manage retrieving information. That way we could keep it separate from the actual cashing and display logic. Might be easier to use it that way and possibly connect other sites like Hulu into the same plugin at some point

andrewleech commented 8 years ago

Absolutely, I'm restructuring the code to work that way already. My sbs addon is set up that way and it makes the code far easier to test and maintain.

krutoileshii commented 8 years ago

Is it in your testing repo? I'd love to get a pull of it

andrewleech commented 8 years ago

No not yet, it's too early days to have anything to test. I was already working on changing the chrome/browser interactions before the netflix api stuff broke so I want to finish cleaning that up before I can really get onto the netflix comms.

Once the new structure is done I'll certainly get it online and shared, such that anyone else trying to help like you can work in the new layout to make merges easy.

krutoileshii commented 8 years ago

I'll try to track down anything else of use for the time being then like getting lists and stuff.

andrewleech commented 8 years ago

If you look back a good few pages on the forum (around page 71 I think) a couple if us were looking at various third party aggregator sites whose APIs could be used to get some Netflix json data, I should compile the options into a list somewhere. On 11 Nov 2015 3:49 pm, "krutoileshii" notifications@github.com wrote:

I'll try to track down anything else of use for the time being then like getting lists and stuff.

— Reply to this email directly or view it on GitHub https://github.com/andrewleech/plugin.video.netflixbmc/issues/64#issuecomment-155662292 .

krutoileshii commented 8 years ago

That's the thing though, Netflix already provides about 90% of the data. images,icons,actors,directors,descriptions,ratings,watched/not watched. just need the correct API call and it's extremely small size wise and fast.

pi-anl commented 8 years ago

Oh absolutely, anything that can come from Netflix is best, last I looked it seemed some of that would require js processing as opposed to straight json. If I finish what I'm doing with the playback engine we'll be able to do arbitrary js processing as well though which will help. On 11 Nov 2015 4:54 pm, "krutoileshii" notifications@github.com wrote:

That's the thing though, Netflix already provides about 90% of the data. images,icons,actors,directors,descriptions,ratings,watched/not watched. just need the correct API call and it's extremely small size wise and fast.

— Reply to this email directly or view it on GitHub https://github.com/andrewleech/plugin.video.netflixbmc/issues/64#issuecomment-155675135 .

IMPORTANT NOTE. If you are NOT AN AUTHORISED RECIPIENT of this e-mail, please contact Planet Innovation Pty Ltd by return e-mail or by telephone on +613 9945 7510. In this case, you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. This e-mail and any attachments are confidential and may contain legally privileged information and/or copyright material of Planet Innovation Pty Ltd or third parties. You should only re-transmit, distribute or commercialise the material if you are authorised to do so. Although we use virus scanning software, we deny all liability for viruses or alike in any message or attachment. This notice should not be removed.

krutoileshii commented 8 years ago

So far I really haven't ran into any JS being required. Does require some parsing of the page when it initially loads to get the server hex, and Shakti API reference.

Do you have a rough list of what information and actions you need? I could see which ones I can track down. Also, there is a way to control the player through JavaScript but that one would definitely require JS I think. That could be separated into an actual chrome plugin though to interact with the player through the OS layer directly.

andrewleech commented 8 years ago

No I'm not really sure yet.

JS player interactions are already being done, that's how I handle remote control interactions for playback on the SBS plugin. I've got no issue injecting/running JS on demand once the chrome window is displayed. I'm avoiding going down the chrome plugin route again to make it easier to keep all control code in one place. ps. the current released addon includes my chrome plugin for playback control.

On 12/11/2015 3:14 PM, krutoileshii wrote:

So far I really haven't ran into any JS being required. Does require some parsing of the page when it initially loads to get the server hex, and Shakti API reference.

Do you have a rough list of what information and actions you need? I could see which ones I can track down. Also, there is a way to control the player through JavaScript but that one would definitely require JS I think. That could be separated into an actual chrome plugin though to interact with the player through the OS layer directly.

— Reply to this email directly or view it on GitHub https://github.com/andrewleech/plugin.video.netflixbmc/issues/64#issuecomment-155993375.

krutoileshii commented 8 years ago

I am working on getting the following calls nailed down:

Currently just compiling a giant file with calls/replies and what's required. I will share it once it gets closer.