Kodi Community Forum

Full Version: [RELEASE] NetfliXBMC - Unofficial Netflix Add-on (Win/OSX/Linux) - Thread 2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(2015-09-23, 18:35)airberger Wrote: [ -> ]
(2015-09-23, 14:07)corona Wrote: [ -> ]Could you even just paste the working contents of default.py on http://paste.ofcode.org/ and post the link here.

http://paste.ofcode.org/36SEpTRzM7SChChqYMSAHqX

Does this work?

Looks good thanks! I'll get it in a new release soon.
(2015-09-24, 00:39)Falkor Wrote: [ -> ]Hi All!!

Long time reader but this is my first post and I hope it helps someone.

My system is an Ubuntu-gnome 14.04 and since I insatlled NetfilXBMC every time I exit Chrome (ctrl+w) it lost focus on Kodi making me select it again to get focus. (Sorry about my english by the way).

I find a workaround and I wanted to share with all of you, it is not elegant, it is not pretty, but it works for me, maybe it works for someone else.

In "default.py" I inserted a line after line number 751, just after this one:
Quote:xbmc.executebuiltin("RunPlugin(plugin://plugin.program.chrome.launcher/?url="+urllib.quote_plus(url)+"&mode=showSite&kiosk="+kiosk+profileFolder+")")

The line I inserted is:
Quote:os.system('sleep 5; while [ "$(ps -ef | grep -i "plugin.video.netflixbmc/chrome" | grep -v grep)" != "" ]; do sleep 2; done ; wmctrl -a Kodi')

With this change, every time I exit Chrome (ctrl+w) the focus is in Kodi instead of an empty desktop.

I hope this will help someone.

BTW: You must have installed wmctrl (sudo apt-get install wmctrl)

Thanks for this. It's always good to know that focus doesn't work for some people and some strategies for managing.
I'm hoping that my (soon to happen) switch to my newer webdriver module should alleviate this issue once and for all. It does it a different way to this, although it'll be worth me having another look at it as monitoring the actual browser processes like this may be more reliable.
(2015-09-24, 01:57)jimd3 Wrote: [ -> ]I use both browser.sh and netflix.lirc in this plugin.

Each time I get an upgrade, the browser.sh permissions are changed and removes the "executable" on the file.
I need to always do a chmod 755 browser.sh on each upgrade.
Is there a smarter way I can handle this?

I have edited the netflix.lirc in the plugin.video.netflixbmc directory to map the LIRC to my remote key definitions.
Each time I get an update, the file is overwritten.
This really isn't surprising.
Should I be editing this file directly or is there a preferred means of mapping the LIRC keys?

Any advice appreciated.

Jim

With regard to overwriting the lirc keys, I don't have a workaround right now.
In future this file should be copied/moved to <kodi_home>userdata/addon_data/plugin.video.netflixbmc/ and then the end user can edit it as much as desired without fear of overwriting.
Same goes for the browser script really, as people will often want to edit this.

I've actually got a little fix for the executable flag for now though, would it be possible for you to test it for me?

first, remove the executable status from the file again ( to be sure the fix below does work ) :
Code:
chmod -x browser.sh

then find this chunk in default.py
Code:
elif osLinux:
        if linuxUseShellScript:
            xbmc.executebuiltin('LIRC.Stop')
            
            call = '"'+browserScript+'" "'+url+'"';
            debug("Browser Call: " + call)
            subprocess.call(call, shell=True)
            
            xbmc.executebuiltin('LIRC.Start')
        else:
            launchChrome(url)

and replace it with:
Code:
elif osLinux:
        if linuxUseShellScript:
            # Ensure the browserScript is executable
            import stat
            st = os.stat(browserScript)
            os.chmod(browserScript, st.st_mode | stat.S_IEXEC)

            xbmc.executebuiltin('LIRC.Stop')

            call = '"'+browserScript+'" "'+url+'"';
            debug("Browser Call: " + call)
            subprocess.call(call, shell=True)

            xbmc.executebuiltin('LIRC.Start')
        else:
            launchChrome(url)

Then try starting a netflix show.
(2015-09-24, 03:22)corona Wrote: [ -> ]
(2015-09-24, 00:39)Falkor Wrote: [ -> ]Hi All!!

Long time reader but this is my first post and I hope it helps someone.

My system is an Ubuntu-gnome 14.04 and since I insatlled NetfilXBMC every time I exit Chrome (ctrl+w) it lost focus on Kodi making me select it again to get focus. (Sorry about my english by the way).

