Skip to content

Commit

Permalink
feat(inputstream): Adds content lookup mime type & same user agent as…
Browse files Browse the repository at this point in the history
… for json requests for inputstream
  • Loading branch information
Sebastian Golasch committed Jul 26, 2017
1 parent c6e56c0 commit 68cf7c1
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.netflix" name="Netflix" version="0.11.16" provider-name="libdev + jojo + asciidisco">
<addon id="plugin.video.netflix" name="Netflix" version="0.11.17" provider-name="libdev + jojo + asciidisco">
<requires>
<import addon="xbmc.python" version="2.24.0"/>
<import addon="script.module.beautifulsoup4" version="4.3.2"/>
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Dutch/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/English/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/German/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Polish/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Portugese/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Slovak/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Spanish/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Swedish/strings.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Kodi Media Center language file
# Addon Name: Netflix
# Addon id: plugin.video.netflix
# Addon version: 0.11.16
# Addon version: 0.11.17
# Addon Provider: libdev + jojo + asciidisco
msgid ""
msgstr ""
Expand Down
4 changes: 4 additions & 0 deletions resources/lib/KodiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from urllib import urlencode
from xbmcaddon import Addon
from uuid import uuid4
from utils import get_user_agent_for_current_platform
from UniversalAnalytics import Tracker
try:
import cPickle as pickle
Expand Down Expand Up @@ -693,6 +694,9 @@ def play_item (self, esn, video_id, start_offset=-1):
# inputstream addon properties
msl_service_url = 'http://localhost:' + str(addon.getSetting('msl_service_port'))
play_item = xbmcgui.ListItem(path=msl_service_url + '/manifest?id=' + video_id)
play_item.setContentLookup(False)
play_item.setMimeType('application/dash+xml')
play_item.setProperty(inputstream_addon + '.stream_headers', 'user-agent=' + get_user_agent_for_current_platform())
play_item.setProperty(inputstream_addon + '.license_type', 'com.widevine.alpha')
play_item.setProperty(inputstream_addon + '.manifest_type', 'mpd')
play_item.setProperty(inputstream_addon + '.license_key', msl_service_url + '/license?id=' + video_id + '||b{SSM}!b{SID}|')
Expand Down
22 changes: 2 additions & 20 deletions resources/lib/NetflixSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from time import time
from base64 import urlsafe_b64encode
from bs4 import BeautifulSoup, SoupStrainer
from utils import noop
from utils import noop, get_user_agent_for_current_platform
try:
import cPickle as pickle
except:
Expand Down Expand Up @@ -103,7 +103,7 @@ def __init__(self, cookie_path, data_path, verify_ssl=True, log_fn=noop):
# start session, fake chrome on the current platform (so that we get a proper widevine esn) & enable gzip
self.session = session()
self.session.headers.update({
'User-Agent': self._get_user_agent_for_current_platform(),
'User-Agent': get_user_agent_for_current_platform(),
'Accept-Encoding': 'gzip'
})

Expand Down Expand Up @@ -1880,24 +1880,6 @@ def _generate_account_hash (self, account):
"""
return urlsafe_b64encode(account['email'])

def _get_user_agent_for_current_platform (self):
"""Determines the user agent string for the current platform (to retrieve a valid ESN)
Returns
-------
:obj:`str`
User Agent for platform
"""
import platform
self.log(msg='Building User Agent for platform: ' + str(platform.system()) + ' - ' + str(platform.machine()))
if platform.system() == 'Darwin':
return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
if platform.system() == 'Windows':
return 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
if platform.machine().startswith('arm'):
return 'Mozilla/5.0 (X11; CrOS armv7l 7647.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36'
return 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'

def _session_post (self, component, type='document', data={}, headers={}, params={}):
"""Executes a get request using requests for the current session & measures the duration of that request
Expand Down
19 changes: 19 additions & 0 deletions resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Module: utils
# Created on: 13.01.2017

import platform

# Takes everything, does nothing, classic no operation function
def noop (**kwargs):
return True
Expand All @@ -27,3 +29,20 @@ def wrapped(*args, **kwargs):
return result
wrapped.__doc__ = f.__doc__
return wrapped

def _get_user_agent_for_current_platform():
"""Determines the user agent string for the current platform (to retrieve a valid ESN)
Returns
-------
:obj:`str`
User Agent for platform
"""
system = platform.system()
if system == 'Darwin':
return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
if system == 'Windows':
return 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
if platform.machine().startswith('arm'):
return 'Mozilla/5.0 (X11; CrOS armv7l 7647.78.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
return 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'

0 comments on commit 68cf7c1

Please sign in to comment.