Jump to content
hstamas

Netflix integration?

Recommended Posts

hstamas

I know it’s been requested a few times before but now that Kodi can do it any way we can do the same thing natively in Emby?

 

https://forum.kodi.tv/showthread.php?tid=329767

 

I would love to have all my media including Netflix streams all managed within Emby itself.

  • Like 2

Share this post


Link to post
Share on other sites
Luke

It's not really Netflix approved though right?

Share this post


Link to post
Share on other sites
hstamas

It's not really Netflix approved though right?

I believe it is @@Luke. All DRM rights are being honored as far as I can tell. You need to log in to watch and once logged in, Netflix sends you a confirmation that you’ve logged in to a “device” for playback.

Edited by hstamas

Share this post


Link to post
Share on other sites
VladTepz

It's not really Netflix approved though right?

 

It is not Netflix approved, it is a workaround, and may break at anytime. Although both the Netflix & Amazon Prime apps do work really well.

 

That said, it does use proper DRM and you do need a proper Netflix account. So for the time being, Netflix & Amazon are allowing it.

 

 

The biggest issue with these addons is the use of the Widevine Library that is needed for non ARM Systems to support the DRM. I believe there is no proper/legal way to repackage the Widevine Library into Emby and would need the user to manually acquire it.

 

This is currently done in Kodi either manually, or through a 3rd party helper script that either extracts the library from Chrome or Firefox, as Kodi can't legally include this library in it's install setup.

Perhaps one day Netflix/Amazon/Etc.. will supply them with a proper/official DRM solution in the future..., hopefully...


BTW, a big +1 for me to see this implemented in Emby in the future.

  • Like 1

Share this post


Link to post
Share on other sites
VladTepz

Also, it’s only a client side solution, and not all Clients support Widevine. (Apple, Xbox, Etc..) so because of the DRM, it most likely couldn’t be implemented into the server without doing the same thing PlayOn does. i.e... Transcode the stream to pass it to the clients.

Edited by VladTepz

Share this post


Link to post
Share on other sites
xnappo
Posted (edited)

Replying to an old topic, but I do kinda integrate Netflix and Amazon into my Emby library in a hacky way that might be something that can be expanded upon.

1. I have scripts that create dummy video files with Netflix or Prime in the name for shows on Amazon

2. Emby scans them and adds them as normal

3. I have a script on my NVidia Kodi that launches Netflix or Amazon whenever these are played and marks as watched correctly

It does not automatically launch that show, just the app, but it is good enough for my purposes of just keeping everything we are watching under the Emby umbrella.

What would be nice for me would be a way to do #1 from inside of Emby.

xnappo

Edited by xnappo
  • Like 1

Share this post


Link to post
Share on other sites
Luke
3 hours ago, xnappo said:

Replying to an old topic, but I do kinda integrate Netflix and Amazon into my Emby library in a hacky way that might be something that can be expanded upon.

1. I have scripts that create dummy video files with Netflix or Prime in the name for shows on Amazon

2. Emby scans them and adds them as normal

3. I have a script on my NVidia Kodi that launches Netflix or Amazon whenever these are played and marks as watched correctly

It does not automatically launch that show, just the app, but it is good enough for my purposes of just keeping everything we are watching under the Emby umbrella.

What would be nice for me would be a way to do #1 from inside of Emby.

xnappo

For #1 couldn't you just have an external tool create create stub files or strm files?

Share this post


Link to post
Share on other sites
xnappo
1 hour ago, Luke said:

For #1 couldn't you just have an external tool create create stub files or strm files?

Sure, that is what my scripts do, but it is fairly manual.  Maybe it is something better done as a Sonarr addin now that I think about it, might look into that.

Share this post


Link to post
Share on other sites
Luke

#3 I would think could be accomplished by adding some additional flexibility to external players.

Share this post


Link to post
Share on other sites
cayars

Do you mean changing the external players or adding some additional flexibility in Emby to use the external players?

It could be cool if Emby saw an strm file with "NETFLIX" in it to launch the netflix app on that device sort of how we launch Youtube on Android TV.  If we could pass the file link even better.

This could be done for Netflix, Amazon Prime, Hulu for example as they are 3 of the big ones. That would make for some interesting integration things that could be done.