I find a workaround and I wanted to share with all of you, it is not elegant, it is not pretty, but it works for me, maybe it works for someone else.

In "default.py" I inserted a line after line number 751, just after this one:
Quote:xbmc.executebuiltin("RunPlugin(plugin://plugin.program.chrome.launcher/?url="+urllib.quote_plus(url)+"&mode=showSite&kiosk="+kiosk+profileFolder+")")

The line I inserted is:
Quote:os.system('sleep 5; while [ "$(ps -ef | grep -i "plugin.video.netflixbmc/chrome" | grep -v grep)" != "" ]; do sleep 2; done ; wmctrl -a Kodi')

With this change, every time I exit Chrome (ctrl+w) the focus is in Kodi instead of an empty desktop.

I hope this will help someone.

BTW: You must have installed wmctrl (sudo apt-get install wmctrl)

Thanks for this. It's always good to know that focus doesn't work for some people and some strategies for managing.
I'm hoping that my (soon to happen) switch to my newer webdriver module should alleviate this issue once and for all. It does it a different way to this, although it'll be worth me having another look at it as monitoring the actual browser processes like this may be more reliable.

Glad I can be of some help, but may be if I used the browser.sh script it would be cleaner, but i really didn't try that way too much.

Thank you !!!
(2015-09-25, 05:06)Falkor Wrote: [ -> ]
(2015-09-24, 03:22)corona Wrote: [ -> ]
(2015-09-24, 00:39)Falkor Wrote: [ -> ]Hi All!!

Long time reader but this is my first post and I hope it helps someone.

My system is an Ubuntu-gnome 14.04 and since I insatlled NetfilXBMC every time I exit Chrome (ctrl+w) it lost focus on Kodi making me select it again to get focus. (Sorry about my english by the way).

I find a workaround and I wanted to share with all of you, it is not elegant, it is not pretty, but it works for me, maybe it works for someone else.

In "default.py" I inserted a line after line number 751, just after this one:

The line I inserted is:

With this change, every time I exit Chrome (ctrl+w) the focus is in Kodi instead of an empty desktop.

I hope this will help someone.

BTW: You must have installed wmctrl (sudo apt-get install wmctrl)

Thanks for this. It's always good to know that focus doesn't work for some people and some strategies for managing.
I'm hoping that my (soon to happen) switch to my newer webdriver module should alleviate this issue once and for all. It does it a different way to this, although it'll be worth me having another look at it as monitoring the actual browser processes like this may be more reliable.

Glad I can be of some help, but may be if I used the browser.sh script it would be cleaner, but i really didn't try that way too much.

Thank you !!!

Ok, so I've been trying to use the browser.sh script (so I can came out with a better solution), but I cannot make goole-chorome run in kiosk mode. Any suggestions?

Remember that this is on Ubuntu 14.04.
Guys, here's a default.py that I've modified to use current useragent settings. This means that I can scrape the current Netflix url's for content. From a US netflix perspective at least, mylist is fully functional. Recents and all TV shows are partially functional.

Give it a whirl if you like and let me know if you think this is better or worse than the current default.py being used with this plugin

Dropbox link to default.py
(2015-09-24, 00:39)Falkor Wrote: [ -> ]Hi All!!

Long time reader but this is my first post and I hope it helps someone.

My system is an Ubuntu-gnome 14.04 and since I insatlled NetfilXBMC every time I exit Chrome (ctrl+w) it lost focus on Kodi making me select it again to get focus. (Sorry about my english by the way).

I find a workaround and I wanted to share with all of you, it is not elegant, it is not pretty, but it works for me, maybe it works for someone else.

In "default.py" I inserted a line after line number 751, just after this one:
Quote:xbmc.executebuiltin("RunPlugin(plugin://plugin.program.chrome.launcher/?url="+urllib.quote_plus(url)+"&mode=showSite&kiosk="+kiosk+profileFolder+")")

The line I inserted is:
Quote:os.system('sleep 5; while [ "$(ps -ef | grep -i "plugin.video.netflixbmc/chrome" | grep -v grep)" != "" ]; do sleep 2; done ; wmctrl -a Kodi')

Again, I hope this helps.

With this change, every time I exit Chrome (ctrl+w) the focus is in Kodi instead of an empty desktop.

I hope this will help someone.

BTW: You must have installed wmctrl (sudo apt-get install wmctrl)

I have noticed that making the above changes keeps the script from hidding the mouse pointer (cursor), so I figure out that the line I purposed should be running in the background.

