Skip to content

Commit

Permalink
Merge pull request asciidisco#335 from asciidisco/encode
Browse files Browse the repository at this point in the history
Fixes asciidisco#336 / asciidisco#337 / asciidisco#338 and introduce cenc::defaultKeyId in mpd manifest
  • Loading branch information
liberty-developer authored Apr 28, 2018
2 parents 7919411 + ebaf58e commit a4e6b56
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 21 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.13.0" provider-name="libdev + jojo + asciidisco">
<addon id="plugin.video.netflix" name="Netflix" version="0.13.1" provider-name="libdev + jojo + asciidisco">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.requests" version="2.12.4"/>
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/KodiHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ def save_autologin_data(self, autologin_user, autologin_id):
autologin_id : :obj:`str`
Profile id from netflix
"""
self.set_setting('autologin_user', autologin_user)
self.set_setting('autologin_id', autologin_id)
self.set_setting('autologin_enable', 'True')
self.dialogs.show_autologin_enabled_notify()
self.nx_common.set_setting('autologin_user', autologin_user)
self.nx_common.set_setting('autologin_id', autologin_id)
self.nx_common.set_setting('autologin_enable', 'True')
self.nx_common.dialogs.show_autologin_enabled_notify()
self.invalidate_memcache()
self.refresh()

Expand Down
4 changes: 2 additions & 2 deletions resources/lib/Library.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def write_strm_file(self, path, url, title_player):
Video fallback title for m3u
"""
self.log('Writing {}'.format(path.decode('ascii','ignore')))
self.log('Writing {}'.format(path.encode('ascii','ignore')))
f = xbmcvfs.File(path, 'w')
f.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\n')
f.write(url)
Expand Down Expand Up @@ -401,7 +401,7 @@ def add_show(self, netflix_id, title, alt_title, episodes, build_url,
show_dir = self.nx_common.check_folder_path(
path=os.path.join(self.tvshow_path, folder))
progress = self._create_progress_dialog(in_background)
progress.create(self.kodi_helper.get_local_string(650), show_meta)
progress.create(self.nx_common.get_local_string(650), show_meta)
if not xbmcvfs.exists(show_dir):
self.log('Created show folder {}'.format(show_dir))
xbmcvfs.mkdirs(show_dir)
Expand Down
14 changes: 14 additions & 0 deletions resources/lib/MSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import time
import base64
import random
import uuid
from StringIO import StringIO
from datetime import datetime
import requests
Expand Down Expand Up @@ -296,9 +297,13 @@ def __tranform_to_dash(self, manifest):

# Check for pssh
pssh = ''
keyid = None
if 'psshb64' in manifest:
if len(manifest['psshb64']) >= 1:
pssh = manifest['psshb64'][0]
psshbytes = base64.standard_b64decode(pssh)
if len(psshbytes) == 52:
keyid = psshbytes[36:]

seconds = manifest['runtime']/1000
init_length = seconds / 2 * 12 + 20*1000
Expand All @@ -318,7 +323,16 @@ def __tranform_to_dash(self, manifest):
tag='AdaptationSet',
mimeType='video/mp4',
contentType="video")

# Content Protection
if keyid:
protection = ET.SubElement(
parent=video_adaption_set,
tag='ContentProtection',
value='cenc',
schemeIdUri='urn:mpeg:dash:mp4protection:2011')
protection.set('cenc:default_KID', str(uuid.UUID(bytes=keyid)))

protection = ET.SubElement(
parent=video_adaption_set,
tag='ContentProtection',
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/NetflixCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ def get_addon_info(self, name):
"""Return the current addon instance"""
return self.addon.getAddonInfo(name)

def set_setting(self, name, value):
return self.addon.setSetting(name, value)
def set_setting(self, key, value):
return self.addon.setSetting(key, value)

def get_setting(self, name):
return self.addon.getSetting(name)
def get_setting(self, key):
return self.addon.getSetting(key)

def flush_settings(self):
self.addon = Addon()
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/NetflixCredentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def encode_credentials(self, email, password):
# if everything is fine, we encode the values
if '' != email or '' != password:
return {
'email': self.encode(enc=email),
'password': self.encode(enc=password)
'email': self.encode(raw=email),
'password': self.encode(raw=password)
}

# if email is empty, we return an empty map
Expand Down
20 changes: 12 additions & 8 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,32 @@ def __init__(self):

def _start_servers(self):
# start thread for MLS servie
msl_thread = threading.Thread(target=self.msl_server.serve_forever)
msl_thread.daemon = True
msl_thread.start()
self.msl_thread = threading.Thread(
target=self.msl_server.serve_forever)
self.msl_thread.start()
self.nx_common.log(msg='[MSL] Thread started')

# start thread for Netflix HTTP service
ns_thread = threading.Thread(target=self.ns_server.serve_forever)
ns_thread.daemon = True
ns_thread.start()
self.ns_thread = threading.Thread(
target=self.ns_server.serve_forever)
self.ns_thread.start()
self.nx_common.log(msg='[NS] Thread started')

def _shutdown(self):
# MSL service shutdown sequence
self.msl_server.server_close()
self.msl_server.socket.close()
self.msl_server.shutdown()
self.msl_thread.join()
self.msl_server = None
self.msl_thread = None
self.nx_common.log(msg='Stopped MSL Service')

# Netflix service shutdown sequence
self.ns_server.server_close()
self.ns_server.socket.close()
self.ns_server.shutdown()
self.ns_thread.join()
self.ns_server = None
self.ns_thread = None
self.nx_common.log(msg='Stopped HTTP Service')

def _is_idle(self):
Expand Down

0 comments on commit a4e6b56

Please sign in to comment.