I'd use something like this for some TV series especially to see if I like the series before I'd want to load on my system or to make it easier for the Daughter to get to shows like "Love Island" that's on Hulu.

Share this post


Link to post
Share on other sites
horstepipe
Posted (edited)

@xnappo

would you mind to share your work/your scripts? I thought about something similar awhile ago but didn’t find the time to start yet.

How did you accomplish to create all files without getting an API ban? How do you keep the files up to date (content is being removed regularly)?

 

 

Edited by horstepipe
  • Like 1

Share this post


Link to post
Share on other sites
xnappo
Posted (edited)
12 hours ago, cayars said:

It could be cool if Emby saw an strm file with "NETFLIX" in it to launch the netflix app on that device sort of how we launch Youtube on Android TV.  If we could pass the file link even better.

Yeah, this is pretty much exactly what my little Kodi hack does, I just use a dummy video file instead of a strm though.  It used to be on AndroidTV you could link to a specific video, then they broke that and you could link to a search, but now you can only launch the app from what I can tell (for Netflix and Prime at least).

        if "Netflix_S" in str(self.getPlayingFile(self)):
            xbmc.sleep(400)
            while(self.isPlaying() == True): # Force to end to mark watched in Emby
                self.seekTime(10)
                xbmc.sleep(200)
            app      = 'com.netflix.ninja'
            cmd = 'StartAndroidActivity("%s", "%s", "%s", "%s")' % (app, intent, dataType, dataURI)
            xbmc.executebuiltin(cmd)
3 hours ago, horstepipe said:

@xnappo

would you mind to share your work/your scripts? I thought about something similar awhile ago but didn’t find the time to start yet.

How did you accomplish to create all files without getting an API ban? How do you keep the files up to date (content is being removed regularly)?

You are overestimating my level of automation lol.  I use Sonaar to keep track of shows I am watching - just as a calendar.  I manually add the files using a script when they are available, Emby takes care of all the metadata and 'watched' states.  This is the bit I think could be done with a Sonaar addon.

#!/bin/bash

read -p 'Starting season: ' startseason
read -p 'Ending season: ' endseason

for ((season = $startseason; season <= $endseason; season++)); do
        niceseason=$(printf "%02d" $season)
        mkdir "Season $niceseason"
        read -p "Epsiodes in Season ${season} :" episodes
        for ((episode = 1; episode <= $episodes; episode++)); do
                niceepisode=$(printf "%02d" $episode)
                echo Netflix_S${niceseason}E${niceepisode}.mp4
                cp ../../netflix_intro.mp4 "Season $niceseason/Netflix_S${niceseason}E${niceepisode}.mp4"
        done
done

 

Edited by xnappo

Share this post


Link to post
Share on other sites
xnappo

Also I realize this is super corner-case and not likely to get support inside Emby, but I think the way to do it would be to allow 'virtual episodes' to be turned on only at the series level and add the concept of virtual episode providers when 'air date' has past.

Share this post


Link to post
Share on other sites
xnappo
Posted (edited)

@horstepipe - likely just talking to myself here, but I did add Sonarr based automation to my setup.  Chron job run at 6am plus this Python script.  Top bit of script needs to be modified for your needs, I will update this post if I find any bugs.

import requests
import json
import os.path
from os import path
from shutil import copyfile
from datetime import date
from datetime import timedelta

# Modify below for your setup
basePath = "../test" # Path to where your TV Shows are stored, you can use a temp dir for testing
host = "localhost:6666" # URL : PORT to your Sonarr
apiKey = "123456" # Get this from Sonarr Settings -> General
daysBack = 0 # Used for debug to get more episodes
daysAhead = 1 # Used for debug to get more episodes, one is actually for current day.
startDate = date.today() - timedelta(daysBack) 
endDate = date.today() + timedelta(daysAhead)
netflixDummy = "../netflix_intro.mp4" # Name of the stub video file for Netflix
amazonDummy = "../amazon_intro.mp4" # Name of the stub video file for Amazon Prime
# End of modify section

url = "http://" + host + "/api/calendar/?apikey=" + apiKey + "&unmonitored=true&start=" + startDate.strftime("%Y-%m-%d") + "&end=" + endDate.strftime("%Y-%m-%d")