I came up with this:
Quote:os.system('{ sleep 5; while [ "$(ps -ef | grep -i "plugin.video.netflixbmc/chrome" | grep -v grep)" != "" ]; do sleep 2; done ; wmctrl -a Kodi; } &')

instead of this:
Quote:os.system('sleep 5; while [ "$(ps -ef | grep -i "plugin.video.netflixbmc/chrome" | grep -v grep)" != "" ]; do sleep 2; done ; wmctrl -a Kodi')

Note the brackets and the "&" sign. It will now run on the background, so hiding mouse pointer is done (and then some other things.. :-D )

BTW: The browser.sh was not executing because it was not made executable (chmod +x), and kiosk mode was not working because there was already a session of google-chrome running (with my own profile)
Here's an update that works with their new website. It basically gets JSON data from both the web pages and the private REST API.

It's work in progress, but I figured I'd share it sooner rather than later in case people want to improve it or update the official add-on.

http://pastebin.com/K0LD5pLX
(2015-09-27, 23:23)ZumZen Wrote: [ -> ]Here's an update that works with their new website. It basically gets JSON data from both the web pages and the private REST API.

Cool! Does this mean it won't be quite as dependent on the exact UI layout?
(2015-09-27, 23:23)ZumZen Wrote: [ -> ]Here's an update that works with their new website. It basically gets JSON data from both the web pages and the private REST API.

It's work in progress, but I figured I'd share it sooner rather than later in case people want to improve it or update the official add-on.

http://pastebin.com/K0LD5pLX

At first glance this looks good.
Are you using the json endpoints that netflixs' own webpages are using to get show details etc? Or did you find some more elsewhere?

I would highly recommend working with a github fork of the repo, you can fork into you own free account ( https://guides.github.com/activities/forking/ ) then clone it straight into your kodi addons folder.
Then every change you make that's good just commit it to git. push to github when you've got a good set and pull-request it back to me when you've got stuff to share!

Even if you've never used git/github before it's pretty easy to pick up, and means you'll never accidentally overwrite and lose some working changes.
It also makes it really easy to send your changes over to me in a pull request to integrate into the mainline. This would also mean you get credit on the github history page for all your work ;-)

Even if you don't have a chance to use github, I definitely recommend disabling my repo or at least keep regular backups of your changes, because if I release a new version it might just overwrite all your local changes with the new download!

I'm working on large updates to the plugin myself at the moment, but haven't got to the api yet (starting with cleaning up the code, fixing ssl etc).
I'm planning on using a json api from a third party website as well as any that can be found from netflix, so your code will be quite useful for that! The end goal is to avoid scraping any website, if possible.
(2015-09-28, 01:18)corona Wrote: [ -> ]At first glance this looks good.
Are you using the json endpoints that netflixs' own webpages are using to get show details etc? Or did you find some more elsewhere?

The pages that the netflix website serves contain pointers to the REST servers. They are on the netflix.com domain, which is hardcoded for no good reason in my code. The rest of the URL comes from the page though. It seems that you need that and an authentication token from the main page.

(2015-09-28, 01:18)corona Wrote: [ -> ]I would highly recommend working with a github fork of the repo, [...]

I'm trying to avoid making this another job Smile
Sorry.

(2015-09-28, 01:18)corona Wrote: [ -> ]Even if you don't have a chance to use github, I definitely recommend disabling my repo or at least keep regular backups of your changes, because if I release a new version it might just overwrite all your local changes with the new download!

The thought occurred to me, so I have backups.

(2015-09-28, 01:18)corona Wrote: [ -> ]I'm working on large updates to the plugin myself at the moment, but haven't got to the api yet (starting with cleaning up the code, fixing ssl etc).
I'm planning on using a json api from a third party website as well as any that can be found from netflix, so your code will be quite useful for that! The end goal is to avoid scraping any website, if possible.

Do you have a specific site in mind? I couldn't find one.

I think with some effort one can figure out the layout of their data to a sufficient degree to get all of the information needed by the plugin. I've got most of that, but not all. It's a matter of monitoring the requests the pages make and then some guesswork on top of that. You'd probably still need the main web site for authentication. I wonder what the lifetime of their authentication tokens is.
(2015-09-28, 06:35)ZumZen Wrote: [ -> ]Do you have a specific site in mind? I couldn't find one.

I think with some effort one can figure out the layout of their data to a sufficient degree to get all of the information needed by the plugin. I've got most of that, but not all. It's a matter of monitoring the requests the pages make and then some guesswork on top of that. You'd probably still need the main web site for authentication. I wonder what the lifetime of their authentication tokens is.

@hstegeman and I were discussing this a good few pages back: http://forum.kodi.tv/showthread.php?tid=...pid2092521
http://beta.istreamguide.com was the best one for having some nice clean json, but they've since closed the beta site for some closed dev/testing/planning :-(

I like yidio.com for having a good json api again ( http://cf.yidio.com/ajax_base_dir_shows_...letter=All )
but it's unclear how well they support international netflix sites.

It's also quite different in that it's an aggregater of streaming services. It can be set to just display shows from netflix, or it can display shows from heaps of different services and then play them from wherever.

From my initial testing (in australia) when set to filter for netflix it only seems to show things available in your country, but then doesn't give me a netflix link to watch them. I've sent them a question about their international support.

(2015-09-28, 06:35)ZumZen Wrote: [ -> ]The pages that the netflix website serves contain pointers to the REST servers. They are on the netflix.com domain, which is hardcoded for no good reason in my code. The rest of the URL comes from the page though. It seems that you need that and an authentication token from the main page.
Yeah it's possible for third party sites to permanently link to a netflix account, yidio does this, as such it might be worth folling the network requests it uses when you go through the linking process to see if there's any netflix api exposed we could use to achieve the same goal (I doubt it),

Otherwise we do still need to script this part on the netflix site. My new webdriver module leverages selenium which means you can automate the button clicks/textbox form submissions more easily if the api endpoint can't be found. Then the cookies/session gets stored to keep logged in as long as possible (already done).
(2015-09-28, 08:19)corona Wrote: [ -> ]@hstegeman and I were discussing this a good few pages back: http://forum.kodi.tv/showthread.php?tid=...pid2092521
http://beta.istreamguide.com was the best one for having some nice clean json, but they've since closed the beta site for some closed dev/testing/planning :-(

I like yidio.com for having a good json api again ( http://cf.yidio.com/ajax_base_dir_shows_...letter=All )
but it's unclear how well they support international netflix sites.

[...]

Yeah it's possible for third party sites to permanently link to a netflix account, yidio does this, as such it might be worth folling the network requests it uses when you go through the linking process to see if there's any netflix api exposed we could use to achieve the same goal (I doubt it),

Sorry, I should have been more clear.
The REST requests to netflix all have an authentication token which looks, well, mostly random. That is supplied in the data that comes with the pages served by netflix.com/* and is put by the js code into all the async requests. It doesn't seem to be strictly necessary. I'm able to get, for example, the genre list even with an empty token. I assume that it is used for personalized information, but I don't know for sure.


Yidio looks nice. Their play links are old-style netflix play links (e.g. http://movies.netflix.com/WiMovie/80049672), which redirect to the show page instead of playing stuff.

That's really an easy fix though: www.netflix.com/watch/80049672

(2015-09-28, 08:19)corona Wrote: [ -> ]Otherwise we do still need to script this part on the netflix site. My new webdriver module leverages selenium which means you can automate the button clicks/textbox form submissions more easily if the api endpoint can't be found. Then the cookies/session gets stored to keep logged in as long as possible (already done).

As long as you have the video ID, it should be fine. I mean the whole thing is working perfectly fine for me right now.
first of all, i appreciate your efforts for having a perfect netflix experience.
i am using openelec with chromium and i am not sure if the new webdriver solution will work on openelec.
corona, will you update netflixbmc with the webdriver or make a fork so the addon will not break on openelec?
btw. is it possible to add an option to disable remote control? i am using my own solution and the dummy window interferes with it.

i tried yidio and it seems very uncomplete. i tried two netflix and one amazon shows (the returned - 2015, firefly and fear the walking dead) and they all had no links available...
(2015-09-27, 23:47)jluce50 Wrote: [ -> ]
(2015-09-27, 23:23)ZumZen Wrote: [ -> ]Here's an update that works with their new website. It basically gets JSON data from both the web pages and the private REST API.

Cool! Does this mean it won't be quite as dependent on the exact UI layout?

To some extent. There is some information that comes from JavaScript variables in their web pages. While that is layout independent, the way that the variables appear in there and their particular names could change. I doubt that will be soon though. They have to give the current platform its run for the money.

The rest of the info (genres, new arrivals, seasons, episode info) comes from their internal API which is served as JSON objects. Ideally an addon would only use that.

I think their internal API is robust (i.e. won't change soon). It's flexible, extensive and it looks like they have spent quite some effort on it. They released parts as OSS (see, for example, http://netflix.github.io/falcor/). So I think that's a safe bet for a few years.