jsonResponse = requests.get(url).json()
for item in jsonResponse:
    if "Netflix" in item['series']['network'] or "Amazon" in item['series']['network']:
        if "Netflix" in item['series']['network']:
            dummyFile = netflixDummy
        else:
            dummyFile = amazonDummy
        showSeason = "{:02d}".format(item['seasonNumber'])
        showEpisode = "{:02d}".format(item['episodeNumber'])
        print ("Adding: " + item['series']['title'] + " " + "S" + showSeason + "E" + str(item['episodeNumber']) + " from " + item['series']['network'])
        # Make directories/files as needed
        if not path.exists(basePath + "/" + item['series']['title']):
            os.mkdir(basePath + "/" + item['series']['title'])
        if not path.exists(basePath + "/" + item['series']['title'] + "/Season " + showSeason):
            os.mkdir(basePath + "/" + item['series']['title'] + "/Season " + showSeason)
        if not path.exists(basePath + "/" + item['series']['title'] + "/Season " + showSeason + "/" + item['series']['network'] + "_S" + showSeason + "E" + showEpisode + ".mp4"):
            copyfile(dummyFile, basePath + "/" + item['series']['title'] + "/Season " + showSeason + "/" + item['series']['network'] + "_S" + showSeason + "E" + showEpisode + ".mp4")

 

Edited by xnappo
Switched to JSON instead of iCal
  • Thanks 1

Share this post


Link to post
Share on other sites
xnappo
Posted (edited)

Here is another Python script to replace my earlier shell script to add series that have already aired.  This one also uses Sonarr for the data - so add the show to Sonarr and set it to 'unmonitored'.  Then run the script with a reasonable subset of the series title and it will make dummy files for all the seasons/episodes.  

import requests
import json
import sys
import os.path
from os import path
from shutil import copyfile

# Modify below for you setup
basePath = "../test" # Path to where your TV Shows are stored, you can use a temp dir for testing
host = "localhost:6666" # URL : PORT to your Sonarr
apiKey = "123456" # Get this from Sonarr Settings -> General
netflixDummy = "../netflix_intro.mp4" # Name of the stub video file for Netflix
amazonDummy = "../amazon_intro.mp4" # Name of the stub video file for Amazon Prime
# End of modify section

url = "http://" + host + "/api/series/?apikey=" + apiKey
try: sys.argv[1]
except:
    print ('Usage: addVirtual.py <partial title of show to add>')
    sys.exit()

jsonResponse = requests.get(url).json()
found = False
for item in jsonResponse:
    if sys.argv[1].lower() in item['title'].lower():
        found = True
        if "Netflix" in item['network'] or "Amazon" in item['network']:
            if not path.exists(basePath + "/" + item['title']):
                os.mkdir(basePath + "/" + item['title'])            
            if "Netflix" in item['network']:
                dummyFile = netflixDummy
            else:
                dummyFile = amazonDummy
            for season in range (1, item['seasonCount']+1):
                showSeason = "{:02d}".format(season)
                if not path.exists(basePath + "/" + item['title'] + "/Season " + showSeason):
                    os.mkdir(basePath + "/" + item['title'] + "/Season " + showSeason)                
                for episode in range (1, item['seasons'][season]['statistics']['totalEpisodeCount']+1):
                    showEpisode = "{:02d}".format(episode)
                    print ("Adding: " + item['title'] + " " + "S" + showSeason + "E" + showEpisode + " from " + item['network'])
                    if not path.exists(basePath + "/" + item['title'] + "/Season " + showSeason + "/" + item['network'] + "_S" + showSeason + "E" + showEpisode + ".mp4"):
                        copyfile(dummyFile, basePath + "/" + item['title'] + "/Season " + showSeason + "/" + item['network'] + "_S" + showSeason + "E" + showEpisode + ".mp4")
if found == False:
    print ('Series: ' + sys.argv[1] + ' not found!  Please use addVirtual.py with one of the following series:\n')
    for item in jsonResponse:
        if "Netflix" in item['network'] or "Amazon" in item['network']:
            print (item['title'])

 

Edited by xnappo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...