author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
106,046 | 24.01.2020 14:53:56 | -3,600 | b96b4a6cbe76bb5882521ecfdbbbdde85554210c | Added "because you liked" to raccomendations menu | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/globals.py",
"new_path": "resources/lib/globals.py",
"diff": "@@ -115,7 +115,7 @@ class GlobalVariables(object):\n'description_id': 30164,\n'icon': 'DefaultTVShows.png'}),\n('recommendations', {'path': ['recommendations', 'recommendations'],\n- 'lolomo_contexts': ['similars', 'becauseYouAdded'],\n+ 'lolomo_contexts': ['similars', 'becauseYouAdded', 'becauseYouLiked'],\n'lolomo_known': False,\n'label_id': 30001,\n'description_id': 30094,\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added "because you liked" to raccomendations menu |
106,046 | 26.01.2020 17:03:42 | -3,600 | e7754184431f15ed9fb8ec5612bcc2189424eb60 | Updated ESN generator
on android now is mandatory append the widewine uuid system identifier | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -271,6 +271,9 @@ def generate_esn(user_data):\nesn += '{:=<5.5}'.format(manufacturer.upper())\nesn += model.replace(' ', '=').upper()\nesn = sub(r'[^A-Za-z0-9=-]', '=', esn)\n+ system_id = g.LOCAL_DB.get_value('drm_system_id', table=TABLE_SESSION)\n+ if system_id:\n+ esn += '-' + str(system_id) + '-'\ncommon.debug('Android generated ESN: {}', esn)\nreturn esn\nexcept OSError:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/android_crypto.py",
"new_path": "resources/lib/services/msl/android_crypto.py",
"diff": "@@ -15,7 +15,8 @@ import json\nimport xbmcdrm\nimport resources.lib.common as common\n-\n+from resources.lib.database.db_utils import TABLE_SESSION\n+from resources.lib.globals import g\nfrom .base_crypto import MSLBaseCrypto\nfrom .exceptions import MSLError\n@@ -26,8 +27,7 @@ class AndroidMSLCrypto(MSLBaseCrypto):\n# pylint: disable=broad-except\ntry:\nself.crypto_session = xbmcdrm.CryptoSession(\n- 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed', 'AES/CBC/NoPadding',\n- 'HmacSHA256')\n+ 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed', 'AES/CBC/NoPadding', 'HmacSHA256')\ncommon.debug('Widevine CryptoSession successful constructed')\nexcept Exception:\nimport traceback\n@@ -38,18 +38,34 @@ class AndroidMSLCrypto(MSLBaseCrypto):\nsuper(AndroidMSLCrypto, self).__init__(msl_data)\nself.keyset_id = base64.standard_b64decode(msl_data['key_set_id'])\nself.key_id = base64.standard_b64decode(msl_data['key_id'])\n- self.hmac_key_id = base64.standard_b64decode(\n- msl_data['hmac_key_id'])\n+ self.hmac_key_id = base64.standard_b64decode(msl_data['hmac_key_id'])\nself.crypto_session.RestoreKeys(self.keyset_id)\nexcept Exception:\nself.keyset_id = None\nself.key_id = None\nself.hmac_key_id = None\n- common.debug('Widevine CryptoSession systemId: {}',\n- self.crypto_session.GetPropertyString('systemId'))\n- common.debug('Widevine CryptoSession algorithms: {}',\n- self.crypto_session.GetPropertyString('algorithms'))\n+ drm_info = {\n+ 'version': self.crypto_session.GetPropertyString('version'),\n+ 'system_id': self.crypto_session.GetPropertyString('systemId'),\n+ # 'device_unique_id': self.crypto_session.GetPropertyByteArray('deviceUniqueId')\n+ 'hdcp_level': self.crypto_session.GetPropertyString('hdcpLevel'),\n+ 'hdcp_level_max': self.crypto_session.GetPropertyString('maxHdcpLevel'),\n+ 'security_level': self.crypto_session.GetPropertyString('securityLevel')\n+ }\n+\n+ g.LOCAL_DB.set_value('drm_system_id', drm_info['system_id'], TABLE_SESSION)\n+\n+ common.debug('Widevine version: {}', drm_info['version'])\n+ if drm_info['system_id']:\n+ common.debug('Widevine CryptoSession system id: {}', drm_info['system_id'])\n+ else:\n+ common.warn('Widevine CryptoSession system id not obtained!')\n+ common.debug('Widevine CryptoSession security level: {}', drm_info['security_level'])\n+ common.debug('Widevine CryptoSession hdcp level from {} to {}',\n+ drm_info['hdcp_level'],\n+ drm_info['hdcp_level_max'])\n+ common.debug('Widevine CryptoSession algorithms: {}', self.crypto_session.GetPropertyString('algorithms'))\ndef __del__(self):\nself.crypto_session = None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Updated ESN generator
on android now is mandatory append the widewine uuid system identifier |
106,046 | 28.01.2020 12:54:42 | -3,600 | f00104830245363a8d7f47235fbc8fc05cc761f8 | Version bump (0.16.4) | [
{
"change_type": "MODIFY",
"old_path": "addon.xml",
"new_path": "addon.xml",
"diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.16.3\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.16.4\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.addon.signals\" version=\"0.0.3\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.16.4 (2020-01-28)\n+-Up Next is now supported only from version 1.1.0 and up\n+-Added czech language\n+-Added \"because you liked\" to recommendations menu\n+-Added Up Next install option\n+-Implemented Up Next feature, end time information\n+-Implemented Up Next feature, fast start next video\n+-Fixed the error \"Request failed validation during key exchange\"\n+-Fixed an issue that causing opening Up Next notification in wrong position\n+-Fixed html tags in profiles names\n+-Fixed STRM files resume workaround\n+-Fixed retrieving infolabels from library on python 3\n+-Managed user id token key expiration\n+-Manifest is saved to hdd with enabled verbose debugging only\n+-Updated de, es, hu, it translations\n+-Some minor changes, fixes\n+\nv0.16.3 (2020-01-18)\n-Fixed an issue that causing addon freeze on export/update to library\n-Fixed an regression issue that causing http error 401\n@@ -62,18 +79,6 @@ v0.16.3 (2020-01-18)\n-Fixed an issue that in some cases prevented the export of a tv show season\n-Generally optimized addon speed\n-Many improvements to the code\n-\n-v0.16.2 (2020-01-07)\n--Improved add-on startup\n--Improved loading of profiles list\n--Added in expert setting a choice to speed up service or addon startup\n--Fixed an issue that causing addon misbehaviour using multiple Kodi profiles\n--Fixed an issue that causing addon breakage with sqlite connections\n--Fixed some python 3 issues on Android\n--Handled cases of metadata not available\n--Permanently removed sharing Kodi videos settings between profiles\n--Updated de, es, it translations\n--Minor improvements\n</news>\n</extension>\n</addon>\n"
},
{
"change_type": "MODIFY",
"old_path": "changelog.txt",
"new_path": "changelog.txt",
"diff": "+v0.16.2 (2020-01-07)\n+-Improved add-on startup\n+-Improved loading of profiles list\n+-Added in expert setting a choice to speed up service or addon startup\n+-Fixed an issue that causing addon misbehaviour using multiple Kodi profiles\n+-Fixed an issue that causing addon breakage with sqlite connections\n+-Fixed some python 3 issues on Android\n+-Handled cases of metadata not available\n+-Permanently removed sharing Kodi videos settings between profiles\n+-Updated de, es, it translations\n+-Minor improvements\n+\nv0.16.1 (2019-12-14)\n-Allowed to export individual seasons to the library (manual mode)\n-Dolby atmos audio streams are now specified (Kodi 19)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump (0.16.4) |
106,046 | 01.02.2020 08:43:51 | -3,600 | b6f3ffb4bfb15ce76914b29439b4f5d09b70c0ac | Raise an error when get info from crypto session do not work | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/android_crypto.py",
"new_path": "resources/lib/services/msl/android_crypto.py",
"diff": "@@ -54,6 +54,13 @@ class AndroidMSLCrypto(MSLBaseCrypto):\n'security_level': self.crypto_session.GetPropertyString('securityLevel')\n}\n+ if not drm_info['version']:\n+ # Possible cases where no data is obtained:\n+ # I don't know if this is really the cause, but seem that using Kodi debug build with a\n+ # InputStream Adaptive release build (yes users do it) cause problems\n+ raise MSLError('It was not possible to get the data from Widevine CryptoSession, '\n+ 'try to reinstall Kodi with latest version')\n+\ng.LOCAL_DB.set_value('drm_system_id', drm_info['system_id'], TABLE_SESSION)\ncommon.debug('Widevine version: {}', drm_info['version'])\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Raise an error when get info from crypto session do not work |
106,046 | 29.01.2020 16:50:51 | -3,600 | cf24820ade1809b379cc03eb37d978796d9b2806 | Added 4k check capability | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -333,6 +333,21 @@ def remove_html_tags(raw_html):\nreturn text\n+def is_device_4k_capable():\n+ \"\"\"Check if the device is 4k capable\"\"\"\n+ # Currently only on android is it possible to use 4K\n+ if get_system_platform() == 'android':\n+ from re import findall\n+ from resources.lib.database.db_utils import TABLE_SESSION\n+ # Check if the drm has security level L1\n+ is_drm_l1_security_level = g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1'\n+ # Check if HDCP level is 2.2 or up\n+ drm_hdcp_level = findall('\\\\d+\\\\.\\\\d+', g.LOCAL_DB.get_value('drm_hdcp_level', '', table=TABLE_SESSION))\n+ hdcp_4k_capable = drm_hdcp_level and float(drm_hdcp_level[0]) >= 2.2\n+ return is_drm_l1_security_level and hdcp_4k_capable\n+ return False\n+\n+\ndef get_system_platform():\nplatform = \"unknown\"\nif xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/android_crypto.py",
"new_path": "resources/lib/services/msl/android_crypto.py",
"diff": "@@ -62,6 +62,8 @@ class AndroidMSLCrypto(MSLBaseCrypto):\n'try to reinstall Kodi with latest version')\ng.LOCAL_DB.set_value('drm_system_id', drm_info['system_id'], TABLE_SESSION)\n+ g.LOCAL_DB.set_value('drm_security_level', drm_info['security_level'], TABLE_SESSION)\n+ g.LOCAL_DB.set_value('drm_hdcp_level', drm_info['hdcp_level'], TABLE_SESSION)\ncommon.debug('Widevine version: {}', drm_info['version'])\nif drm_info['system_id']:\n@@ -69,9 +71,8 @@ class AndroidMSLCrypto(MSLBaseCrypto):\nelse:\ncommon.warn('Widevine CryptoSession system id not obtained!')\ncommon.debug('Widevine CryptoSession security level: {}', drm_info['security_level'])\n- common.debug('Widevine CryptoSession hdcp level from {} to {}',\n- drm_info['hdcp_level'],\n- drm_info['hdcp_level_max'])\n+ common.debug('Widevine CryptoSession current hdcp level', drm_info['hdcp_level'])\n+ common.debug('Widevine CryptoSession max hdcp level supported', drm_info['hdcp_level_max'])\ncommon.debug('Widevine CryptoSession algorithms: {}', self.crypto_session.GetPropertyString('algorithms'))\ndef __del__(self):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added 4k check capability |
106,046 | 01.02.2020 09:14:00 | -3,600 | 9a2a3312be07587b0af78d222f40ec6362caa07d | Add widevine security level check on esn generation
Chinese devices like Smart Android TV Box T96 H616 (android 10.0)
Have included 'tv' property in product characteristics
but they have a L3 widevine security level
that cause a wrong esn generation.
So it is better to add the widevine security level verification. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -260,14 +260,17 @@ def generate_esn(user_data):\n['/system/bin/getprop',\n'ro.nrdp.modelgroup']).decode('utf-8').strip(' \\t\\n\\r')\n- esn = ('NFANDROID2-PRV-' if has_product_characteristics_tv else 'NFANDROID1-PRV-')\n- if has_product_characteristics_tv:\n+ if has_product_characteristics_tv and \\\n+ g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1':\n+ esn = 'NFANDROID2-PRV-'\nif nrdp_modelgroup:\nesn += nrdp_modelgroup + '-'\nelse:\nesn += model.replace(' ', '').upper() + '-'\nelse:\n+ esn = 'NFANDROID1-PRV-'\nesn += 'T-L3-'\n+\nesn += '{:=<5.5}'.format(manufacturer.upper())\nesn += model.replace(' ', '=').upper()\nesn = sub(r'[^A-Za-z0-9=-]', '=', esn)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add widevine security level check on esn generation
Chinese devices like Smart Android TV Box T96 H616 (android 10.0)
Have included 'tv' property in product characteristics
but they have a L3 widevine security level
that cause a wrong esn generation.
So it is better to add the widevine security level verification. |
106,046 | 05.02.2020 13:16:51 | -3,600 | 404cf572f948977a104cbbd8af293761fb9c812d | Fixed the 30 seconds delay on notify_all
was blocking the execution of the all action manager functions
and also the 'on_tick' callback | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/ipc.py",
"new_path": "resources/lib/common/ipc.py",
"diff": "@@ -15,7 +15,7 @@ from resources.lib.globals import g\nimport resources.lib.api.exceptions as apierrors\nfrom .logging import debug, error\n-from .misc_utils import time_execution\n+from .misc_utils import time_execution, run_threaded\ntry: # Python 2\nunicode\n@@ -58,7 +58,6 @@ def unregister_slot(callback, signal=None):\ndef send_signal(signal, data=None, non_blocking=False):\n\"\"\"Send a signal via AddonSignals\"\"\"\n- if non_blocking:\n# Using sendSignal of AddonSignals you might think that it is not a blocking call instead is blocking because it\n# uses executeJSONRPC that is a blocking call, so the invoker will remain blocked until the function called by\n# executeJSONRPC has completed his operations, even if it does not return any data.\n@@ -66,11 +65,7 @@ def send_signal(signal, data=None, non_blocking=False):\n# This is to be considered according to the functions to be called,\n# because it could keep the caller blocked for a certain amount of time unnecessarily.\n# To note that several consecutive calls, are made in sequence not at the same time.\n- from threading import Thread\n- thread = Thread(target=_send_signal, args=[signal, data])\n- thread.start()\n- else:\n- _send_signal(signal, data)\n+ run_threaded(non_blocking, _send_signal, signal, data)\ndef _send_signal(signal, data):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -357,6 +357,16 @@ def is_device_4k_capable():\nreturn False\n+def run_threaded(non_blocking, target_func, *args, **kwargs):\n+ \"\"\"Call a function in a thread, when specified\"\"\"\n+ if not non_blocking:\n+ target_func(*args, **kwargs)\n+ return\n+ from threading import Thread\n+ thread = Thread(target=target_func, args=args, kwargs=kwargs)\n+ thread.start()\n+\n+\ndef get_system_platform():\nplatform = \"unknown\"\nif xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/ui/xmldialogs.py",
"new_path": "resources/lib/kodi/ui/xmldialogs.py",
"diff": "@@ -16,6 +16,7 @@ from platform import machine\nimport xbmc\nimport xbmcgui\n+from resources.lib.common import run_threaded\nfrom resources.lib.globals import g\nfrom resources.lib.kodi.ui.dialogs import (show_ok_dialog, show_error_info)\n@@ -36,12 +37,21 @@ OS_MACHINE = machine()\nCMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{},silent)'\n-def show_modal_dialog(dlg_class, xml, path, **kwargs):\n+# @time_execution(immediate=True)\n+def show_modal_dialog(non_blocking, dlg_class, xml, path, **kwargs):\n\"\"\"\nShow a modal Dialog in the UI.\nPass kwargs minutes and/or seconds to have the dialog automatically\nclose after the specified time.\n\"\"\"\n+ # WARNING: doModal when invoked does not release the function immediately!\n+ # it seems that doModal waiting for all window operations to be completed before return,\n+ # for example the \"Skip\" dialog takes about 30 seconds to release the function (test on Kodi 19.x)\n+ # To be taken into account because it can do very big delays in the execution of the invoking code\n+ run_threaded(non_blocking, _show_modal_dialog, dlg_class, xml, path, **kwargs)\n+\n+\n+def _show_modal_dialog(dlg_class, xml, path, **kwargs):\ndlg = dlg_class(xml, path, 'default', '1080i', **kwargs)\nminutes = kwargs.get('minutes', 0)\nseconds = kwargs.get('seconds', 0)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/actions.py",
"new_path": "resources/lib/navigation/actions.py",
"diff": "@@ -50,7 +50,8 @@ class AddonActionExecutor(object):\nreturn\ntry:\nparental_control_data = api.get_parental_control_data(password)\n- ui.show_modal_dialog(ui.xmldialogs.ParentalControl,\n+ ui.show_modal_dialog(False,\n+ ui.xmldialogs.ParentalControl,\n'plugin-video-netflix-ParentalControl.xml',\ng.ADDON.getAddonInfo('path'),\n**parental_control_data)\n@@ -73,7 +74,8 @@ class AddonActionExecutor(object):\nis_thumb_rating = video_data.get('userRating', {}).get('type', '') == 'thumb'\nuser_rating = video_data.get('userRating', {}).get('userRating') \\\nif is_thumb_rating else None\n- ui.show_modal_dialog(ui.xmldialogs.RatingThumb,\n+ ui.show_modal_dialog(False,\n+ ui.xmldialogs.RatingThumb,\n'plugin-video-netflix-RatingThumb.xml',\ng.ADDON.getAddonInfo('path'),\nvideoid=videoid,\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/section_skipping.py",
"new_path": "resources/lib/services/playback/section_skipping.py",
"diff": "@@ -72,13 +72,13 @@ class SectionSkipper(PlaybackActionManager):\ncommon.debug('Asking to skip {}', section)\ndialog_duration = (self.markers[section]['end'] -\nself.markers[section]['start'])\n- ui.show_modal_dialog(ui.xmldialogs.Skip,\n+ ui.show_modal_dialog(True,\n+ ui.xmldialogs.Skip,\n\"plugin-video-netflix-Skip.xml\",\ng.ADDON.getAddonInfo('path'),\nseconds=dialog_duration,\nskip_to=self.markers[section]['end'],\n- label=common.get_local_string(\n- SKIPPABLE_SECTIONS[section]))\n+ label=common.get_local_string(SKIPPABLE_SECTIONS[section]))\ndef _on_playback_stopped(self):\n# Close any dialog remaining open\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed the 30 seconds delay on notify_all
was blocking the execution of the all action manager functions
and also the 'on_tick' callback |
106,046 | 05.02.2020 13:30:08 | -3,600 | e820a00dacb25b3bbf985f75d33bddd03aefa501 | Get player id through rpcjson | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import json\n+import time\n-import xbmc\nimport AddonSignals\n+import xbmc\n-from resources.lib.globals import g\nimport resources.lib.common as common\n-\n+from resources.lib.globals import g\nfrom .action_manager import PlaybackActionManager\nfrom .resume_manager import ResumeManager\nfrom .section_skipping import SectionSkipper\n@@ -37,8 +36,7 @@ class PlaybackController(xbmc.Monitor):\nself.action_managers = None\nAddonSignals.registerSlot(\n- g.ADDON.getAddonInfo('id'), common.Signals.PLAYBACK_INITIATED,\n- self.initialize_playback)\n+ g.ADDON.getAddonInfo('id'), common.Signals.PLAYBACK_INITIATED, self.initialize_playback)\ndef initialize_playback(self, data):\n# pylint: disable=broad-except\n@@ -65,7 +63,10 @@ class PlaybackController(xbmc.Monitor):\nreturn\ntry:\nif method == 'Player.OnAVStart':\n- self._on_playback_started(json.loads(data))\n+ # WARNING: Do not get playerid from 'data',\n+ # Because when UpNext addon play a video while we are inside Netflix addon and\n+ # not externally like Kodi library, the playerid become -1 this id does not exist\n+ self._on_playback_started()\nelif method == 'Player.OnStop':\nself._on_playback_stopped()\nexcept Exception:\n@@ -79,16 +80,11 @@ class PlaybackController(xbmc.Monitor):\nif self.tracking and self.active_player_id is not None:\nplayer_state = self._get_player_state()\nif player_state:\n- self._notify_all(PlaybackActionManager.on_tick,\n- player_state)\n+ self._notify_all(PlaybackActionManager.on_tick, player_state)\n- def _on_playback_started(self, data):\n- # When UpNext addon play a video while we are inside Netflix addon and\n- # not externally like Kodi library, the playerid become -1 this id does not exist\n- player_id = data['player']['playerid'] if data['player']['playerid'] > -1 else 1\n- self.active_player_id = player_id\n- self._notify_all(PlaybackActionManager.on_playback_started,\n- self._get_player_state())\n+ def _on_playback_started(self):\n+ self.active_player_id = _get_player_id()\n+ self._notify_all(PlaybackActionManager.on_playback_started, self._get_player_state())\nif common.is_debug_verbose() and g.ADDON.getSettingBool('show_codec_info'):\ncommon.json_rpc('Input.ExecuteAction', {'action': 'codecinfo'})\n@@ -100,8 +96,7 @@ class PlaybackController(xbmc.Monitor):\ndef _notify_all(self, notification, data=None):\n# pylint: disable=broad-except\n- common.debug('Notifying all managers of {} (data={})',\n- notification.__name__, data)\n+ common.debug('Notifying all managers of {} (data={})', notification.__name__, data)\nfor manager in self.action_managers:\n_notify_managers(manager, notification, data)\n@@ -147,3 +142,18 @@ def _notify_managers(manager, notification, data):\ncommon.error('{} disabled due to exception: {}', manager.name, exc)\nmanager.enabled = False\nraise\n+\n+\n+def _get_player_id():\n+ try:\n+ retry = 10\n+ while retry:\n+ result = common.json_rpc('Player.GetActivePlayers')\n+ if result:\n+ return result[0]['playerid']\n+ time.sleep(0.1)\n+ retry -= 1\n+ common.warn('Player ID not obtained, fallback to ID 1')\n+ except IOError:\n+ common.error('Player ID not obtained, fallback to ID 1')\n+ return 1\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Get player id through rpcjson |
106,046 | 09.02.2020 20:50:18 | -3,600 | 30ac436ffd02389983df8610aee098eb0bc10b0c | Now we can get the profiles cookies
cookies like:
lhpuuidh-browse-xxxxxxxxx
lhpuuidh-browse-xxxxxxxxx-T
and are updated on profile switching,
but again this is not enough to fix the problem of msl requests done by profiles | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession.py",
"new_path": "resources/lib/services/nfsession/nfsession.py",
"diff": "@@ -81,14 +81,17 @@ class NetflixSession(NFSessionAccess):\nif guid == g.LOCAL_DB.get_active_profile_guid():\ncommon.debug('Profile {} is already active', guid)\nreturn False\n+ # When switch profile is performed the authURL change\n+ response = self._get('switch_profile', params={'tkn': guid})\n+ react_context = website.extract_json(response, 'reactContext')\n+ self.auth_url = website.extract_api_data(react_context)['auth_url']\n+\nself._get(component='activate_profile',\nreq_type='api',\nparams={'switchProfileGuid': guid,\n'_': int(time.time()),\n'authURL': self.auth_url})\n- # When switch profile is performed the authURL change\n- react_context = website.extract_json(self._get('browse'), 'reactContext')\n- self.auth_url = website.extract_api_data(react_context)['auth_url']\n+\ng.LOCAL_DB.switch_active_profile(guid)\nself.update_session_data()\ncommon.debug('Successfully activated profile {}', guid)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_requests.py",
"new_path": "resources/lib/services/nfsession/nfsession_requests.py",
"diff": "@@ -31,6 +31,7 @@ URLS = {\n'shakti': {'endpoint': '/pathEvaluator', 'is_api_call': True},\n'browse': {'endpoint': '/browse', 'is_api_call': False},\n'profiles': {'endpoint': '/profiles/manage', 'is_api_call': False},\n+ 'switch_profile': {'endpoint': '/SwitchProfile', 'is_api_call': False},\n'activate_profile': {'endpoint': '/profiles/switch', 'is_api_call': True},\n'pin': {'endpoint': '/pin', 'is_api_call': False},\n'pin_reset': {'endpoint': '/pin/reset', 'is_api_call': True},\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Now we can get the profiles cookies
cookies like:
lhpuuidh-browse-xxxxxxxxx
lhpuuidh-browse-xxxxxxxxx-T
and are updated on profile switching,
but again this is not enough to fix the problem of msl requests done by profiles |
106,046 | 15.02.2020 13:36:48 | -3,600 | 823cf0ef109685dacd8dad6bd0fe171916a83dbf | Fixes workarounds for apple ios/tvos restrictions | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -240,6 +240,7 @@ def validate_login(react_context):\ndef generate_esn(user_data):\n\"\"\"Generate an ESN if on android or return the one from user_data\"\"\"\n+ if common.get_system_platform() == 'android':\nimport subprocess\ntry:\nmanufacturer = subprocess.check_output(\n@@ -281,7 +282,6 @@ def generate_esn(user_data):\nreturn esn\nexcept OSError:\npass\n-\nreturn user_data.get('esn', '')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -96,9 +96,8 @@ def get_user_agent(enable_android_mediaflag_fix=False):\n:returns: str -- User agent string\n\"\"\"\n- import platform\n- system = platform.system()\n- if enable_android_mediaflag_fix and get_system_platform() == 'android' and is_device_4k_capable():\n+ system = get_system_platform()\n+ if enable_android_mediaflag_fix and system == 'android' and is_device_4k_capable():\n# The UA affects not only the ESNs in the login, but also the video details,\n# so the UAs seem refer to exactly to these conditions: https://help.netflix.com/en/node/23742\n# This workaround is needed because currently we do not login through the netflix native android API,\n@@ -106,21 +105,20 @@ def get_user_agent(enable_android_mediaflag_fix=False):\n# Then on android usually we use the 'arm' UA which refers to chrome os, but this is limited to 1080P, so the\n# labels on the 4K devices appears wrong (in the Kodi skin the 4K videos have 1080P media flags instead of 4K),\n# the Windows UA is not limited, so we can use it to get the right video media flags.\n- system = 'Windows'\n+ system = 'windows'\nchrome_version = 'Chrome/78.0.3904.92'\nbase = 'Mozilla/5.0 '\nbase += '%PL% '\nbase += 'AppleWebKit/537.36 (KHTML, like Gecko) '\nbase += '%CH_VER% Safari/537.36'.replace('%CH_VER%', chrome_version)\n- # Mac OSX\n- if system == 'Darwin':\n+\n+ if system in ['osx', 'ios', 'tvos']:\nreturn base.replace('%PL%', '(Macintosh; Intel Mac OS X 10_14_6)')\n- # Windows\n- if system == 'Windows':\n+ if system in ['windows', 'xbox']:\nreturn base.replace('%PL%', '(Windows NT 10; Win64; x64)')\n# ARM based Linux\n- if platform.machine().startswith('arm'):\n+ if get_machine().startswith('arm'):\n# Last number is the platform version of Chrome OS\nreturn base.replace('%PL%', '(X11; CrOS armv7l 12371.89.0)')\n# x86 Linux\n@@ -367,6 +365,18 @@ def run_threaded(non_blocking, target_func, *args, **kwargs):\nthread.start()\n+def get_machine():\n+ \"\"\"Get machine architecture\"\"\"\n+ from platform import machine\n+ try:\n+ return machine()\n+ except Exception: # pylint: disable=broad-except\n+ # Due to OS restrictions on 'ios' and 'tvos' this generate an exception\n+ # See python limits in the wiki development page\n+ # Fallback with a generic arm\n+ return 'arm'\n+\n+\ndef get_system_platform():\nplatform = \"unknown\"\nif xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):\n@@ -381,6 +391,8 @@ def get_system_platform():\nplatform = \"osx\"\nelif xbmc.getCondVisibility('system.platform.ios'):\nplatform = \"ios\"\n+ elif xbmc.getCondVisibility('system.platform.tvos'): # Supported only on Kodi 19.x\n+ platform = \"tvos\"\nreturn platform\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/uuid_device.py",
"new_path": "resources/lib/common/uuid_device.py",
"diff": "@@ -54,7 +54,9 @@ def _get_system_uuid():\nuuid_value = _get_android_uuid()\nelif system == 'linux':\nuuid_value = _get_linux_uuid()\n- elif system in ['osx', 'ios']:\n+ elif system == 'osx':\n+ # Due to OS restrictions on 'ios' and 'tvos' is not possible to use _get_macos_uuid()\n+ # See python limits in the wiki development page\nuuid_value = _get_macos_uuid()\nif not uuid_value:\ndebug('It is not possible to get a system UUID creating a new UUID')\n@@ -120,8 +122,7 @@ def _get_android_uuid():\n'persist.sys.timezone', 'persist.sys.locale', 'net.hostname']\n# Warning net.hostname property starting from android 10 is deprecated return empty\nproc = subprocess.Popen(['/system/bin/getprop'], stdout=subprocess.PIPE)\n- output_data = proc.stdout.read().decode('utf-8')\n- proc.stdout.close()\n+ output_data = proc.communicate()[0].decode('utf-8')\nlist_values = output_data.splitlines()\nfor value in list_values:\nvalue_splitted = re.sub(r'\\[|\\]|\\s', '', value).split(':')\n@@ -140,8 +141,7 @@ def _get_macos_uuid():\nproc = subprocess.Popen(\n['/usr/sbin/system_profiler', 'SPHardwareDataType', '-detaillevel', 'full', '-xml'],\nstdout=subprocess.PIPE)\n- output_data = proc.stdout.read().decode('utf-8')\n- proc.stdout.close()\n+ output_data = proc.communicate()[0].decode('utf-8')\nif output_data:\nsp_dict_values = _parse_osx_xml_plist_data(output_data)\nexcept Exception as exc:\n@@ -185,5 +185,10 @@ def _get_fake_uuid(with_hostname=True):\nimport platform\nlist_values = [xbmc.getInfoLabel('System.Memory(total)')]\nif with_hostname:\n+ try:\nlist_values.append(platform.node())\n+ except Exception: # pylint: disable=broad-except\n+ # Due to OS restrictions on 'ios' and 'tvos' an error happen\n+ # See python limits in the wiki development page\n+ pass\nreturn '_'.join(list_values)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/ui/xmldialogs.py",
"new_path": "resources/lib/kodi/ui/xmldialogs.py",
"diff": "from __future__ import absolute_import, division, unicode_literals\nimport time\n-from platform import machine\nimport xbmc\nimport xbmcgui\n-from resources.lib.common import run_threaded\n+from resources.lib.common import run_threaded, get_machine\nfrom resources.lib.globals import g\nfrom resources.lib.kodi.ui.dialogs import (show_ok_dialog, show_error_info)\n@@ -32,8 +31,6 @@ XBFONT_CENTER_Y = 0x00000004\nXBFONT_TRUNCATED = 0x00000008\nXBFONT_JUSTIFY = 0x00000010\n-OS_MACHINE = machine()\n-\nCMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{},silent)'\n@@ -79,10 +76,13 @@ class Skip(xbmcgui.WindowXMLDialog):\nACTION_NAV_BACK,\nACTION_NOOP]\n- if OS_MACHINE[0:5] == 'armv7':\n+ if get_machine()[0:5] == 'armv7':\nxbmcgui.WindowXMLDialog.__init__(self)\nelse:\n+ try:\nxbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+ except Exception: # pylint: disable=broad-except\n+ xbmcgui.WindowXMLDialog.__init__(self)\ndef onInit(self):\nself.getControl(6012).setLabel(self.label)\n@@ -116,10 +116,13 @@ class ParentalControl(xbmcgui.WindowXMLDialog):\nself.action_exitkeys_id = [ACTION_PREVIOUS_MENU,\nACTION_PLAYER_STOP,\nACTION_NAV_BACK]\n- if OS_MACHINE[0:5] == 'armv7':\n+ if get_machine()[0:5] == 'armv7':\nxbmcgui.WindowXMLDialog.__init__(self)\nelse:\n+ try:\nxbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+ except Exception: # pylint: disable=broad-except\n+ xbmcgui.WindowXMLDialog.__init__(self)\ndef onInit(self):\nself._generate_levels_labels()\n@@ -224,10 +227,13 @@ class RatingThumb(xbmcgui.WindowXMLDialog):\nself.action_exitkeys_id = [ACTION_PREVIOUS_MENU,\nACTION_PLAYER_STOP,\nACTION_NAV_BACK]\n- if OS_MACHINE[0:5] == 'armv7':\n+ if get_machine()[0:5] == 'armv7':\nxbmcgui.WindowXMLDialog.__init__(self)\nelse:\n+ try:\nxbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+ except Exception: # pylint: disable=broad-except\n+ xbmcgui.WindowXMLDialog.__init__(self)\ndef onInit(self):\nself.getControl(10000).setLabel(self.title)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/request_builder.py",
"new_path": "resources/lib/services/msl/request_builder.py",
"diff": "@@ -22,7 +22,9 @@ import resources.lib.common as common\ntry:\nSDKVERSION = int(subprocess.check_output(\n['/system/bin/getprop', 'ro.build.version.sdk']))\n-except (OSError, subprocess.CalledProcessError):\n+except (OSError, subprocess.CalledProcessError, AttributeError):\n+ # Due to OS restrictions on 'ios' and 'tvos' this give AttributeError\n+ # See python limits in the wiki development page\nSDKVERSION = 0\nif SDKVERSION >= 18:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixes workarounds for apple ios/tvos restrictions |
106,046 | 03.02.2020 16:55:01 | -3,600 | e88a37cc5737bc457b7b4bc615675cd62f668a11 | msl_handler divided into two classes | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import re\n-import zlib\nimport json\nimport time\n-import base64\n-from functools import wraps\nimport requests\nimport xbmcaddon\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n-import resources.lib.kodi.ui as ui\nimport resources.lib.cache as cache\n+from .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info\nfrom .request_builder import MSLRequestBuilder\nfrom .profiles import enabled_profiles\nfrom .converter import convert_to_dash\n-from .exceptions import MSLError\ntry: # Python 2\nunicode\n@@ -34,30 +29,7 @@ except NameError: # Python 3\nunicode = str # pylint: disable=redefined-builtin\n-CHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\n-ENDPOINTS = {\n- 'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n- 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router'\n-}\n-\n-\n-def display_error_info(func):\n- \"\"\"Decorator that catches errors raise by the decorated function,\n- displays an error info dialog in the UI and reraises the error\"\"\"\n- # pylint: disable=missing-docstring\n- @wraps(func)\n- def error_catching_wrapper(*args, **kwargs):\n- try:\n- return func(*args, **kwargs)\n- except Exception as exc:\n- ui.show_error_info(common.get_local_string(30028), unicode(exc),\n- unknown_error=not(unicode(exc)),\n- netflix_error=isinstance(exc, MSLError))\n- raise\n- return error_catching_wrapper\n-\n-\n-class MSLHandler(object):\n+class MSLHandler(MSLHandlerBase):\n\"\"\"Handles session management and crypto for license and manifest\nrequests\"\"\"\nlast_license_url = ''\n@@ -66,6 +38,7 @@ class MSLHandler(object):\nsession = requests.session()\ndef __init__(self):\n+ super(MSLHandler, self).__init__()\n# pylint: disable=broad-except\nself.request_builder = None\ntry:\n@@ -85,49 +58,6 @@ class MSLHandler(object):\nsignal=common.Signals.ESN_CHANGED,\ncallback=self.perform_key_handshake)\n- def check_mastertoken_validity(self):\n- \"\"\"Return the mastertoken validity and executes a new key handshake when necessary\"\"\"\n- if self.request_builder.crypto.mastertoken:\n- time_now = time.time()\n- renewable = self.request_builder.crypto.renewal_window < time_now\n- expired = self.request_builder.crypto.expiration <= time_now\n- else:\n- renewable = False\n- expired = True\n- if expired:\n- if not self.request_builder.crypto.mastertoken:\n- common.debug('Stored MSL data not available, a new key handshake will be performed')\n- self.request_builder = MSLRequestBuilder()\n- else:\n- common.debug('Stored MSL data is expired, a new key handshake will be performed')\n- if self.perform_key_handshake():\n- self.request_builder = MSLRequestBuilder(json.loads(\n- common.load_file('msl_data.json')))\n- return self.check_mastertoken_validity()\n- return {'renewable': renewable, 'expired': expired}\n-\n- @display_error_info\n- @common.time_execution(immediate=True)\n- def perform_key_handshake(self, data=None):\n- \"\"\"Perform a key handshake and initialize crypto keys\"\"\"\n- # pylint: disable=unused-argument\n- esn = data or g.get_esn()\n- if not esn:\n- common.info('Cannot perform key handshake, missing ESN')\n- return False\n-\n- common.debug('Performing key handshake. ESN: {}', esn)\n-\n- response = _process_json_response(\n- self._post(ENDPOINTS['manifest'],\n- self.request_builder.handshake_request(esn)))\n- header_data = self.request_builder.decrypt_header_data(response['headerdata'], False)\n- self.request_builder.crypto.parse_key_response(header_data, not common.is_edge_esn(esn))\n- # Reset the user id token\n- self.request_builder.user_id_token = None\n- common.debug('Key handshake successful')\n- return True\n-\n@display_error_info\[email protected]_execution(immediate=True)\ndef load_manifest(self, viewable_id):\n@@ -289,137 +219,6 @@ class MSLHandler(object):\nself.last_drm_context = manifest['drmContextId']\nreturn convert_to_dash(manifest)\n- @common.time_execution(immediate=True)\n- def _chunked_request(self, endpoint, request_data, esn, mt_validity=None):\n- \"\"\"Do a POST request and process the chunked response\"\"\"\n- chunked_response = self._process_chunked_response(\n- self._post(endpoint, self.request_builder.msl_request(request_data, esn)),\n- mt_validity['renewable'] if mt_validity else None)\n- return chunked_response['result']\n-\n- @common.time_execution(immediate=True)\n- def _post(self, endpoint, request_data):\n- \"\"\"Execute a post request\"\"\"\n- common.debug('Executing POST request to {}', endpoint)\n- start = time.clock()\n- response = self.session.post(endpoint, request_data)\n- common.debug('Request took {}s', time.clock() - start)\n- common.debug('Request returned response with status {}', response.status_code)\n- response.raise_for_status()\n- return response\n-\n- # pylint: disable=unused-argument\n- @common.time_execution(immediate=True)\n- def _process_chunked_response(self, response, mt_renewable):\n- \"\"\"Parse and decrypt an encrypted chunked response. Raise an error\n- if the response is plaintext json\"\"\"\n- try:\n- # if the json() does not fail we have an error because\n- # the expected response is a chunked json response\n- return _raise_if_error(response.json())\n- except ValueError:\n- # json() failed so parse and decrypt the chunked response\n- common.debug('Received encrypted chunked response')\n- response = _parse_chunks(response.text)\n- # TODO: sending for the renewal request is not yet implemented\n- # if mt_renewable:\n- # # Check if mastertoken is renewed\n- # self.request_builder.crypto.compare_mastertoken(response['header']['mastertoken'])\n-\n- header_data = self.request_builder.decrypt_header_data(\n- response['header'].get('headerdata'))\n-\n- if 'useridtoken' in header_data:\n- # After the first call, it is possible get the 'user id token' that contains the\n- # user identity to use instead of 'User Authentication Data' with user credentials\n- self.request_builder.user_id_token = header_data['useridtoken']\n- # if 'keyresponsedata' in header_data:\n- # common.debug('Found key handshake in response data')\n- # # Update current mastertoken\n- # self.request_builder.crypto.parse_key_response(header_data, True)\n- decrypted_response = _decrypt_chunks(response['payloads'], self.request_builder.crypto)\n- return _raise_if_error(decrypted_response)\n-\n-\[email protected]_execution(immediate=True)\n-def _process_json_response(response):\n- \"\"\"Execute a post request and expect a JSON response\"\"\"\n- try:\n- return _raise_if_error(response.json())\n- except ValueError:\n- raise MSLError('Expected JSON response, got {}'.format(response.text))\n-\n-\n-def _raise_if_error(decoded_response):\n- raise_error = False\n- # Catch a manifest/chunk error\n- if any(key in decoded_response for key in ['error', 'errordata']):\n- raise_error = True\n- # Catch a license error\n- if 'result' in decoded_response and isinstance(decoded_response.get('result'), list):\n- if 'error' in decoded_response['result'][0]:\n- raise_error = True\n- if raise_error:\n- common.error('Full MSL error information:')\n- common.error(json.dumps(decoded_response))\n- raise MSLError(_get_error_details(decoded_response))\n- return decoded_response\n-\n-\n-def _get_error_details(decoded_response):\n- # Catch a chunk error\n- if 'errordata' in decoded_response:\n- return json.loads(\n- base64.standard_b64decode(\n- decoded_response['errordata']))['errormsg']\n- # Catch a manifest error\n- if 'error' in decoded_response:\n- if decoded_response['error'].get('errorDisplayMessage'):\n- return decoded_response['error']['errorDisplayMessage']\n- # Catch a license error\n- if 'result' in decoded_response and isinstance(decoded_response.get('result'), list):\n- if 'error' in decoded_response['result'][0]:\n- if decoded_response['result'][0]['error'].get('errorDisplayMessage'):\n- return decoded_response['result'][0]['error']['errorDisplayMessage']\n- return 'Unhandled error check log.'\n-\n-\[email protected]_execution(immediate=True)\n-def _parse_chunks(message):\n- header = json.loads(message.split('}}')[0] + '}}')\n- payloads = re.split(',\\\"signature\\\":\\\"[0-9A-Za-z=/+]+\\\"}',\n- message.split('}}')[1])\n- payloads = [x + '}' for x in payloads][:-1]\n- return {'header': header, 'payloads': payloads}\n-\n-\[email protected]_execution(immediate=True)\n-def _decrypt_chunks(chunks, crypto):\n- decrypted_payload = ''\n- for chunk in chunks:\n- payloadchunk = json.loads(chunk)\n- payload = payloadchunk.get('payload')\n- decoded_payload = base64.standard_b64decode(payload)\n- encryption_envelope = json.loads(decoded_payload)\n- # Decrypt the text\n- plaintext = crypto.decrypt(\n- base64.standard_b64decode(encryption_envelope['iv']),\n- base64.standard_b64decode(encryption_envelope.get('ciphertext')))\n- # unpad the plaintext\n- plaintext = json.loads(plaintext)\n- data = plaintext.get('data')\n-\n- # uncompress data if compressed\n- if plaintext.get('compressionalgo') == 'GZIP':\n- decoded_data = base64.standard_b64decode(data)\n- data = zlib.decompress(decoded_data, 16 + zlib.MAX_WBITS).decode('utf-8')\n- else:\n- data = base64.standard_b64decode(data).decode('utf-8')\n-\n- decrypted_payload += data\n-\n- return json.loads(decrypted_payload)\n-\ndef has_1080p(manifest):\n\"\"\"Return True if any of the video tracks in manifest have a 1080p profile\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "+# -*- coding: utf-8 -*-\n+\"\"\"\n+ Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n+ Copyright (C) 2017 Trummerjo (original implementation module)\n+ Proxy service to convert manifest and provide license data\n+\n+ SPDX-License-Identifier: MIT\n+ See LICENSES/MIT.md for more information.\n+\"\"\"\n+from __future__ import absolute_import, division, unicode_literals\n+\n+import base64\n+import json\n+import re\n+import time\n+import zlib\n+from functools import wraps\n+\n+import requests\n+\n+import resources.lib.common as common\n+import resources.lib.kodi.ui as ui\n+from resources.lib.globals import g\n+from resources.lib.services.msl.exceptions import MSLError\n+from resources.lib.services.msl.request_builder import MSLRequestBuilder\n+\n+try: # Python 2\n+ unicode\n+except NameError: # Python 3\n+ unicode = str # pylint: disable=redefined-builtin\n+\n+\n+CHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\n+ENDPOINTS = {\n+ 'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n+ 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router'\n+}\n+\n+\n+def display_error_info(func):\n+ \"\"\"Decorator that catches errors raise by the decorated function,\n+ displays an error info dialog in the UI and reraises the error\"\"\"\n+ # pylint: disable=missing-docstring\n+ @wraps(func)\n+ def error_catching_wrapper(*args, **kwargs):\n+ try:\n+ return func(*args, **kwargs)\n+ except Exception as exc:\n+ ui.show_error_info(common.get_local_string(30028), unicode(exc),\n+ unknown_error=not(unicode(exc)),\n+ netflix_error=isinstance(exc, MSLError))\n+ raise\n+ return error_catching_wrapper\n+\n+\n+class MSLHandlerBase(object):\n+ \"\"\"Handles session management and crypto for license, manifest and event requests\"\"\"\n+ last_license_url = ''\n+ last_drm_context = ''\n+ last_playback_context = ''\n+ session = requests.session()\n+\n+ def __init__(self):\n+ self.request_builder = None\n+\n+ def check_mastertoken_validity(self):\n+ \"\"\"Return the mastertoken validity and executes a new key handshake when necessary\"\"\"\n+ if self.request_builder.crypto.mastertoken:\n+ time_now = time.time()\n+ renewable = self.request_builder.crypto.renewal_window < time_now\n+ expired = self.request_builder.crypto.expiration <= time_now\n+ else:\n+ renewable = False\n+ expired = True\n+ if expired:\n+ if not self.request_builder.crypto.mastertoken:\n+ common.debug('Stored MSL data not available, a new key handshake will be performed')\n+ self.request_builder = MSLRequestBuilder()\n+ else:\n+ common.debug('Stored MSL data is expired, a new key handshake will be performed')\n+ if self.perform_key_handshake():\n+ self.request_builder = MSLRequestBuilder(json.loads(\n+ common.load_file('msl_data.json')))\n+ return self.check_mastertoken_validity()\n+ return {'renewable': renewable, 'expired': expired}\n+\n+\n+ @display_error_info\n+ @common.time_execution(immediate=True)\n+ def perform_key_handshake(self, data=None):\n+ \"\"\"Perform a key handshake and initialize crypto keys\"\"\"\n+ # pylint: disable=unused-argument\n+ esn = data or g.get_esn()\n+ if not esn:\n+ common.info('Cannot perform key handshake, missing ESN')\n+ return False\n+\n+ common.debug('Performing key handshake. ESN: {}', esn)\n+\n+ response = _process_json_response(\n+ self._post(ENDPOINTS['manifest'],\n+ self.request_builder.handshake_request(esn)))\n+ header_data = self.request_builder.decrypt_header_data(response['headerdata'], False)\n+ self.request_builder.crypto.parse_key_response(header_data, not common.is_edge_esn(esn))\n+ # Reset the user id token\n+ self.request_builder.user_id_token = None\n+ common.debug('Key handshake successful')\n+ return True\n+\n+ @common.time_execution(immediate=True)\n+ def _chunked_request(self, endpoint, request_data, esn, mt_validity=None):\n+ \"\"\"Do a POST request and process the chunked response\"\"\"\n+ chunked_response = self._process_chunked_response(\n+ self._post(endpoint, self.request_builder.msl_request(request_data, esn)),\n+ mt_validity['renewable'] if mt_validity else None)\n+ return chunked_response['result']\n+\n+ @common.time_execution(immediate=True)\n+ def _post(self, endpoint, request_data):\n+ \"\"\"Execute a post request\"\"\"\n+ common.debug('Executing POST request to {}', endpoint)\n+ start = time.clock()\n+ response = self.session.post(endpoint, request_data)\n+ common.debug('Request took {}s', time.clock() - start)\n+ common.debug('Request returned response with status {}', response.status_code)\n+ response.raise_for_status()\n+ return response\n+\n+ # pylint: disable=unused-argument\n+ @common.time_execution(immediate=True)\n+ def _process_chunked_response(self, response, mt_renewable):\n+ \"\"\"Parse and decrypt an encrypted chunked response. Raise an error\n+ if the response is plaintext json\"\"\"\n+ try:\n+ # if the json() does not fail we have an error because\n+ # the expected response is a chunked json response\n+ return _raise_if_error(response.json())\n+ except ValueError:\n+ # json() failed so parse and decrypt the chunked response\n+ common.debug('Received encrypted chunked response')\n+ response = _parse_chunks(response.text)\n+ # TODO: sending for the renewal request is not yet implemented\n+ # if mt_renewable:\n+ # # Check if mastertoken is renewed\n+ # self.request_builder.crypto.compare_mastertoken(response['header']['mastertoken'])\n+\n+ header_data = self.request_builder.decrypt_header_data(\n+ response['header'].get('headerdata'))\n+\n+ if 'useridtoken' in header_data:\n+ # After the first call, it is possible get the 'user id token' that contains the\n+ # user identity to use instead of 'User Authentication Data' with user credentials\n+ self.request_builder.user_id_token = header_data['useridtoken']\n+ # if 'keyresponsedata' in header_data:\n+ # common.debug('Found key handshake in response data')\n+ # # Update current mastertoken\n+ # self.request_builder.crypto.parse_key_response(header_data, True)\n+ decrypted_response = _decrypt_chunks(response['payloads'], self.request_builder.crypto)\n+ return _raise_if_error(decrypted_response)\n+\n+\[email protected]_execution(immediate=True)\n+def _process_json_response(response):\n+ \"\"\"Execute a post request and expect a JSON response\"\"\"\n+ try:\n+ return _raise_if_error(response.json())\n+ except ValueError:\n+ raise MSLError('Expected JSON response, got {}'.format(response.text))\n+\n+\n+def _raise_if_error(decoded_response):\n+ raise_error = False\n+ # Catch a manifest/chunk error\n+ if any(key in decoded_response for key in ['error', 'errordata']):\n+ raise_error = True\n+ # Catch a license error\n+ if 'result' in decoded_response and isinstance(decoded_response.get('result'), list):\n+ if 'error' in decoded_response['result'][0]:\n+ raise_error = True\n+ if raise_error:\n+ common.error('Full MSL error information:')\n+ common.error(json.dumps(decoded_response))\n+ raise MSLError(_get_error_details(decoded_response))\n+ return decoded_response\n+\n+\n+def _get_error_details(decoded_response):\n+ # Catch a chunk error\n+ if 'errordata' in decoded_response:\n+ return json.loads(\n+ base64.standard_b64decode(\n+ decoded_response['errordata']))['errormsg']\n+ # Catch a manifest error\n+ if 'error' in decoded_response:\n+ if decoded_response['error'].get('errorDisplayMessage'):\n+ return decoded_response['error']['errorDisplayMessage']\n+ # Catch a license error\n+ if 'result' in decoded_response and isinstance(decoded_response.get('result'), list):\n+ if 'error' in decoded_response['result'][0]:\n+ if decoded_response['result'][0]['error'].get('errorDisplayMessage'):\n+ return decoded_response['result'][0]['error']['errorDisplayMessage']\n+ return 'Unhandled error check log.'\n+\n+\[email protected]_execution(immediate=True)\n+def _parse_chunks(message):\n+ header = json.loads(message.split('}}')[0] + '}}')\n+ payloads = re.split(',\\\"signature\\\":\\\"[0-9A-Za-z=/+]+\\\"}',\n+ message.split('}}')[1])\n+ payloads = [x + '}' for x in payloads][:-1]\n+ return {'header': header, 'payloads': payloads}\n+\n+\[email protected]_execution(immediate=True)\n+def _decrypt_chunks(chunks, crypto):\n+ decrypted_payload = ''\n+ for chunk in chunks:\n+ payloadchunk = json.loads(chunk)\n+ payload = payloadchunk.get('payload')\n+ decoded_payload = base64.standard_b64decode(payload)\n+ encryption_envelope = json.loads(decoded_payload)\n+ # Decrypt the text\n+ plaintext = crypto.decrypt(\n+ base64.standard_b64decode(encryption_envelope['iv']),\n+ base64.standard_b64decode(encryption_envelope.get('ciphertext')))\n+ # unpad the plaintext\n+ plaintext = json.loads(plaintext)\n+ data = plaintext.get('data')\n+\n+ # uncompress data if compressed\n+ if plaintext.get('compressionalgo') == 'GZIP':\n+ decoded_data = base64.standard_b64decode(data)\n+ data = zlib.decompress(decoded_data, 16 + zlib.MAX_WBITS).decode('utf-8')\n+ else:\n+ data = base64.standard_b64decode(data).decode('utf-8')\n+\n+ decrypted_payload += data\n+\n+ return json.loads(decrypted_payload)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | msl_handler divided into two classes |
106,046 | 03.02.2020 17:10:16 | -3,600 | 24cab9b199c8d3b2de771aa8742d51f83645ce2e | Build messages in a common way | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -17,7 +17,7 @@ import xbmcaddon\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.cache as cache\n-from .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info\n+from .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info, build_request_data\nfrom .request_builder import MSLRequestBuilder\nfrom .profiles import enabled_profiles\n@@ -124,13 +124,7 @@ class MSLHandler(MSLHandlerBase):\nif g.ADDON.getSettingBool('enable_force_hdcp') and hdcp:\nhdcp_version = ['2.2']\n- timestamp = int(time.time() * 10000)\n- manifest_request_data = {\n- 'version': 2,\n- 'url': '/manifest',\n- 'id': timestamp,\n- 'languages': [g.LOCAL_DB.get_value('locale_id')],\n- 'params': {\n+ params = {\n'type': 'standard',\n'viewableId': [viewable_id],\n'profiles': profiles,\n@@ -163,14 +157,12 @@ class MSLHandler(MSLHandlerBase):\n'isHdcpEngaged': hdcp\n}],\n'preferAssistiveAudio': False\n- },\n- 'echo': ''\n}\n# Get and check mastertoken validity\nmt_validity = self.check_mastertoken_validity()\nmanifest = self._chunked_request(ENDPOINTS['manifest'],\n- manifest_request_data,\n+ build_request_data('/manifest', params),\nesn,\nmt_validity)\nif common.is_debug_verbose():\n@@ -189,27 +181,24 @@ class MSLHandler(MSLHandlerBase):\n\"\"\"\nRequests and returns a license for the given challenge and sid\n:param challenge: The base64 encoded challenge\n- :param sid: The sid paired to the challengew\n- :return: Base64 representation of the licensekey or False unsuccessfull\n+ :param sid: The sid paired to the challenge\n+ :return: Base64 representation of the license key or False unsuccessful\n\"\"\"\ncommon.debug('Requesting license')\n- timestamp = int(time.time() * 10000)\n- license_request_data = {\n- 'version': 2,\n- 'url': self.last_license_url,\n- 'id': timestamp,\n- 'languages': [g.LOCAL_DB.get_value('locale_id')],\n- 'params': [{\n+ timestamp = int(time.time() * 10000)\n+ params = [{\n'sessionId': sid,\n'clientTime': int(timestamp / 10000),\n'challengeBase64': challenge,\n'xid': str(timestamp + 1610)\n- }],\n- 'echo': 'sessionId'\n- }\n+ }]\n+\n+ url = self.last_license_url\n- response = self._chunked_request(ENDPOINTS['license'], license_request_data, g.get_esn())\n+ response = self._chunked_request(ENDPOINTS['license'],\n+ build_request_data(url, params, 'sessionId'),\n+ g.get_esn())\nreturn response[0]['licenseResponseBase64']\[email protected]_execution(immediate=True)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "@@ -159,6 +159,22 @@ class MSLHandlerBase(object):\nreturn _raise_if_error(decrypted_response)\n+def build_request_data(url, params=None, echo=''):\n+ \"\"\"Create a standard request data\"\"\"\n+ if not params:\n+ raise Exception('Cannot build the message without parameters')\n+ timestamp = int(time.time() * 10000)\n+ request_data = {\n+ 'version': 2,\n+ 'url': url,\n+ 'id': timestamp,\n+ 'languages': [g.LOCAL_DB.get_value('locale_id')],\n+ 'params': params,\n+ 'echo': echo\n+ }\n+ return request_data\n+\n+\[email protected]_execution(immediate=True)\ndef _process_json_response(response):\n\"\"\"Execute a post request and expect a JSON response\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Build messages in a common way |
106,046 | 21.12.2019 13:14:44 | -3,600 | 0e63027f98747b3840de01b7f14e6b2542f0930e | Added onSkip, onPause | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/action_manager.py",
"new_path": "resources/lib/services/playback/action_manager.py",
"diff": "@@ -64,6 +64,18 @@ class PlaybackActionManager(object):\n\"\"\"\nself._call_if_enabled(self._on_tick, player_state=player_state)\n+ def on_playback_seek(self, player_state):\n+ \"\"\"\n+ Notify that a playback has seek\n+ \"\"\"\n+ self._call_if_enabled(self._on_playback_seek, player_state=player_state)\n+\n+ def on_playback_pause(self, player_state):\n+ \"\"\"\n+ Notify that the playback is actually in pause\n+ \"\"\"\n+ self._call_if_enabled(self._on_playback_pause, player_state=player_state)\n+\ndef on_playback_stopped(self):\n\"\"\"\nNotify that a playback has stopped\n@@ -89,5 +101,11 @@ class PlaybackActionManager(object):\ndef _on_tick(self, player_state):\nraise NotImplementedError\n+ def _on_playback_seek(self, player_state):\n+ pass\n+\n+ def _on_playback_pause(self, player_state):\n+ pass\n+\ndef _on_playback_stopped(self):\npass\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "@@ -67,6 +67,10 @@ class PlaybackController(xbmc.Monitor):\n# Because when UpNext addon play a video while we are inside Netflix addon and\n# not externally like Kodi library, the playerid become -1 this id does not exist\nself._on_playback_started()\n+ elif method == 'Player.OnSeek':\n+ self._on_playback_seek()\n+ elif method == 'Player.OnPause':\n+ self._on_playback_pause()\nelif method == 'Player.OnStop':\nself._on_playback_stopped()\nexcept Exception:\n@@ -88,6 +92,20 @@ class PlaybackController(xbmc.Monitor):\nif common.is_debug_verbose() and g.ADDON.getSettingBool('show_codec_info'):\ncommon.json_rpc('Input.ExecuteAction', {'action': 'codecinfo'})\n+ def _on_playback_seek(self):\n+ if self.tracking and self.active_player_id is not None:\n+ player_state = self._get_player_state()\n+ if player_state:\n+ self._notify_all(PlaybackActionManager.on_playback_seek,\n+ player_state)\n+\n+ def _on_playback_pause(self):\n+ if self.tracking and self.active_player_id is not None:\n+ player_state = self._get_player_state()\n+ if player_state:\n+ self._notify_all(PlaybackActionManager.on_playback_pause,\n+ player_state)\n+\ndef _on_playback_stopped(self):\nself.tracking = False\nself.active_player_id = None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added onSkip, onPause |
106,046 | 06.02.2020 16:46:13 | -3,600 | 00d650c2cf91e479fdd7a7f28fe0da4815fbade5 | Added first impl. of progress manager | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -963,3 +963,7 @@ msgstr \"\"\nmsgctxt \"#30234\"\nmsgid \"Install Up Next add-on\"\nmsgstr \"\"\n+\n+msgctxt \"#30500\"\n+msgid \"[WIP] Send/Receive progress and watched status of the videos (works only with the main profile)\"\n+msgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "@@ -17,6 +17,7 @@ import xbmc\nimport resources.lib.common as common\nfrom resources.lib.globals import g\nfrom .action_manager import PlaybackActionManager\n+from .progress_manager import ProgressManager\nfrom .resume_manager import ResumeManager\nfrom .section_skipping import SectionSkipper\nfrom .stream_continuity import StreamContinuityManager\n@@ -49,7 +50,8 @@ class PlaybackController(xbmc.Monitor):\nResumeManager(),\nSectionSkipper(),\nStreamContinuityManager(),\n- UpNextNotifier()\n+ UpNextNotifier(),\n+ ProgressManager()\n]\nself._notify_all(PlaybackActionManager.initialize, data)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "+# -*- coding: utf-8 -*-\n+\"\"\"\n+ Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n+ Copyright (C) 2019 Stefano Gottardo - @CastagnaIT (original implementation module)\n+ Manages events to send to the netflix service for the progress of the played video\n+\n+ SPDX-License-Identifier: MIT\n+ See LICENSES/MIT.md for more information.\n+\"\"\"\n+from __future__ import absolute_import, division, unicode_literals\n+\n+import resources.lib.common as common\n+\n+from .action_manager import PlaybackActionManager\n+\n+\n+class ProgressManager(PlaybackActionManager):\n+ \"\"\"Detect the progress of the played video and send the data to the netflix service\"\"\"\n+\n+ def __init__(self): # pylint: disable=super-on-old-class\n+ super(ProgressManager, self).__init__()\n+ self.current_videoid = None\n+ self.wait_for_first_start_event = True\n+ self.last_tick_count = 0\n+ self.tick_elapsed = 0\n+ self.last_player_state = {}\n+ self.is_video_started = False\n+\n+ def _initialize(self, data):\n+ videoid = common.VideoId.from_dict(data['videoid'])\n+ if videoid.mediatype not in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\n+ self.enabled = False\n+ return\n+ self.current_videoid = videoid \\\n+ if videoid.mediatype == common.VideoId.MOVIE \\\n+ else videoid.derive_parent(0)\n+\n+ def _on_playback_started(self, player_state):\n+ self.tick_elapsed = 0\n+ self.player_elapsed_time = 0\n+ self.send_first_start_event = True\n+ self.is_video_started = True\n+\n+ def _on_tick(self, player_state):\n+ if not self.is_video_started:\n+ return\n+ if self.wait_for_first_start_event:\n+ # Before start we have to wait a possible values changed by stream_continuity\n+ if self.tick_elapsed == 2:\n+ # Is needed to wait at least 2 seconds\n+ self.wait_for_first_start_event = False\n+ else:\n+ # Generate events to send to Netflix service every 1 minute\n+ if (self.tick_elapsed - self.last_tick_count) / 60 >= 1:\n+ # Todo: identify a possible fast forward / rewind\n+ # send event\n+ self.last_tick_count = self.tick_elapsed\n+ self.last_player_state = player_state\n+\n+ # Todo: One tick should be one second but _on_tick is called in sequence between all classes,\n+ # then will have to be reviewed in the future\n+ self.tick_elapsed += 1 # One tick is one second\n+\n+ def _on_playback_stopped(self):\n+ # Generate events to send to Netflix service\n+ # Todo: send event\n+ pass\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"ResumeManager_enabled\" type=\"bool\" label=\"30176\" default=\"true\"/>\n<setting id=\"ResumeManager_dialog\" type=\"bool\" label=\"30177\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"forced_subtitle_workaround\" type=\"bool\" label=\"30181\" default=\"true\" />\n+ <setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30500\" default=\"true\"/>\n</category>\n<category label=\"30023\"><!--Expert-->\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added first impl. of progress manager |
106,046 | 03.02.2020 19:00:15 | -3,600 | aa49abf8840a333b6d36d84b6721f5a5a11a4f05 | Add api url and required path data | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/paths.py",
"new_path": "resources/lib/api/paths.py",
"diff": "@@ -39,7 +39,7 @@ ART_PARTIAL_PATHS = [\n]\nVIDEO_LIST_PARTIAL_PATHS = [\n- [['summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue',\n+ [['requestId', 'summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue',\n'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount',\n'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition',\n'dpSupplementalMessage', 'watched', 'delivery']],\n@@ -64,9 +64,9 @@ SEASONS_PARTIAL_PATHS = [\n] + ART_PARTIAL_PATHS\nEPISODES_PARTIAL_PATHS = [\n- [['summary', 'synopsis', 'title', 'runtime', 'releaseYear', 'queue',\n+ [['requestId', 'summary', 'synopsis', 'title', 'runtime', 'releaseYear', 'queue',\n'info', 'maturity', 'userRating', 'bookmarkPosition', 'creditsOffset',\n- 'watched', 'delivery']],\n+ 'watched', 'delivery', 'trackIds']],\n[['genres', 'tags', 'creators', 'directors', 'cast'],\n{'from': 0, 'to': 10}, ['id', 'name']]\n] + ART_PARTIAL_PATHS\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "@@ -33,7 +33,8 @@ except NameError: # Python 3\nCHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\nENDPOINTS = {\n'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n- 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router'\n+ 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router',\n+ 'events': CHROME_BASE_URL + 'pbo_events/%5E1.0.0/router'\n}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add api url and required path data |
106,046 | 03.02.2020 19:51:11 | -3,600 | 347902f2a80b0b374f719c64dc60177dbbb11c34 | Send event data to playback controller | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -71,9 +71,23 @@ def play(videoid):\nlist_item = get_inputstream_listitem(videoid)\ninfos, art = infolabels.add_info_for_playback(videoid, list_item, is_up_next_enabled)\n+ resume_position = {}\n+ event_data = {}\n+\n+ if g.ADDON.getSettingBool('ProgressManager_enabled'):\n+ event_data = _get_event_data(videoid)\n+ event_data['videoid'] = videoid.to_dict()\n+ event_data['is_played_by_library'] = g.IS_SKIN_CALL\n+ if event_data['resume_position']:\n+ # Todo: This is for test purpose,\n+ # set watched and resume data to list items in the get lists methods\n+ common.debug('Resume from last saved Netflix position: {}', event_data['resume_position'])\n+ list_item.setProperty('ResumeTime', str(event_data['resume_position']))\n+ list_item.setProperty('TotalTime', str(event_data['runtime']))\n+ elif g.IS_SKIN_CALL:\n# Workaround for resuming strm files from library\nresume_position = infos.get('resume', {}).get('position') \\\n- if g.IS_SKIN_CALL and g.ADDON.getSettingBool('ResumeManager_enabled') else None\n+ if g.ADDON.getSettingBool('ResumeManager_enabled') else None\nif resume_position:\nindex_selected = ui.ask_for_resume(resume_position) if g.ADDON.getSettingBool('ResumeManager_dialog') else None\nif index_selected == -1:\n@@ -99,7 +113,8 @@ def play(videoid):\n'art': art,\n'timeline_markers': get_timeline_markers(metadata[0]),\n'upnext_info': upnext_info,\n- 'resume_position': resume_position}, non_blocking=True)\n+ 'resume_position': resume_position,\n+ 'event_data': event_data}, non_blocking=True)\nxbmcplugin.setResolvedUrl(\nhandle=g.PLUGIN_HANDLE,\nsucceeded=True,\n@@ -152,6 +167,28 @@ def _verify_pin(pin_required):\nreturn None if not pin else api.verify_pin(pin)\n+def _get_event_data(videoid):\n+ \"\"\"Get data needed to send event requests to Netflix and for resume from last position\"\"\"\n+ api_data = api.single_info(videoid)\n+ if not api_data:\n+ return {}\n+ # Todo: request via api only data needed\n+ videoid_data = api_data['videos'][videoid.value]\n+ common.debug('Event data: {}', videoid_data)\n+\n+ event_data = {'resume_position': videoid_data['bookmarkPosition']\n+ if videoid_data['bookmarkPosition'] > -1 else None,\n+ 'runtime': videoid_data['runtime'],\n+ 'request_id': videoid_data['requestId'],\n+ 'watched': videoid_data['watched'],\n+ 'is_in_mylist': videoid_data['queue'].get('inQueue', False)}\n+ if videoid.mediatype == common.VideoId.EPISODE:\n+ event_data['track_id'] = videoid_data['trackIds']['trackId_jawEpisode']\n+ else:\n+ event_data['track_id'] = videoid_data['trackIds']['trackId_jaw']\n+ return event_data\n+\n+\[email protected]_execution(immediate=False)\ndef get_upnext_info(videoid, current_episode, metadata):\n\"\"\"Determine next episode and send an AddonSignal to UpNext addon\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Send event data to playback controller |
106,046 | 03.02.2020 19:59:31 | -3,600 | eac2edf1479d128b7f5a74862013ab3e1d2bc18d | Moved out chunk_request from internal | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -161,7 +161,7 @@ class MSLHandler(MSLHandlerBase):\n# Get and check mastertoken validity\nmt_validity = self.check_mastertoken_validity()\n- manifest = self._chunked_request(ENDPOINTS['manifest'],\n+ manifest = self.chunked_request(ENDPOINTS['manifest'],\nbuild_request_data('/manifest', params),\nesn,\nmt_validity)\n@@ -196,7 +196,7 @@ class MSLHandler(MSLHandlerBase):\nurl = self.last_license_url\n- response = self._chunked_request(ENDPOINTS['license'],\n+ response = self.chunked_request(ENDPOINTS['license'],\nbuild_request_data(url, params, 'sessionId'),\ng.get_esn())\nreturn response[0]['licenseResponseBase64']\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "@@ -109,7 +109,7 @@ class MSLHandlerBase(object):\nreturn True\[email protected]_execution(immediate=True)\n- def _chunked_request(self, endpoint, request_data, esn, mt_validity=None):\n+ def chunked_request(self, endpoint, request_data, esn, mt_validity=None):\n\"\"\"Do a POST request and process the chunked response\"\"\"\nchunked_response = self._process_chunked_response(\nself._post(endpoint, self.request_builder.msl_request(request_data, esn)),\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Moved out chunk_request from internal |
106,046 | 06.02.2020 16:53:18 | -3,600 | 695554ad9711a2a934e2a7edca3c41d488e4ed7c | Added first impl. events_hadler | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/ipc.py",
"new_path": "resources/lib/common/ipc.py",
"diff": "@@ -35,6 +35,7 @@ class Signals(object): # pylint: disable=no-init\nLIBRARY_UPDATE_REQUESTED = 'library_update_requested'\nUPNEXT_ADDON_INIT = 'upnext_data'\nINVALIDATE_SERVICE_CACHE = 'invalidate_service_cache'\n+ QUEUE_VIDEO_EVENT = 'queue_video_event'\ndef register_slot(callback, signal=None, source_id=None):\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "+# -*- coding: utf-8 -*-\n+\"\"\"\n+ Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n+ Copyright (C) 2019 Stefano Gottardo - @CastagnaIT (original implementation module)\n+ Handle and build Netflix events\n+\n+ SPDX-License-Identifier: MIT\n+ See LICENSES/MIT.md for more information.\n+\"\"\"\n+from __future__ import absolute_import, division, unicode_literals\n+\n+import random\n+import threading\n+import time\n+\n+try: # Python 2\n+ from urllib import urlencode\n+except ImportError: # Python 3\n+ from urllib.parse import urlencode\n+\n+import xbmc\n+\n+import resources.lib.cache as cache\n+from resources.lib import common\n+from resources.lib.database.db_utils import TABLE_SESSION\n+from resources.lib.globals import g\n+from resources.lib.services.msl import event_tag_builder\n+from resources.lib.services.msl.msl_handler_base import build_request_data, ENDPOINTS\n+\n+try:\n+ import Queue as queue\n+except ImportError: # Python 3\n+ import queue\n+\n+EVENT_START = 'start' # events/start : Video starts (seem also after a ff/rw)\n+EVENT_STOP = 'stop' # events/stop : Video stops (seem also after a ff/rw)\n+EVENT_KEEP_ALIVE = 'keepAlive' # events/keepAlive : Update progress status\n+EVENT_ENGAGE = 'engage' # events/engage : After user interaction (e.g. before send stop)\n+EVENT_BIND = 'bind' # events/bind : ?\n+\n+\n+class Event(object):\n+ \"\"\"Object representing an event request to be processed\"\"\"\n+\n+ STATUS_REQUESTED = 'REQUESTED'\n+ STATUS_INQUEUE = 'IN_QUEUE'\n+ STATUS_ERROR = 'ERROR'\n+ STATUS_SUCCESS = 'SUCCESS'\n+\n+ def __init__(self, event_data):\n+ self.event_type = event_data['params']['event']\n+ common.debug('Event type [{}] added to queue: {}', self.event_type, event_data)\n+ self.status = self.STATUS_INQUEUE\n+ self.request_data = event_data\n+ self.response_data = None\n+ self.req_attempt = 0\n+\n+ def get_event_id(self):\n+ return self.request_data['xid']\n+\n+ def set_response(self, response):\n+ self.response_data = response\n+ common.debug('Event type [{}] response: {}', self.event_type, response)\n+ # Todo check for possible error in response and set right status\n+ self.status = self.STATUS_ERROR\n+ self.status = self.STATUS_SUCCESS\n+\n+ def is_response_success(self):\n+ return self.status == self.STATUS_SUCCESS\n+\n+ def is_attempts_granted(self):\n+ \"\"\"Returns True if you can make new request attempts\"\"\"\n+ self.req_attempt += 1\n+ return True if self.req_attempt <= 3 else False\n+\n+ def __str__(self):\n+ return self.event_type\n+\n+\n+class EventsHandler(threading.Thread):\n+ \"\"\"Handle and build Netflix event requests\"\"\"\n+\n+ def __init__(self, chunked_request):\n+ super(EventsHandler, self).__init__()\n+ self.chunked_request = chunked_request\n+ # session_id, app_id are common to all events\n+ self.session_id = int(time.time()) * 10000 + random.randint(1, 10001)\n+ self.app_id = None\n+ self.queue_events = queue.Queue(maxsize=10)\n+ self.cache_data_events = {}\n+ self.banned_events_ids = []\n+ common.register_slot(signal=common.Signals.QUEUE_VIDEO_EVENT, callback=self.callback_event_video_queue)\n+\n+ def run(self):\n+ \"\"\"Monitor and process the event queue\"\"\"\n+ common.debug('[Event queue monitor] Thread started')\n+ monitor = xbmc.Monitor()\n+ while not monitor.abortRequested():\n+ try:\n+ # Take the first queued item\n+ event = self.queue_events.get_nowait()\n+ # Process the request\n+ continue_queue = self._process_event_request(event)\n+ if not continue_queue:\n+ # Ban future requests from this event id\n+ self.banned_events_ids += [event.get_event_id()]\n+ except queue.Empty:\n+ pass\n+ monitor.waitForAbort(0.5)\n+\n+ def _process_event_request(self, event):\n+ \"\"\"Do the event post request\"\"\"\n+ event.status = Event.STATUS_REQUESTED\n+ # Request attempts can be made up to a maximum of 3 times per event\n+ while event.is_attempts_granted():\n+ common.info('Perform event request [{}] (attempt {})', event, event.req_attempt)\n+ params = {'reqAttempt': event.req_attempt,\n+ 'reqPriority': 20 if event.event_type == EVENT_START else 0,\n+ 'reqName': 'events/{}'.format(event)}\n+ url = ENDPOINTS['events'] + '?' + urlencode(params).replace('%2F', '/')\n+ try:\n+ response = self.chunked_request(url, event.request_data, g.get_esn())\n+ event.set_response(response)\n+ break\n+ except Exception as exc:\n+ common.error('Event request [{}] failed: {}', event, exc)\n+ if event.event_type == EVENT_STOP:\n+ self.clear_queue()\n+ if event.event_type == EVENT_START and not event.is_response_success():\n+ # If 'start' event was unsuccessful,\n+ # no longer make any future requests from this event id\n+ return False\n+ return True\n+\n+ def callback_event_video_queue(self, data=None):\n+ \"\"\"Callback to add a video event\"\"\"\n+ self.add_event_to_queue(data['event_type'], data['event_data'], data['player_state'])\n+\n+ def add_event_to_queue(self, event_type, event_data, player_state):\n+ \"\"\"Adds an event in the queue of events to be processed\"\"\"\n+ videoid = common.VideoId.from_dict(event_data['videoid'])\n+ previous_data = self.cache_data_events.get(videoid.value, {})\n+ manifest = get_manifest(videoid)\n+ url = manifest['links']['events']['href']\n+\n+ if previous_data.get('xid') in self.banned_events_ids:\n+ common.warn('Event [{}] not added, is banned for a previous request event error',\n+ event_type)\n+ return\n+\n+ event_data = build_request_data(url, self._build_event_params(event_type,\n+ event_data,\n+ player_state,\n+ manifest))\n+ try:\n+ self.queue_events.put_nowait(Event(event_data))\n+ except queue.Full:\n+ common.warn('Events queue is full, event [{}] not queued', event_type)\n+\n+ def clear_queue(self):\n+ \"\"\"Clear all queued events\"\"\"\n+ with self.queue_events.mutex:\n+ self.queue_events.queue.clear()\n+ self.cache_data_events = {}\n+ self.banned_events_ids = []\n+\n+ def _build_event_params(self, event_type, event_data, player_state, manifest):\n+ \"\"\"Build data params for an event request\"\"\"\n+ videoid = common.VideoId.from_dict(event_data['videoid'])\n+ # Get previous elaborated data of the same video id\n+ # Some tags must remain unchanged between events\n+ previous_data = self.cache_data_events.get(videoid.value, {})\n+ timestamp = int(time.time() * 10000)\n+\n+ # Context location values can be easily viewed from tag data-ui-tracking-context\n+ # of a preview box in website html\n+ play_ctx_location = 'WATCHNOW' # We currently leave a fixed value, we leave support for future changes\n+ # play_ctx_location = 'MyListAsGallery' if event_data['is_in_mylist'] else 'browseTitles'\n+\n+ # To now it is not mandatory, we leave support for future changes\n+ # if event_data['is_played_by_library']:\n+ # list_id = 'unknown'\n+ # else:\n+ # list_id = g.LOCAL_DB.get_value('last_menu_id', 'unknown')\n+\n+ params = {\n+ 'event': event_type,\n+ 'xid': previous_data.get('xid', str(timestamp + 1610)),\n+ 'position': player_state['elapsed_seconds'] * 1000, # Video time elapsed\n+ 'clientTime': timestamp,\n+ 'sessionStartTime': previous_data.get('sessionStartTime', timestamp),\n+ 'mediaId': event_tag_builder.get_media_id(videoid, player_state, manifest),\n+ 'trackId': str(event_data['track_id']),\n+ 'sessionId': str(self.session_id),\n+ 'appId': str(self.app_id or self.session_id),\n+ 'playTimes': event_tag_builder.get_play_times(videoid, player_state, manifest),\n+ 'sessionParams': previous_data.get('sessionParams', {\n+ 'isUIAutoPlay': False, # Should be set equal to the one in the manifest\n+ 'supportsPreReleasePin': True, # Should be set equal to the one in the manifest\n+ 'supportsWatermark': True, # Should be set equal to the one in the manifest\n+ 'preferUnletterboxed': True, # Should be set equal to the one in the manifest\n+ 'uiplaycontext': {\n+ # 'list_id': list_id, # not mandatory\n+ # 'lolomo_id': g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION), # not mandatory\n+ 'location': play_ctx_location,\n+ 'rank': 0, # Perhaps this is a reference of cdn rank used in the manifest? (we use always 0)\n+ 'request_id': event_data['request_id'],\n+ 'row': 0, # Purpose not known\n+ 'track_id': event_data['track_id'],\n+ 'video_id': videoid.value\n+ }\n+ })\n+ }\n+\n+ if event_type == EVENT_ENGAGE:\n+ params['action'] = 'User_Interaction'\n+\n+ self.cache_data_events[videoid.value] = params\n+ return params\n+\n+\n+def get_manifest(videoid):\n+ \"\"\"Get the manifest from cache\"\"\"\n+ cache_identifier = g.get_esn() + '_' + videoid.value\n+ return g.CACHE.get(cache.CACHE_MANIFESTS, cache_identifier, False)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -17,6 +17,7 @@ import xbmcaddon\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.cache as cache\n+from .events_handler import EventsHandler\nfrom .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info, build_request_data\nfrom .request_builder import MSLRequestBuilder\n@@ -51,6 +52,9 @@ class MSLHandler(MSLHandlerBase):\n# Addon just installed, the service starts but there is no esn\nif g.get_esn():\nself.check_mastertoken_validity()\n+\n+ events_handler = EventsHandler(self.chunked_request)\n+ events_handler.start()\nexcept Exception:\nimport traceback\ncommon.error(traceback.format_exc())\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "from __future__ import absolute_import, division, unicode_literals\nimport resources.lib.common as common\n-\n+from resources.lib.services.msl.events_handler import EVENT_STOP, EVENT_KEEP_ALIVE, EVENT_START\nfrom .action_manager import PlaybackActionManager\n@@ -20,6 +20,7 @@ class ProgressManager(PlaybackActionManager):\ndef __init__(self): # pylint: disable=super-on-old-class\nsuper(ProgressManager, self).__init__()\nself.current_videoid = None\n+ self.event_data = {}\nself.wait_for_first_start_event = True\nself.last_tick_count = 0\nself.tick_elapsed = 0\n@@ -34,6 +35,7 @@ class ProgressManager(PlaybackActionManager):\nself.current_videoid = videoid \\\nif videoid.mediatype == common.VideoId.MOVIE \\\nelse videoid.derive_parent(0)\n+ self.event_data = data['event_data']\ndef _on_playback_started(self, player_state):\nself.tick_elapsed = 0\n@@ -48,12 +50,13 @@ class ProgressManager(PlaybackActionManager):\n# Before start we have to wait a possible values changed by stream_continuity\nif self.tick_elapsed == 2:\n# Is needed to wait at least 2 seconds\n+ _send_event(EVENT_START, self.event_data, player_state)\nself.wait_for_first_start_event = False\nelse:\n# Generate events to send to Netflix service every 1 minute\nif (self.tick_elapsed - self.last_tick_count) / 60 >= 1:\n# Todo: identify a possible fast forward / rewind\n- # send event\n+ _send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\nself.last_tick_count = self.tick_elapsed\nself.last_player_state = player_state\n@@ -62,6 +65,12 @@ class ProgressManager(PlaybackActionManager):\nself.tick_elapsed += 1 # One tick is one second\ndef _on_playback_stopped(self):\n- # Generate events to send to Netflix service\n- # Todo: send event\n- pass\n+ _send_event(EVENT_STOP, self.event_data, self.last_player_state)\n+\n+\n+def _send_event(event_type, event_data, player_state):\n+ common.send_signal(common.Signals.QUEUE_VIDEO_EVENT, {\n+ 'event_type': event_type,\n+ 'event_data': event_data,\n+ 'player_state': player_state\n+ }, non_blocking=True)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added first impl. events_hadler |
106,046 | 04.02.2020 09:33:33 | -3,600 | 01b9f9fdff2b2c60ba9a26702c9bf924c6def3aa | Get from path-req only needed event info | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/paths.py",
"new_path": "resources/lib/api/paths.py",
"diff": "@@ -75,6 +75,10 @@ TRAILER_PARTIAL_PATHS = [\n[['availability', 'summary', 'synopsis', 'title', 'trackId', 'delivery', 'runtime']]\n] + ART_PARTIAL_PATHS\n+EVENT_PATHS = [\n+ [['requestId', 'title', 'runtime', 'queue', 'bookmarkPosition', 'watched', 'trackIds']]\n+]\n+\nVIDEO_LIST_RATING_THUMB_PATHS = [\n[['summary', 'title', 'userRating', 'trackIds']]\n]\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -21,7 +21,7 @@ from .data_types import (LoLoMo, VideoList, VideoListSorted, SeasonList, Episode\nfrom .paths import (VIDEO_LIST_PARTIAL_PATHS, VIDEO_LIST_BASIC_PARTIAL_PATHS,\nSEASONS_PARTIAL_PATHS, EPISODES_PARTIAL_PATHS, ART_PARTIAL_PATHS,\nGENRE_PARTIAL_PATHS, RANGE_SELECTOR, MAX_PATH_REQUEST_SIZE,\n- TRAILER_PARTIAL_PATHS)\n+ TRAILER_PARTIAL_PATHS, EVENT_PATHS)\nfrom .exceptions import (InvalidVideoListTypeError, APIError, MissingCredentialsError,\nMetadataNotAvailable)\nfrom .website import parse_profiles\n@@ -269,6 +269,18 @@ def single_info(videoid):\nreturn common.make_call('path_request', paths)\[email protected]_execution(immediate=False)\n+def event_info(videoid):\n+ \"\"\"Retrieve info for the events\"\"\"\n+ if videoid.mediatype not in [common.VideoId.EPISODE, common.VideoId.MOVIE,\n+ common.VideoId.SUPPLEMENTAL]:\n+ raise common.InvalidVideoId('Cannot request event info for {}'\n+ .format(videoid))\n+ common.debug('Requesting event info for {}', videoid)\n+ paths = build_paths(['videos', videoid.value], EVENT_PATHS)\n+ return common.make_call('path_request', paths)\n+\n+\ndef custom_video_list_basicinfo(context_name, switch_profiles=False):\n\"\"\"\nRetrieve a single video list\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -169,15 +169,14 @@ def _verify_pin(pin_required):\ndef _get_event_data(videoid):\n\"\"\"Get data needed to send event requests to Netflix and for resume from last position\"\"\"\n- api_data = api.single_info(videoid)\n+ api_data = api.event_info(videoid)\nif not api_data:\nreturn {}\n- # Todo: request via api only data needed\nvideoid_data = api_data['videos'][videoid.value]\ncommon.debug('Event data: {}', videoid_data)\n- event_data = {'resume_position': videoid_data['bookmarkPosition']\n- if videoid_data['bookmarkPosition'] > -1 else None,\n+ event_data = {'resume_position':\n+ videoid_data['bookmarkPosition'] if videoid_data['bookmarkPosition'] > -1 else None,\n'runtime': videoid_data['runtime'],\n'request_id': videoid_data['requestId'],\n'watched': videoid_data['watched'],\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Get from path-req only needed event info |
106,046 | 04.02.2020 13:09:34 | -3,600 | 452872e3af0afa293a33c8d1a5bb547da08e9729 | Force event start time with 0 seconds | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "@@ -50,6 +50,7 @@ class ProgressManager(PlaybackActionManager):\n# Before start we have to wait a possible values changed by stream_continuity\nif self.tick_elapsed == 2:\n# Is needed to wait at least 2 seconds\n+ player_state['elapsed_seconds'] = 0 # Force set to 0\n_send_event(EVENT_START, self.event_data, player_state)\nself.wait_for_first_start_event = False\nelse:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Force event start time with 0 seconds |
106,046 | 06.02.2020 16:56:31 | -3,600 | 138512cec4ad7c23254788f23c038a51b24aed38 | Added first impl. event_tag_builder | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/services/msl/event_tag_builder.py",
"diff": "+# -*- coding: utf-8 -*-\n+\"\"\"\n+ Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n+ Copyright (C) 2019 Stefano Gottardo - @CastagnaIT (original implementation module)\n+ Build event tags values\n+\n+ SPDX-License-Identifier: MIT\n+ See LICENSES/MIT.md for more information.\n+\"\"\"\n+from __future__ import absolute_import, division, unicode_literals\n+\n+\n+def get_media_id(videoid, player_state, manifest):\n+ \"\"\"Try to build the mediaId by parsing manifest with the current player streams used\"\"\"\n+ # Build using 'new_track_id' tags\n+ # Format example: \"A:1:1;2;en;1;|V:2:1;2;;default;1;CE3;0;|T:1:1;1;NONE;0;1;\"\n+ return manifest['defaultTrackOrderList'][0]['mediaId'] # Todo: test purpose\n+\n+\n+def get_play_times(videoid, player_state, manifest):\n+ \"\"\"Build the playTimes dict by parsing manifest with the current player streams used\"\"\"\n+ duration = player_state['elapsed_seconds'] * 1000\n+\n+ # Todo: elaborate from manifest\n+ audio_downloadable_id = manifest['audio_tracks'][0]['streams'][0]['downloadable_id'] # Todo: test purpose\n+ video_downloadable_id = manifest['video_tracks'][0]['streams'][0]['downloadable_id'] # Todo: test purpose\n+\n+ play_times = {\n+ 'total': duration,\n+ 'audio': [{\n+ 'downloadableId': audio_downloadable_id,\n+ 'duration': duration\n+ }],\n+ 'video': [{\n+ 'downloadableId': video_downloadable_id,\n+ 'duration': duration\n+ }],\n+ 'text': []\n+ }\n+ return play_times\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added first impl. event_tag_builder |
106,046 | 05.02.2020 15:58:19 | -3,600 | 3611886dcc15a4a4b9da465fba318a71a9d5adbc | Added send events on playback pause and skip | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -32,10 +32,10 @@ try:\nexcept ImportError: # Python 3\nimport queue\n-EVENT_START = 'start' # events/start : Video starts (seem also after a ff/rw)\n-EVENT_STOP = 'stop' # events/stop : Video stops (seem also after a ff/rw)\n+EVENT_START = 'start' # events/start : Video starts\n+EVENT_STOP = 'stop' # events/stop : Video stops\nEVENT_KEEP_ALIVE = 'keepAlive' # events/keepAlive : Update progress status\n-EVENT_ENGAGE = 'engage' # events/engage : After user interaction (e.g. before send stop)\n+EVENT_ENGAGE = 'engage' # events/engage : After user interaction (before stop, on skip, on pause)\nEVENT_BIND = 'bind' # events/bind : ?\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "from __future__ import absolute_import, division, unicode_literals\nimport resources.lib.common as common\n-from resources.lib.services.msl.events_handler import EVENT_STOP, EVENT_KEEP_ALIVE, EVENT_START\n+from resources.lib.services.msl.events_handler import EVENT_STOP, EVENT_KEEP_ALIVE, EVENT_START, EVENT_ENGAGE\nfrom .action_manager import PlaybackActionManager\n@@ -48,13 +48,22 @@ class ProgressManager(PlaybackActionManager):\nelse:\n# Generate events to send to Netflix service every 1 minute\nif (self.tick_elapsed - self.last_tick_count) / 60 >= 1:\n- # Todo: identify a possible fast forward / rewind\n_send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\nself.last_tick_count = self.tick_elapsed\nself.last_player_state = player_state\nself.tick_elapsed += 1 # One tick almost always represents one second\n+ def on_playback_pause(self, player_state):\n+ self.tick_elapsed = 0\n+ _send_event(EVENT_ENGAGE, self.event_data, player_state)\n+\n+ def on_playback_seek(self, player_state):\n+ self.tick_elapsed = 0\n+ _send_event(EVENT_ENGAGE, self.event_data, player_state)\n+\ndef _on_playback_stopped(self):\n+ self.tick_elapsed = 0\n+ _send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n_send_event(EVENT_STOP, self.event_data, self.last_player_state)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added send events on playback pause and skip |
106,046 | 07.02.2020 09:39:30 | -3,600 | 3d5bda2fdf7dfc40739ac12af5fff81328790244 | Added convert language iso | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/kodiops.py",
"new_path": "resources/lib/common/kodiops.py",
"diff": "@@ -154,9 +154,7 @@ def get_kodi_audio_language():\nReturn the audio language from Kodi settings\n\"\"\"\naudio_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})\n- audio_language = xbmc.convertLanguage(g.py2_encode(audio_language['value']), xbmc.ISO_639_1)\n- audio_language = audio_language if audio_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n- return audio_language if audio_language else 'en'\n+ return convert_language_iso(audio_language['value'])\ndef get_kodi_subtitle_language():\n@@ -166,12 +164,20 @@ def get_kodi_subtitle_language():\nsubtitle_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})\nif subtitle_language['value'] == 'forced_only':\nreturn subtitle_language['value']\n- subtitle_language = xbmc.convertLanguage(g.py2_encode(subtitle_language['value']),\n- xbmc.ISO_639_1)\n- subtitle_language = subtitle_language if subtitle_language else xbmc.getLanguage(xbmc.ISO_639_1,\n- False)\n- subtitle_language = subtitle_language if subtitle_language else 'en'\n- return subtitle_language\n+ return convert_language_iso(subtitle_language['value'])\n+\n+\n+def convert_language_iso(from_value, use_fallback=True):\n+ \"\"\"\n+ Convert language code from an English name or three letter code (ISO 639-2) to two letter code (ISO 639-1)\n+\n+ :param use_fallback: if True when the conversion fails, is returned the current Kodi active language\n+ \"\"\"\n+ converted_lang = xbmc.convertLanguage(g.py2_encode(from_value), xbmc.ISO_639_1)\n+ if not use_fallback:\n+ return converted_lang\n+ converted_lang = converted_lang if converted_lang else xbmc.getLanguage(xbmc.ISO_639_1, False)\n+ return converted_lang if converted_lang else 'en'\ndef fix_locale_languages(data_list):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added convert language iso |
106,046 | 07.02.2020 09:40:00 | -3,600 | 63b864ccfe40e093248d84bfe57c9c332c6293cf | Added locale problem github issue link | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/kodiops.py",
"new_path": "resources/lib/common/kodiops.py",
"diff": "@@ -204,6 +204,7 @@ def _adjust_locale(locale_code, lang_code_without_country_exists):\nLocale conversion helper\nConversion table to prevent Kodi to display\nes-ES as Spanish - Spanish, pt-BR as Portuguese - Breton, and so on\n+ Kodi issue: https://github.com/xbmc/xbmc/issues/15308\n\"\"\"\nlocale_conversion_table = {\n'es-ES': 'es-Spain',\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added locale problem github issue link |
106,046 | 07.02.2020 10:04:47 | -3,600 | ab29b4480c652121fe916a4a44b268b7665683af | Reworked event tag builder | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/event_tag_builder.py",
"new_path": "resources/lib/services/msl/event_tag_builder.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+from resources.lib import common\n-def get_media_id(videoid, player_state, manifest):\n- \"\"\"Try to build the mediaId by parsing manifest with the current player streams used\"\"\"\n- # Build using 'new_track_id' tags\n- # Format example: \"A:1:1;2;en;1;|V:2:1;2;;default;1;CE3;0;|T:1:1;1;NONE;0;1;\"\n- return manifest['defaultTrackOrderList'][0]['mediaId'] # Todo: test purpose\n+AUDIO_CHANNELS_CONV = {1: '1.0', 2: '2.0', 6: '5.1', 8: '7.1'}\n+\n+\n+def is_media_changed(previous_player_state, player_state):\n+ \"\"\"Check if there are variations in player state to avoids overhead processing\"\"\"\n+ if not previous_player_state:\n+ return True\n+ # To now we do not check subtitle, because to the moment it is not implemented\n+ if player_state['currentvideostream'] != previous_player_state['currentvideostream'] or \\\n+ player_state['currentaudiostream'] != previous_player_state['currentaudiostream']:\n+ return True\n+ return False\n+\n+\n+def update_play_times_duration(play_times, player_state):\n+ \"\"\"Update the playTimes duration values\"\"\"\n+ duration = player_state['elapsed_seconds'] * 1000\n+ play_times['total'] = duration\n+ play_times['audio'][0]['duration'] = duration\n+ play_times['video'][0]['duration'] = duration\n-def get_play_times(videoid, player_state, manifest):\n- \"\"\"Build the playTimes dict by parsing manifest with the current player streams used\"\"\"\n+def build_media_tag(player_state, manifest):\n+ \"\"\"Build the playTimes and the mediaId data by parsing manifest and the current player streams used\"\"\"\n+ common.fix_locale_languages(manifest['audio_tracks'])\nduration = player_state['elapsed_seconds'] * 1000\n- # Todo: elaborate from manifest\n- audio_downloadable_id = manifest['audio_tracks'][0]['streams'][0]['downloadable_id'] # Todo: test purpose\n- video_downloadable_id = manifest['video_tracks'][0]['streams'][0]['downloadable_id'] # Todo: test purpose\n+ audio_downloadable_id, audio_track_id = _find_audio_data(player_state, manifest)\n+ video_downloadable_id, video_track_id = _find_video_data(player_state, manifest)\n+ # Warning 'currentsubtitle' value in player_state on Kodi 18\n+ # do not have proprieties like isdefault, isforced, isimpaired\n+ # if in the future the implementation will be done it should be available only on Kodi 19\n+ # then for now we leave the subtitles as disabled\n+\n+ text_track_id = 'T:1:1;1;NONE;0;1;'\nplay_times = {\n'total': duration,\n@@ -37,4 +59,41 @@ def get_play_times(videoid, player_state, manifest):\n}],\n'text': []\n}\n- return play_times\n+\n+ # Format example: \"A:1:1;2;en;1;|V:2:1;2;;default;1;CE3;0;|T:1:1;1;NONE;0;1;\"\n+ media_id = '|'.join([audio_track_id, video_track_id, text_track_id])\n+\n+ return play_times, media_id\n+\n+\n+def _find_audio_data(player_state, manifest):\n+ \"\"\"\n+ Find the audio downloadable id and the audio track id\n+ \"\"\"\n+ language = common.convert_language_iso(player_state['currentaudiostream']['language'])\n+ channels = AUDIO_CHANNELS_CONV[player_state['currentaudiostream']['channels']]\n+\n+ for audio_track in manifest['audio_tracks']:\n+ if audio_track['language'] == language and audio_track['channels'] == channels:\n+ # Get the stream dict with the highest bitrate\n+ stream = max(audio_track['streams'], key=lambda x: x['bitrate'])\n+ return stream['downloadable_id'], audio_track['new_track_id']\n+ # Not found?\n+ raise Exception('build_media_tag: unable to find audio data with language: {}, channels: {}'\n+ .format(language, channels))\n+\n+\n+def _find_video_data(player_state, manifest):\n+ \"\"\"\n+ Find the best match for the video downloadable id and the video track id\n+ \"\"\"\n+ codec = player_state['currentvideostream']['codec']\n+ width = player_state['currentvideostream']['width']\n+ height = player_state['currentvideostream']['height']\n+ for video_track in manifest['video_tracks']:\n+ for stream in video_track['streams']:\n+ if codec in stream['content_profile'] and width == stream['res_w'] and height == stream['res_h']:\n+ return stream['downloadable_id'], video_track['new_track_id']\n+ # Not found?\n+ raise Exception('build_media_tag: unable to find video data with codec: {}, width: {}, height: {}'\n+ .format(codec, width, height))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -22,7 +22,6 @@ import xbmc\nimport resources.lib.cache as cache\nfrom resources.lib import common\n-from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom resources.lib.services.msl import event_tag_builder\nfrom resources.lib.services.msl.msl_handler_base import build_request_data, ENDPOINTS\n@@ -49,20 +48,20 @@ class Event(object):\ndef __init__(self, event_data):\nself.event_type = event_data['params']['event']\n- common.debug('Event type [{}] added to queue: {}', self.event_type, event_data)\nself.status = self.STATUS_INQUEUE\nself.request_data = event_data\nself.response_data = None\nself.req_attempt = 0\n+ common.debug('EVENT [{}] - Added to queue', self.event_type)\ndef get_event_id(self):\nreturn self.request_data['xid']\ndef set_response(self, response):\nself.response_data = response\n- common.debug('Event type [{}] response: {}', self.event_type, response)\n- # Todo check for possible error in response and set right status\n- self.status = self.STATUS_ERROR\n+ common.debug('EVENT [{}] - Request response: {}', self.event_type, response)\n+ # Seem that malformed requests are ignored without returning errors\n+ # self.status = self.STATUS_ERROR\nself.status = self.STATUS_SUCCESS\ndef is_response_success(self):\n@@ -71,7 +70,7 @@ class Event(object):\ndef is_attempts_granted(self):\n\"\"\"Returns True if you can make new request attempts\"\"\"\nself.req_attempt += 1\n- return True if self.req_attempt <= 3 else False\n+ return bool(self.req_attempt <= 3)\ndef __str__(self):\nreturn self.event_type\n@@ -106,14 +105,14 @@ class EventsHandler(threading.Thread):\nself.banned_events_ids += [event.get_event_id()]\nexcept queue.Empty:\npass\n- monitor.waitForAbort(0.5)\n+ monitor.waitForAbort(1)\ndef _process_event_request(self, event):\n\"\"\"Do the event post request\"\"\"\nevent.status = Event.STATUS_REQUESTED\n# Request attempts can be made up to a maximum of 3 times per event\nwhile event.is_attempts_granted():\n- common.info('Perform event request [{}] (attempt {})', event, event.req_attempt)\n+ common.info('EVENT [{}] - Executing request (attempt {})', event, event.req_attempt)\nparams = {'reqAttempt': event.req_attempt,\n'reqPriority': 20 if event.event_type == EVENT_START else 0,\n'reqName': 'events/{}'.format(event)}\n@@ -122,8 +121,8 @@ class EventsHandler(threading.Thread):\nresponse = self.chunked_request(url, event.request_data, g.get_esn())\nevent.set_response(response)\nbreak\n- except Exception as exc:\n- common.error('Event request [{}] failed: {}', event, exc)\n+ except Exception as exc: # pylint: disable=broad-except\n+ common.error('EVENT [{}] - The request has failed: {}', event, exc)\nif event.event_type == EVENT_STOP:\nself.clear_queue()\nif event.event_type == EVENT_START and not event.is_response_success():\n@@ -134,28 +133,32 @@ class EventsHandler(threading.Thread):\ndef callback_event_video_queue(self, data=None):\n\"\"\"Callback to add a video event\"\"\"\n+ try:\nself.add_event_to_queue(data['event_type'], data['event_data'], data['player_state'])\n+ except Exception as exc: # pylint: disable=broad-except\n+ import traceback\n+ from resources.lib.kodi.ui import show_addon_error_info\n+ common.error(traceback.format_exc())\n+ show_addon_error_info(exc)\ndef add_event_to_queue(self, event_type, event_data, player_state):\n\"\"\"Adds an event in the queue of events to be processed\"\"\"\nvideoid = common.VideoId.from_dict(event_data['videoid'])\n- previous_data = self.cache_data_events.get(videoid.value, {})\n+ # pylint: disable=unused-variable\n+ previous_data, previous_player_state = self.cache_data_events.get(videoid.value, ({}, None))\nmanifest = get_manifest(videoid)\nurl = manifest['links']['events']['href']\nif previous_data.get('xid') in self.banned_events_ids:\n- common.warn('Event [{}] not added, is banned for a previous request event error',\n- event_type)\n+ common.warn('EVENT [{}] - Not added to the queue. The xid {} is banned due to a previous failed request',\n+ event_type, previous_data.get('xid'))\nreturn\n- event_data = build_request_data(url, self._build_event_params(event_type,\n- event_data,\n- player_state,\n- manifest))\n+ event_data = build_request_data(url, self._build_event_params(event_type, event_data, player_state, manifest))\ntry:\nself.queue_events.put_nowait(Event(event_data))\nexcept queue.Full:\n- common.warn('Events queue is full, event [{}] not queued', event_type)\n+ common.warn('EVENT [{}] - Not added to the queue. The event queue is full.', event_type)\ndef clear_queue(self):\n\"\"\"Clear all queued events\"\"\"\n@@ -169,7 +172,7 @@ class EventsHandler(threading.Thread):\nvideoid = common.VideoId.from_dict(event_data['videoid'])\n# Get previous elaborated data of the same video id\n# Some tags must remain unchanged between events\n- previous_data = self.cache_data_events.get(videoid.value, {})\n+ previous_data, previous_player_state = self.cache_data_events.get(videoid.value, ({}, None))\ntimestamp = int(time.time() * 10000)\n# Context location values can be easily viewed from tag data-ui-tracking-context\n@@ -183,22 +186,29 @@ class EventsHandler(threading.Thread):\n# else:\n# list_id = g.LOCAL_DB.get_value('last_menu_id', 'unknown')\n+ if event_tag_builder.is_media_changed(previous_player_state, player_state):\n+ play_times, media_id = event_tag_builder.build_media_tag(player_state, manifest)\n+ else:\n+ play_times = previous_data['playTimes']\n+ event_tag_builder.update_play_times_duration(play_times, player_state)\n+ media_id = previous_data['mediaId']\n+\nparams = {\n'event': event_type,\n'xid': previous_data.get('xid', str(timestamp + 1610)),\n'position': player_state['elapsed_seconds'] * 1000, # Video time elapsed\n'clientTime': timestamp,\n'sessionStartTime': previous_data.get('sessionStartTime', timestamp),\n- 'mediaId': event_tag_builder.get_media_id(videoid, player_state, manifest),\n+ 'mediaId': media_id,\n'trackId': str(event_data['track_id']),\n'sessionId': str(self.session_id),\n'appId': str(self.app_id or self.session_id),\n- 'playTimes': event_tag_builder.get_play_times(videoid, player_state, manifest),\n+ 'playTimes': play_times,\n'sessionParams': previous_data.get('sessionParams', {\n- 'isUIAutoPlay': False, # Should be set equal to the one in the manifest\n- 'supportsPreReleasePin': True, # Should be set equal to the one in the manifest\n- 'supportsWatermark': True, # Should be set equal to the one in the manifest\n- 'preferUnletterboxed': True, # Should be set equal to the one in the manifest\n+ 'isUIAutoPlay': False, # Should be set equal to the manifest request\n+ 'supportsPreReleasePin': True, # Should be set equal to the manifest request\n+ 'supportsWatermark': True, # Should be set equal to the manifest request\n+ 'preferUnletterboxed': True, # Should be set equal to the manifest request\n'uiplaycontext': {\n# 'list_id': list_id, # not mandatory\n# 'lolomo_id': g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION), # not mandatory\n@@ -215,7 +225,7 @@ class EventsHandler(threading.Thread):\nif event_type == EVENT_ENGAGE:\nparams['action'] = 'User_Interaction'\n- self.cache_data_events[videoid.value] = params\n+ self.cache_data_events[videoid.value] = (params, player_state)\nreturn params\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "@@ -85,7 +85,6 @@ class MSLHandlerBase(object):\nreturn self.check_mastertoken_validity()\nreturn {'renewable': renewable, 'expired': expired}\n-\n@display_error_info\[email protected]_execution(immediate=True)\ndef perform_key_handshake(self, data=None):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/action_manager.py",
"new_path": "resources/lib/services/playback/action_manager.py",
"diff": "@@ -101,7 +101,6 @@ class PlaybackActionManager(object):\nNOTE: If possible never use sleep delay inside this method\notherwise it delay the execution of subsequent action managers\n\"\"\"\n- pass\ndef _on_tick(self, player_state):\n\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "@@ -128,6 +128,7 @@ class PlaybackController(xbmc.Monitor):\n'properties': [\n'audiostreams',\n'currentaudiostream',\n+ 'currentvideostream',\n'subtitles',\n'currentsubtitle',\n'subtitleenabled',\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Reworked event tag builder |
106,046 | 07.02.2020 10:35:01 | -3,600 | e7a705b98101f707b202b121e4558a234856e3b8 | Added onResume | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/action_manager.py",
"new_path": "resources/lib/services/playback/action_manager.py",
"diff": "@@ -76,6 +76,12 @@ class PlaybackActionManager(object):\n\"\"\"\nself._call_if_enabled(self._on_playback_pause, player_state=player_state)\n+ def on_playback_resume(self, player_state):\n+ \"\"\"\n+ Notify that the playback has been resumed\n+ \"\"\"\n+ self._call_if_enabled(self._on_playback_resume, player_state=player_state)\n+\ndef on_playback_stopped(self):\n\"\"\"\nNotify that a playback has stopped\n@@ -117,5 +123,8 @@ class PlaybackActionManager(object):\ndef _on_playback_pause(self, player_state):\npass\n+ def _on_playback_resume(self, player_state):\n+ pass\n+\ndef _on_playback_stopped(self):\npass\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "@@ -73,6 +73,8 @@ class PlaybackController(xbmc.Monitor):\nself._on_playback_seek()\nelif method == 'Player.OnPause':\nself._on_playback_pause()\n+ elif method == 'Player.OnResume':\n+ self._on_playback_resume()\nelif method == 'Player.OnStop':\nself._on_playback_stopped()\nexcept Exception:\n@@ -109,6 +111,13 @@ class PlaybackController(xbmc.Monitor):\nself._notify_all(PlaybackActionManager.on_playback_pause,\nplayer_state)\n+ def _on_playback_resume(self):\n+ if self.tracking and self.active_player_id is not None:\n+ player_state = self._get_player_state()\n+ if player_state:\n+ self._notify_all(PlaybackActionManager.on_playback_resume,\n+ player_state)\n+\ndef _on_playback_stopped(self):\nself.tracking = False\nself.active_player_id = None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added onResume |
106,046 | 07.02.2020 11:29:12 | -3,600 | bacadc33385cae33ff399f95c60578592d3629c6 | Limit sending of keepAlive events to first 30m of pause
prevents sending an infinite number of events to the netflix service, when a user pauses the playback for many hours | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "@@ -24,6 +24,8 @@ class ProgressManager(PlaybackActionManager):\nself.last_tick_count = 0\nself.tick_elapsed = 0\nself.last_player_state = {}\n+ self.is_player_in_pause = False\n+ self.lock_events = False\ndef _initialize(self, data):\nvideoid = common.VideoId.from_dict(data['videoid'])\n@@ -33,15 +35,28 @@ class ProgressManager(PlaybackActionManager):\nself.event_data = data['event_data']\ndef _on_tick(self, player_state):\n+ if self.lock_events:\n+ return\n+ if self.is_player_in_pause and (self.tick_elapsed - self.last_tick_count) >= 1800:\n+ # When the player is paused for more than 30 minutes we interrupt the sending of events (1800secs=30m)\n+ _send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n+ _send_event(EVENT_STOP, self.event_data, self.last_player_state)\n+ self.is_event_start_sent = False\n+ self.lock_events = True\n+ else:\nif not self.is_event_start_sent:\n# We do not use _on_playback_started() to send EVENT_START, because StreamContinuityManager\n- # may cause inconsistencies with the content of player_state data\n- player_state['elapsed_seconds'] = 0 # Force set to 0\n+ # and ResumeManager may cause inconsistencies with the content of player_state data\n+\n+ # When the playback starts for the first time, for correctness should send elapsed_seconds value to 0\n+ if self.tick_elapsed < 5 and self.event_data['resume_position'] is None:\n+ player_state['elapsed_seconds'] = 0\n_send_event(EVENT_START, self.event_data, player_state)\nself.is_event_start_sent = True\n+ self.tick_elapsed = 0\nelse:\n- # Generate events to send to Netflix service every 1 minute\n- if (self.tick_elapsed - self.last_tick_count) / 60 >= 1:\n+ # Generate events to send to Netflix service every 1 minute (60secs=1m)\n+ if (self.tick_elapsed - self.last_tick_count) >= 60:\n_send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\nself.last_tick_count = self.tick_elapsed\nself.last_player_state = player_state\n@@ -51,17 +66,22 @@ class ProgressManager(PlaybackActionManager):\nif not self.is_event_start_sent:\nreturn\nself.tick_elapsed = 0\n+ self.is_player_in_pause = True\n_send_event(EVENT_ENGAGE, self.event_data, player_state)\n+ def on_playback_resume(self, player_state):\n+ self.is_player_in_pause = False\n+ self.lock_events = False\n+\ndef on_playback_seek(self, player_state):\n- if not self.is_event_start_sent:\n+ if not self.is_event_start_sent or self.lock_events:\n# This might happen when ResumeManager skip is performed\nreturn\nself.tick_elapsed = 0\n_send_event(EVENT_ENGAGE, self.event_data, player_state)\ndef _on_playback_stopped(self):\n- if not self.is_event_start_sent:\n+ if not self.is_event_start_sent or self.lock_events:\nreturn\nself.tick_elapsed = 0\n_send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Limit sending of keepAlive events to first 30m of pause
prevents sending an infinite number of events to the netflix service, when a user pauses the playback for many hours |
106,046 | 07.02.2020 11:47:27 | -3,600 | ff4e142e8d55e09bb213eeb931214b3d0a787143 | Fixed event request successful check | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -65,7 +65,7 @@ class Event(object):\nself.status = self.STATUS_SUCCESS\ndef is_response_success(self):\n- return self.status == self.STATUS_SUCCESS\n+ return self.status == self.STATUS_SUCCESS and self.req_attempt <= 3\ndef is_attempts_granted(self):\n\"\"\"Returns True if you can make new request attempts\"\"\"\n@@ -125,8 +125,8 @@ class EventsHandler(threading.Thread):\ncommon.error('EVENT [{}] - The request has failed: {}', event, exc)\nif event.event_type == EVENT_STOP:\nself.clear_queue()\n- if event.event_type == EVENT_START and not event.is_response_success():\n- # If 'start' event was unsuccessful,\n+ if not event.is_response_success():\n+ # The event request is unsuccessful then there is some problem,\n# no longer make any future requests from this event id\nreturn False\nreturn True\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed event request successful check |
106,046 | 10.02.2020 10:57:19 | -3,600 | f0270d047bb4eae6d6f0646c5e6b83c7b52ac053 | Set language of profile | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_handler_base.py",
"diff": "@@ -168,7 +168,7 @@ def build_request_data(url, params=None, echo=''):\n'version': 2,\n'url': url,\n'id': timestamp,\n- 'languages': [g.LOCAL_DB.get_value('locale_id')],\n+ 'languages': [g.LOCAL_DB.get_profile_config('language')],\n'params': params,\n'echo': echo\n}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Set language of profile |
106,046 | 11.02.2020 10:53:38 | -3,600 | ed64d1cf3d5c26c35afbd7510a85815ac9141cf3 | Add json_rpc_multi | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/kodiops.py",
"new_path": "resources/lib/common/kodiops.py",
"diff": "@@ -50,7 +50,7 @@ def json_rpc(method, params=None):\nrequest_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n'params': params or {}}\nrequest = json.dumps(request_data)\n- debug('Executing JSON-RPC: {}'.format(request))\n+ debug('Executing JSON-RPC: {}', request)\nraw_response = xbmc.executeJSONRPC(request)\n# debug('JSON-RPC response: {}'.format(raw_response))\nresponse = json.loads(raw_response)\n@@ -61,6 +61,26 @@ def json_rpc(method, params=None):\nreturn response['result']\n+def json_rpc_multi(method, list_params=None):\n+ \"\"\"\n+ Executes multiple JSON-RPC with the same method in Kodi\n+\n+ :param method: The JSON-RPC method to call\n+ :type method: string\n+ :param list_params: Multiple list of parameters of the method call\n+ :type list_params: a list of dict\n+ :returns: dict -- Method call result\n+ \"\"\"\n+ request_data = [{'jsonrpc': '2.0', 'method': method, 'id': 1,\n+ 'params': params or {}} for params in list_params]\n+ request = json.dumps(request_data)\n+ debug('Executing JSON-RPC: {}', request)\n+ raw_response = xbmc.executeJSONRPC(request)\n+ if 'error' in raw_response:\n+ raise IOError('JSONRPC-Error {}'.format(raw_response))\n+ return json.loads(raw_response)\n+\n+\ndef update_library_item_details(dbtype, dbid, details):\n\"\"\"\nUpdate properties of an item in the Kodi library\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add json_rpc_multi |
106,046 | 13.02.2020 10:08:13 | -3,600 | 2ce8a836efaf9bc913feb43682e4e82de2728f33 | Added cache update method | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/cache.py",
"new_path": "resources/lib/cache.py",
"diff": "@@ -195,6 +195,15 @@ class Cache(object):\nif to_disk:\nself._add_to_disk(bucket, identifier, cache_entry)\n+ def update(self, bucket, identifier, content, to_disk=False):\n+ \"\"\"Update an item content to a cache bucket\"\"\"\n+ cache_entry = self._get_bucket(bucket).get(identifier)\n+ if cache_entry is None:\n+ raise CacheMiss()\n+ cache_entry['content'] = content\n+ if to_disk:\n+ self._add_to_disk(bucket, identifier, cache_entry)\n+\ndef commit(self):\n\"\"\"Persist cache contents in window properties\"\"\"\nfor bucket in list(self.buckets.keys()):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added cache update method |
106,046 | 13.02.2020 10:13:55 | -3,600 | 11bf4d753ef65d787026fb91885a771d465742e0 | Save last cache call data of directory | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -115,7 +115,7 @@ def list_id_for_type(list_type):\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='list_id')\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='list_id', save_call_data=True)\ndef video_list(list_id, perpetual_range_start=None):\n\"\"\"Retrieve a single video list\nsome of this type of request seems to have results fixed at ~40 from netflix\n@@ -134,7 +134,7 @@ def video_list(list_id, perpetual_range_start=None):\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='context_id',\n- identify_append_from_kwarg_name='perpetual_range_start')\n+ identify_append_from_kwarg_name='perpetual_range_start', save_call_data=True)\ndef video_list_sorted(context_name, context_id=None, perpetual_range_start=None, menu_data=None):\n\"\"\"Retrieve a single video list sorted\nthis type of request allows to obtain more than ~40 results\n@@ -218,7 +218,7 @@ def seasons(videoid):\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='videoid_value',\n- identify_append_from_kwarg_name='perpetual_range_start')\n+ identify_append_from_kwarg_name='perpetual_range_start', save_call_data=True)\ndef episodes(videoid, videoid_value, perpetual_range_start=None): # pylint: disable=unused-argument\n\"\"\"Retrieve episodes of a season\"\"\"\nif videoid.mediatype != common.VideoId.SEASON:\n@@ -239,7 +239,7 @@ def episodes(videoid, videoid_value, perpetual_range_start=None): # pylint: dis\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_SUPPLEMENTAL)\[email protected]_output(cache.CACHE_SUPPLEMENTAL, save_call_data=True)\ndef supplemental_video_list(videoid, supplemental_type):\n\"\"\"Retrieve a supplemental video list\"\"\"\nif videoid.mediatype != common.VideoId.SHOW and videoid.mediatype != common.VideoId.MOVIE:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/cache.py",
"new_path": "resources/lib/cache.py",
"diff": "@@ -28,6 +28,7 @@ import xbmcgui\nimport xbmcvfs\nfrom resources.lib import common\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\ntry:\n@@ -81,7 +82,8 @@ def cache_output(bucket, fixed_identifier=None,\nidentify_append_from_kwarg_name=None,\nidentify_fallback_arg_index=0,\nttl=None,\n- to_disk=False):\n+ to_disk=False,\n+ save_call_data=False):\n\"\"\"Decorator that ensures caching the output of a function\"\"\"\n# pylint: disable=missing-docstring, invalid-name, too-many-arguments\ndef caching_decorator(func):\n@@ -94,6 +96,10 @@ def cache_output(bucket, fixed_identifier=None,\nidentify_fallback_arg_index,\nargs,\nkwargs)\n+ if save_call_data and not g.IS_SKIN_CALL:\n+ g.LOCAL_DB.set_value('cache_last_directory_call',\n+ {'bucket': bucket, 'identifier': identifier, 'to_disk': to_disk},\n+ table=TABLE_SESSION)\nif not identifier:\n# Do not cache if identifier couldn't be determined\nreturn func(*args, **kwargs)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Save last cache call data of directory |
106,046 | 13.02.2020 16:19:56 | -3,600 | b1fb3242a10f80a6c35a2966133a6046bcbbe6ae | Implemented watched and resume to listitems | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/paths.py",
"new_path": "resources/lib/api/paths.py",
"diff": "@@ -41,7 +41,7 @@ ART_PARTIAL_PATHS = [\nVIDEO_LIST_PARTIAL_PATHS = [\n[['requestId', 'summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue',\n'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount',\n- 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition',\n+ 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'creditsOffset'\n'dpSupplementalMessage', 'watched', 'delivery']],\n[['genres', 'tags', 'creators', 'directors', 'cast'],\n{'from': 0, 'to': 10}, ['id', 'name']]\n@@ -72,7 +72,8 @@ EPISODES_PARTIAL_PATHS = [\n] + ART_PARTIAL_PATHS\nTRAILER_PARTIAL_PATHS = [\n- [['availability', 'summary', 'synopsis', 'title', 'trackId', 'delivery', 'runtime']]\n+ [['availability', 'summary', 'synopsis', 'title', 'trackId', 'delivery', 'runtime',\n+ 'bookmarkPosition', 'creditsOffset']]\n] + ART_PARTIAL_PATHS\nEVENT_PATHS = [\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/kodiops.py",
"new_path": "resources/lib/common/kodiops.py",
"diff": "@@ -71,8 +71,7 @@ def json_rpc_multi(method, list_params=None):\n:type list_params: a list of dict\n:returns: dict -- Method call result\n\"\"\"\n- request_data = [{'jsonrpc': '2.0', 'method': method, 'id': 1,\n- 'params': params or {}} for params in list_params]\n+ request_data = [{'jsonrpc': '2.0', 'method': method, 'id': 1, 'params': params or {}} for params in list_params]\nrequest = json.dumps(request_data)\ndebug('Executing JSON-RPC: {}', request)\nraw_response = xbmc.executeJSONRPC(request)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -421,3 +421,34 @@ class GetKodiVersion(object):\nself.stage = re_stage.group(1) if re_stage else ''\nelse:\nself.stage = re_stage.group(2) if re_stage else ''\n+\n+\n+def update_cache_videoid_runtime(window_cls):\n+ \"\"\"Try to update the bookmarkPosition value in cache data in order to get a updated watched status/resume time\"\"\"\n+ # Other details in:\n+ # progress_manager.py method: _save_resume_time()\n+ # infolabels.py method: _set_progress_status()\n+ runtime = window_cls.getProperty('nf_playback_resume_time')\n+ if runtime and runtime.isdigit():\n+ from resources.lib.api.data_types import VideoList, VideoListSorted, EpisodeList, SearchVideoList\n+ from resources.lib.cache import CacheMiss\n+ from resources.lib.database.db_utils import TABLE_SESSION\n+ from resources.lib.common import VideoId\n+ cache_last_dir_call = g.LOCAL_DB.get_value('cache_last_directory_call', {}, table=TABLE_SESSION)\n+ if not cache_last_dir_call:\n+ return\n+ videoid = VideoId.from_dict(g.LOCAL_DB.get_value('last_videoid_played', {}, table=TABLE_SESSION))\n+ try:\n+ data_object = g.CACHE.get(cache_last_dir_call['bucket'], cache_last_dir_call['identifier'])\n+ if isinstance(data_object, (VideoList, VideoListSorted, SearchVideoList)):\n+ data_object.videos[str(videoid.value)]['bookmarkPosition'] = int(runtime)\n+ elif isinstance(data_object, EpisodeList):\n+ data_object.episodes[str(videoid.value)]['bookmarkPosition'] = int(runtime)\n+ else:\n+ error('update_cache_videoid_runtime: cache object not mapped, bookmarkPosition not updated')\n+ g.CACHE.update(cache_last_dir_call['bucket'], cache_last_dir_call['identifier'], data_object,\n+ cache_last_dir_call['to_disk'])\n+ except CacheMiss:\n+ # No more valid cache, manual update not needed\n+ pass\n+ window_cls.setProperty('nf_playback_resume_time', '')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -64,6 +64,8 @@ def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False)\nvideoid.mediatype == common.VideoId.SUPPLEMENTAL:\nlist_item.setProperty('isFolder', 'false')\nlist_item.setProperty('IsPlayable', 'true')\n+ # Set the resume and watched status to the list item\n+ _set_progress_status(list_item, item, infos_copy)\nelse:\nlist_item.setProperty('isFolder', 'true')\nfor stream_type, quality_infos in iteritems(quality_infos):\n@@ -345,3 +347,35 @@ def _colorize_title(text, color, remove_color=False):\nif not matches:\nreturn '[COLOR {}]{}[/COLOR]'.format(color, text)\nreturn text\n+\n+\n+def _set_progress_status(list_item, video_data, infos):\n+ \"\"\"Check and set progress status (watched and resume)\"\"\"\n+ if not g.ADDON.getSettingBool('ProgressManager_enabled') or \\\n+ not g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ # Currently due to a unknown problem, it is not possible to communicate MSL data to the right selected\n+ # profile other than the owner profile\n+ return\n+ # Todo: implement a way to let user change manually the watched status (values saved on db)\n+ # then check from db if user has manually changed the watched status\n+\n+ # NOTE shakti 'watched' tag value:\n+ # in my tests playing a video (via web browser) until to the end this value is not changed to True\n+ # seem not respect really if a video is watched to the end or this tag have other purposes\n+ # to now, the only way to know if a video is watched is compare the bookmarkPosition with creditsOffset value\n+\n+ if not video_data.get('creditsOffset'):\n+ # NOTE shakti 'creditsOffset' tag not exists on video type 'movie',\n+ # then simulate the default Kodi playcount behaviour (playcountminimumpercent)\n+ watched_threshold = video_data['runtime'] - (video_data['runtime'] / 100 * 90)\n+ else:\n+ watched_threshold = video_data['creditsOffset']\n+\n+ # NOTE shakti 'bookmarkPosition' tag when it is not set have -1 value\n+ playcount = '1' if video_data['bookmarkPosition'] >= watched_threshold else '0'\n+ if playcount == '0' and video_data['bookmarkPosition'] > 0:\n+ list_item.setProperty('ResumeTime', str(video_data['bookmarkPosition']))\n+ list_item.setProperty('TotalTime', str(video_data['runtime']))\n+ # We have to set playcount with setInfo(), because the setProperty('PlayCount', ) have a bug\n+ # when a item is already watched and you force to set again watched, the override do not work\n+ infos['PlayCount'] = playcount\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -14,6 +14,7 @@ import xbmcplugin\nimport xbmcgui\nfrom resources.lib.api.exceptions import MetadataNotAvailable\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.api.shakti as api\n@@ -74,17 +75,7 @@ def play(videoid):\nresume_position = {}\nevent_data = {}\n- if g.ADDON.getSettingBool('ProgressManager_enabled'):\n- event_data = _get_event_data(videoid)\n- event_data['videoid'] = videoid.to_dict()\n- event_data['is_played_by_library'] = g.IS_SKIN_CALL\n- if event_data['resume_position']:\n- # Todo: This is for test purpose,\n- # set watched and resume data to list items in the get lists methods\n- common.debug('Resume from last saved Netflix position: {}', event_data['resume_position'])\n- list_item.setProperty('ResumeTime', str(event_data['resume_position']))\n- list_item.setProperty('TotalTime', str(event_data['runtime']))\n- elif g.IS_SKIN_CALL:\n+ if g.IS_SKIN_CALL:\n# Workaround for resuming strm files from library\nresume_position = infos.get('resume', {}).get('position') \\\nif g.ADDON.getSettingBool('ResumeManager_enabled') else None\n@@ -98,6 +89,14 @@ def play(videoid):\nreturn\nif index_selected == 1:\nresume_position = None\n+ elif g.ADDON.getSettingBool('ProgressManager_enabled') and g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ # To now we have this limits:\n+ # - enabled only if the owner profile is used. Currently due to a unknown problem,\n+ # it is not possible to communicate MSL data to the right selected profile\n+ # - enabled only with items played inside the addon then not Kodi library, need impl. JSON-RPC lib update code\n+ event_data = _get_event_data(videoid)\n+ event_data['videoid'] = videoid.to_dict()\n+ event_data['is_played_by_library'] = g.IS_SKIN_CALL\nxbmcplugin.setResolvedUrl(\nhandle=g.PLUGIN_HANDLE,\n@@ -106,6 +105,8 @@ def play(videoid):\nupnext_info = get_upnext_info(videoid, (infos, art), metadata) if is_up_next_enabled else None\n+ g.LOCAL_DB.set_value('last_videoid_played', videoid.to_dict(), table=TABLE_SESSION)\n+\ncommon.debug('Sending initialization signal')\ncommon.send_signal(common.Signals.PLAYBACK_INITIATED, {\n'videoid': videoid.to_dict(),\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/run_addon.py",
"new_path": "resources/lib/run_addon.py",
"diff": "@@ -16,7 +16,7 @@ from xbmcgui import Window\nfrom resources.lib.globals import g\nfrom resources.lib.common import (info, debug, warn, error, check_credentials, BackendNotReady,\nlog_time_trace, reset_log_level_global_var,\n- get_current_kodi_profile_name)\n+ get_current_kodi_profile_name, update_cache_videoid_runtime)\nfrom resources.lib.upgrade_controller import check_addon_upgrade\n@@ -148,6 +148,7 @@ def run(argv):\nsuccess = True\nwindow_cls = Window(10000) # Kodi home window\n+\n# If you use multiple Kodi profiles you need to distinguish the property of current profile\nprop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name())\nis_widget_skin_call = _skin_widget_call(window_cls, prop_nf_service_status)\n@@ -164,6 +165,8 @@ def run(argv):\nif g.IS_ADDON_FIRSTRUN:\ncheck_addon_upgrade()\ng.initial_addon_configuration()\n+ if not is_widget_skin_call:\n+ update_cache_videoid_runtime(window_cls)\nroute([part for part in g.PATH.split('/') if part])\nelse:\nsuccess = False\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+from xbmcgui import Window\n+\nimport resources.lib.common as common\n+from resources.lib.globals import g\nfrom resources.lib.services.msl.events_handler import EVENT_STOP, EVENT_KEEP_ALIVE, EVENT_START, EVENT_ENGAGE\nfrom .action_manager import PlaybackActionManager\n@@ -26,12 +29,22 @@ class ProgressManager(PlaybackActionManager):\nself.last_player_state = {}\nself.is_player_in_pause = False\nself.lock_events = False\n+ self.window_cls = Window(10000) # Kodi home window\ndef _initialize(self, data):\n+ if not g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ # Currently due to a unknown problem, it is not possible to communicate MSL data to the right selected\n+ # profile other than the owner profile\n+ self.enabled = False\n+ return\nvideoid = common.VideoId.from_dict(data['videoid'])\nif videoid.mediatype not in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\nself.enabled = False\nreturn\n+ if not data['event_data']:\n+ common.warn('ProgressManager: disabled due to no event data')\n+ self.enabled = False\n+ return\nself.event_data = data['event_data']\ndef _on_tick(self, player_state):\n@@ -59,6 +72,9 @@ class ProgressManager(PlaybackActionManager):\nif (self.tick_elapsed - self.last_tick_count) >= 60:\n_send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\nself.last_tick_count = self.tick_elapsed\n+ # On Kodi we can save every second instead every minute, but only after the first minute\n+ if self.last_tick_count:\n+ self._save_resume_time(player_state['elapsed_seconds'])\nself.last_player_state = player_state\nself.tick_elapsed += 1 # One tick almost always represents one second\n@@ -87,6 +103,19 @@ class ProgressManager(PlaybackActionManager):\n_send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n_send_event(EVENT_STOP, self.event_data, self.last_player_state)\n+ def _save_resume_time(self, resume_time):\n+ \"\"\"Save resume time in order to modify the frontend cache\"\"\"\n+ # Why this, the video lists are requests to the web service only once and then will be cached in order to\n+ # quickly get the data and speed up a lot the GUI response.\n+ # Watched status of a (video) list item is based on resume time, and the resume time is saved in the cache data.\n+ # To avoid slowing down the GUI by invalidating the cache to get new data from website service, one solution is\n+ # modify the cache data.\n+ # Altering here the cache on the fly is not possible because it is currently not shared between service-frontend\n+ # therefore we save the value in a Kodi property and we will modify the cache from addon frontend.\n+ # The choice to save the value in a Kodi property is to not continuously lock with mutex the database.\n+ # The callback _on_playback_stopped can not be used, because the loading of frontend happen before.\n+ self.window_cls.setProperty('nf_playback_resume_time', str(resume_time))\n+\ndef _send_event(event_type, event_data, player_state):\nif not player_state:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"ResumeManager_enabled\" type=\"bool\" label=\"30176\" default=\"true\"/>\n<setting id=\"ResumeManager_dialog\" type=\"bool\" label=\"30177\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"forced_subtitle_workaround\" type=\"bool\" label=\"30181\" default=\"true\" />\n- <setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30500\" default=\"true\"/>\n+ <setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30500\" default=\"false\"/>\n</category>\n<category label=\"30023\"><!--Expert-->\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implemented watched and resume to listitems |
106,046 | 14.02.2020 18:02:15 | -3,600 | d2c03cc8c206b1d098046dc3f5d7baf6512c5ea5 | Update authUrl on refresh session data | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -87,6 +87,7 @@ def extract_session_data(content, validate=False):\n# Save api urls\nfor key, path in list(api_data.items()):\ng.LOCAL_DB.set_value(key, path, TABLE_SESSION)\n+ return api_data\[email protected]_execution(immediate=True)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_requests.py",
"new_path": "resources/lib/services/nfsession/nfsession_requests.py",
"diff": "@@ -112,7 +112,7 @@ class NFSessionRequests(NFSessionBase):\n\"\"\"Refresh session_data from the Netflix website\"\"\"\n# pylint: disable=broad-except\ntry:\n- website.extract_session_data(self._get('profiles'))\n+ self.auth_url = website.extract_session_data(self._get('profiles'))['auth_url']\nself.update_session_data()\ncommon.debug('Successfully refreshed session data')\nreturn True\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Update authUrl on refresh session data |
106,046 | 16.02.2020 15:56:02 | -3,600 | 986f7dfc310e9c4873b94e033a17d34df1ca92b3 | Implemented callpath request | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession.py",
"new_path": "resources/lib/services/nfsession/nfsession.py",
"diff": "@@ -35,6 +35,7 @@ class NetflixSession(NFSessionAccess):\nself.path_request,\nself.perpetual_path_request,\nself.perpetual_path_request_switch_profiles,\n+ self.callpath_request,\nself.get,\nself.post,\nself.startup_requests_module\n@@ -222,6 +223,54 @@ class NetflixSession(NFSessionAccess):\nheaders=headers,\ndata=data)['value']\n+ @common.addonsignals_return_call\n+ @needs_login\n+ def callpath_request(self, callpaths, params=None, path_suffixs=None):\n+ \"\"\"Perform a callPath request against the Shakti API\"\"\"\n+ return self._callpath_request(callpaths, params, path_suffixs)\n+\n+ @common.time_execution(immediate=True)\n+ def _callpath_request(self, callpaths, params=None, path_suffixs=None):\n+ \"\"\"Execute a callPath request with static paths\"\"\"\n+ # Warning: The data to pass on 'params' must not be formatted with json.dumps because it is not full compatible\n+ # if the request have wrong data give error 401\n+ # if the parameters are not formatted correctly will give error 401\n+ common.debug('Executing callPath request: {} params: {} path_suffixs: {}',\n+ json.dumps(callpaths),\n+ params,\n+ json.dumps(path_suffixs))\n+ headers = {\n+ 'Content-Type': 'application/x-www-form-urlencoded',\n+ 'Accept': 'application/json, text/javascript, */*'}\n+\n+ req_params = {\n+ 'drmSystem': 'widevine',\n+ 'falcor_server': '0.1.0',\n+ 'method': 'call',\n+ 'withSize': 'true',\n+ 'materialize': 'true',\n+ 'routeAPIRequestsThroughFTL': 'false',\n+ 'isVolatileBillboardsEnabled': 'true',\n+ 'isWatchlistEnabled': 'false'\n+ }\n+ data = 'callPath=' + '&callPath='.join(json.dumps(callpath) for callpath in callpaths)\n+ if params:\n+ data += '¶m=' + '¶m='.join(params)\n+ if path_suffixs:\n+ data += '&pathSuffix=' + '&pathSuffix='.join(json.dumps(path_suffix) for path_suffix in path_suffixs)\n+ data += '&authURL=' + self.auth_url\n+ data = data.replace(' ', '')\n+ # common.debug('callPath request data: {}', data)\n+ response_data = self._post(\n+ component='shakti',\n+ req_type='api',\n+ params=req_params,\n+ headers=headers,\n+ data=data)\n+ if 'falcor_server' in req_params:\n+ return response_data['jsonGraph']\n+ return response_data['value']\n+\ndef _set_range_selector(paths, range_start, range_end):\n\"\"\"Replace the RANGE_SELECTOR placeholder with an actual dict:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implemented callpath request |
106,046 | 16.02.2020 15:56:27 | -3,600 | 0f4cf6d47d8db0e01176e0ee0d9e6a004488b45f | Added update lolomo by context
Should be used to update the list continue watching
after event stop, but currently not working
I haven't been able to figure out what would be wrong or missing | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\nfrom future.utils import iteritems\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.cache as cache\n@@ -101,6 +102,52 @@ def root_lists():\nART_PARTIAL_PATHS)))\n+def update_lolomo_context(context_name, video_id=None):\n+ \"\"\"Update the lolomo list by context\"\"\"\n+ # Should update the context list but it doesn't, what is missing?\n+ # The remaining requests made on the website that are missing here are of logging type,\n+ # it seems strange that they use log data to finish the operations are almost impossible to reproduce here:\n+ # pbo_logblobs /logblob\n+ # personalization/cl2\n+\n+ lolomo_data = common.make_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\n+ # Note: lolomo root seem differs according to the profile in use\n+ lolomo_root = lolomo_data['lolomo'][1]\n+ context_index = lolomo_data['lolomos'][lolomo_root][context_name][2]\n+ context_id = lolomo_data['lolomos'][lolomo_root][context_index][1]\n+\n+ path = [['lolomos', lolomo_root, 'refreshListByContext']]\n+ params = [common.enclose_quotes(context_id),\n+ context_index,\n+ common.enclose_quotes(context_name),\n+ common.enclose_quotes(g.LOCAL_DB.get_value('request_id', table=TABLE_SESSION))]\n+ # path_suffixs = [\n+ # [['trackIds', 'context', 'length', 'genreId', 'videoId', 'displayName', 'isTallRow', 'isShowAsARow',\n+ # 'impressionToken', 'showAsARow', 'id', 'requestId']],\n+ # [{'from': 0, 'to': 100}, 'reference', 'summary'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'title'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'titleMaturity'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'userRating'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'userRatingRequestId'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'boxarts', '_342x192', 'jpg'],\n+ # [{'from': 0, 'to': 100}, 'reference', 'promoVideo']\n+ # ]\n+ callargs = {\n+ 'callpaths': path,\n+ 'params': params,\n+ # 'path_suffixs': path_suffixs\n+ }\n+ response = common.make_http_call('callpath_request', callargs)\n+ common.debug('refreshListByContext response: {}', response)\n+\n+ callargs = {\n+ 'callpaths': [['refreshVideoCurrentPositions']],\n+ 'params': ['[' + video_id + ']', ''],\n+ }\n+ response = common.make_http_call('callpath_request', callargs)\n+ common.debug('refreshVideoCurrentPositions response: {}', response)\n+\n+\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='list_type')\ndef list_id_for_type(list_type):\n\"\"\"Return the dynamic video list ID for a video list of known type\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -46,7 +46,8 @@ PAGE_ITEMS_API_URL = {\n'auth_url': 'models/userInfo/data/authURL',\n# 'ichnaea_log': 'models/serverDefs/data/ICHNAEA_ROOT', can be for XSS attacks?\n'api_endpoint_root_url': 'models/serverDefs/data/API_ROOT',\n- 'api_endpoint_url': 'models/playerModel/data/config/ui/initParams/apiUrl'\n+ 'api_endpoint_url': 'models/playerModel/data/config/ui/initParams/apiUrl',\n+ 'request_id': 'models/serverDefs/data/requestId'\n}\nPAGE_ITEM_ERROR_CODE = 'models/flow/data/fields/errorCode/value'\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -261,6 +261,10 @@ def any_value_except(mapping, excluded_keys):\nreturn next(mapping[key] for key in mapping if key not in excluded_keys)\n+def enclose_quotes(content):\n+ return '\"' + content + '\"'\n+\n+\ndef time_execution(immediate):\n\"\"\"A decorator that wraps a function call and times its execution\"\"\"\n# pylint: disable=missing-docstring\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -20,6 +20,7 @@ except ImportError: # Python 3\nimport xbmc\n+# import resources.lib.api.shakti as api\nimport resources.lib.cache as cache\nfrom resources.lib import common\nfrom resources.lib.globals import g\n@@ -72,6 +73,9 @@ class Event(object):\nself.req_attempt += 1\nreturn bool(self.req_attempt <= 3)\n+ def get_video_id(self):\n+ return self.request_data['params']['sessionParams']['uiplaycontext']['video_id']\n+\ndef __str__(self):\nreturn self.event_type\n@@ -125,6 +129,7 @@ class EventsHandler(threading.Thread):\ncommon.error('EVENT [{}] - The request has failed: {}', event, exc)\nif event.event_type == EVENT_STOP:\nself.clear_queue()\n+ # api.update_lolomo_context('continueWatching', video_id=event.get_video_id())\nif not event.is_response_success():\n# The event request is unsuccessful then there is some problem,\n# no longer make any future requests from this event id\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added update lolomo by context
Should be used to update the list continue watching
after event stop, but currently not working
I haven't been able to figure out what would be wrong or missing |
106,046 | 18.02.2020 09:56:55 | -3,600 | 642170eb86ef3f5dacbb14065cf48a9c1b83173b | Changed lang id | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -964,6 +964,6 @@ msgctxt \"#30234\"\nmsgid \"Install Up Next add-on\"\nmsgstr \"\"\n-msgctxt \"#30500\"\n+msgctxt \"#30235\"\nmsgid \"[WIP] Send/Receive progress and watched status of the videos (works only with the main profile)\"\nmsgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"ResumeManager_enabled\" type=\"bool\" label=\"30176\" default=\"true\"/>\n<setting id=\"ResumeManager_dialog\" type=\"bool\" label=\"30177\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"forced_subtitle_workaround\" type=\"bool\" label=\"30181\" default=\"true\" />\n- <setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30500\" default=\"false\"/>\n+ <setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30235\" default=\"false\"/>\n</category>\n<category label=\"30023\"><!--Expert-->\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Changed lang id |
106,046 | 18.02.2020 10:12:29 | -3,600 | 909578c438cb3fc512d9c3a962f747093aa5b795 | Removed deprecated replaceItems | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/listings.py",
"new_path": "resources/lib/kodi/listings.py",
"diff": "@@ -390,9 +390,7 @@ def _create_supplemental_item(videoid_value, video, video_list, params):\nurl = common.build_url(videoid=videoid,\nmode=g.MODE_PLAY,\nparams=params)\n- # replaceItems still look broken because it does not remove the default ctx menu\n- # i hope in the future Kodi fix this\n- list_item.addContextMenuItems(generate_context_menu_items(videoid), replaceItems=True)\n+ list_item.addContextMenuItems(generate_context_menu_items(videoid))\nreturn (url, list_item, False)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Removed deprecated replaceItems |
106,046 | 18.02.2020 10:13:51 | -3,600 | 3762a8c623640917bf3ef0f0a5b17222242a7712 | Added watched_status_override table | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/database/db_create_mysql.py",
"new_path": "resources/lib/database/db_create_mysql.py",
"diff": "@@ -95,5 +95,17 @@ def create_database(config):\ncur.execute(table)\ncur.execute(alter_tbl)\n+ table = ('CREATE TABLE netflix_addon.watched_status_override ('\n+ 'ProfileGuid VARCHAR(50) NOT NULL,'\n+ 'VideoID INT(11) NOT NULL,'\n+ 'Value TEXT DEFAULT NULL,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.watched_status_override '\n+ 'ADD CONSTRAINT FK_watchedstatusoverride_ProfileGuid FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES netflix_addon.profiles(Guid) ON DELETE CASCADE ON UPDATE CASCADE;')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+\nif conn and conn.is_connected():\nconn.close()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/database/db_create_sqlite.py",
"new_path": "resources/lib/database/db_create_sqlite.py",
"diff": "@@ -121,5 +121,14 @@ def _create_shared_database(db_file_path):\n'NfoExport TEXT NOT NULL DEFAULT (\\'False\\'));')\ncur.execute(table)\n+ table = str('CREATE TABLE watched_status_override ('\n+ 'ProfileGuid TEXT NOT NULL,'\n+ 'VideoID INTEGER NOT NULL,'\n+ 'Value TEXT,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID ),'\n+ 'FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES Profiles (Guid) ON DELETE CASCADE ON UPDATE CASCADE);')\n+ cur.execute(table)\n+\nif conn:\nconn.close()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/database/db_shared.py",
"new_path": "resources/lib/database/db_shared.py",
"diff": "@@ -363,6 +363,50 @@ def get_shareddb_class(use_mysql=False):\nvalue = common.convert_to_string(value)\nself._execute_query(update_query, (value, tvshowid))\n+ @db_base_mysql.handle_connection\n+ @db_base_sqlite.handle_connection\n+ def get_watched_status(self, profile_guid, videoid, default_value=None, data_type=None):\n+ \"\"\"Get override watched status value of a given id stored to current profile\"\"\"\n+ query = 'SELECT Value FROM watched_status_override WHERE ProfileGuid = ? AND VideoID = ?'\n+ cur = self._execute_query(query, (profile_guid, videoid))\n+ result = cur.fetchone()\n+ if default_value is not None:\n+ data_type = type(default_value)\n+ elif data_type is None:\n+ data_type = str\n+ return common.convert_from_string(result[0], data_type) \\\n+ if result is not None else default_value\n+\n+ @db_base_mysql.handle_connection\n+ @db_base_sqlite.handle_connection\n+ def set_watched_status(self, profile_guid, videoid, value):\n+ \"\"\"Update or insert the watched status override value to current profile\"\"\"\n+ # Update or insert approach, if there is no updated row then insert new one\n+ value = common.convert_to_string(value)\n+ if self.is_mysql_database:\n+ query = db_utils.mysql_insert_or_update('watched_status_override',\n+ ['ProfileGuid', 'VideoID'],\n+ ['Value'])\n+ self._execute_non_query(query, (profile_guid, videoid, value),\n+ multi=True)\n+ else:\n+ update_query = ('UPDATE watched_status_override '\n+ 'SET Value = ? '\n+ 'WHERE ProfileGuid = ? AND VideoID = ?')\n+ cur = self._execute_query(update_query, (value, profile_guid, videoid))\n+ if cur.rowcount == 0:\n+ insert_query = ('INSERT INTO watched_status_override '\n+ '(ProfileGuid, VideoID, Value) '\n+ 'VALUES (?, ?, ?)')\n+ self._execute_non_query(insert_query, (profile_guid, videoid, value))\n+\n+ @db_base_mysql.handle_connection\n+ @db_base_sqlite.handle_connection\n+ def delete_watched_status(self, profile_guid, videoid):\n+ \"\"\"Delete a watched status override from database\"\"\"\n+ query = 'DELETE FROM watched_status_override WHERE ProfileGuid = ? AND VideoID = ?'\n+ self._execute_query(query, (profile_guid, videoid))\n+\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef get_stream_continuity(self, profile_guid, videoid, default_value=None, data_type=None):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/database/db_update.py",
"new_path": "resources/lib/database/db_update.py",
"diff": "@@ -13,21 +13,62 @@ import resources.lib.common as common\nfrom resources.lib.globals import g\n-def run_local_db_updates(db_version, db_new_version):\n+def run_local_db_updates(db_version, db_new_version): # pylint: disable=unused-argument\n\"\"\"Perform database actions for a db version change\"\"\"\n# The changes must be left in sequence to allow cascade operations on non-updated databases\nif common.is_less_version(db_version, '0.2'):\npass\nif common.is_less_version(db_version, '0.3'):\npass\n- g.LOCAL_DB.set_value('db_version', db_new_version)\n-def run_shared_db_updates(db_version, db_new_version):\n+def run_shared_db_updates(db_version, db_new_version): # pylint: disable=unused-argument\n\"\"\"Perform database actions for a db version change\"\"\"\n# The changes must be left in sequence to allow cascade operations on non-updated databases\n+\nif common.is_less_version(db_version, '0.2'):\n- pass\n+ # Changes: added table 'watched_status_override'\n+\n+ # SQLite\n+ import sqlite3 as sql\n+ from resources.lib.database.db_base_sqlite import CONN_ISOLATION_LEVEL\n+ from resources.lib.database import db_utils\n+\n+ shared_db_conn = sql.connect(db_utils.get_local_db_path(db_utils.SHARED_DB_FILENAME),\n+ isolation_level=CONN_ISOLATION_LEVEL)\n+ cur = shared_db_conn.cursor()\n+\n+ table = str('CREATE TABLE watched_status_override ('\n+ 'ProfileGuid TEXT NOT NULL,'\n+ 'VideoID INTEGER NOT NULL,'\n+ 'Value TEXT,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID ),'\n+ 'FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES Profiles (Guid) ON DELETE CASCADE ON UPDATE CASCADE);')\n+ cur.execute(table)\n+ shared_db_conn.close()\n+\n+ # MySQL\n+ if g.ADDON.getSettingBool('use_mysql'):\n+ import mysql.connector\n+ from resources.lib.database.db_base_mysql import MySQLDatabase\n+\n+ shared_db_conn = MySQLDatabase()\n+ shared_db_conn.conn = mysql.connector.connect(**shared_db_conn.config)\n+ cur = shared_db_conn.conn.cursor()\n+\n+ table = ('CREATE TABLE netflix_addon.watched_status_override ('\n+ 'ProfileGuid VARCHAR(50) NOT NULL,'\n+ 'VideoID INT(11) NOT NULL,'\n+ 'Value TEXT DEFAULT NULL,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.watched_status_override '\n+ 'ADD CONSTRAINT FK_watchedstatusoverride_ProfileGuid FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES netflix_addon.profiles(Guid) ON DELETE CASCADE ON UPDATE CASCADE;')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+ shared_db_conn.conn.close()\n+\nif common.is_less_version(db_version, '0.3'):\npass\n- g.LOCAL_DB.set_value('db_version', db_new_version)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/upgrade_controller.py",
"new_path": "resources/lib/upgrade_controller.py",
"diff": "@@ -76,7 +76,7 @@ def _perform_local_db_changes(db_version):\ndef _perform_shared_db_changes(db_version):\n\"\"\"Perform database actions for a db version change\"\"\"\n- db_new_version = '0.1'\n+ db_new_version = '0.2'\nif db_version != db_new_version:\nfrom resources.lib.common import debug\ndebug('Initialization of shared database updates from version {} to {})',\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added watched_status_override table |
106,046 | 18.02.2020 10:18:30 | -3,600 | 9cd9cb2fb296a84286bf1cd59b6b960f512074a7 | Added context menu to manually change watched status
At this moment Kodi do not allow to use the context menu
"Mark as watched/unwatched" when you override playcount/resumetime | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -967,3 +967,11 @@ msgstr \"\"\nmsgctxt \"#30235\"\nmsgid \"[WIP] Send/Receive progress and watched status of the videos (works only with the main profile)\"\nmsgstr \"\"\n+\n+msgctxt \"#30236\"\n+msgid \"Change watched status (locally)\"\n+msgstr \"\"\n+\n+msgctxt \"#30237\"\n+msgid \"Marked as watched|Marked as unwatched|Restored Netflix watched status\"\n+msgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/context_menu.py",
"new_path": "resources/lib/kodi/context_menu.py",
"diff": "@@ -61,7 +61,10 @@ CONTEXT_MENU_ACTIONS = {\n'url': ctx_item_url(['trailer'])},\n'force_update_mylist': {\n'label': common.get_local_string(30214),\n- 'url': ctx_item_url(['force_update_mylist'])}\n+ 'url': ctx_item_url(['force_update_mylist'])},\n+ 'change_watched_status': {\n+ 'label': common.get_local_string(30236),\n+ 'url': ctx_item_url(['change_watched_status'])}\n}\n@@ -97,6 +100,11 @@ def generate_context_menu_items(videoid):\nelse 'add_to_list')\nitems.insert(0, _ctx_item(list_action, videoid))\n+ if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\n+ # Add menu to allow change manually the watched status when progress manager is enabled\n+ if g.ADDON.getSettingBool('ProgressManager_enabled') and g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ items.insert(0, _ctx_item('change_watched_status', videoid))\n+\nreturn items\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -356,9 +356,13 @@ def _set_progress_status(list_item, video_data, infos):\n# Currently due to a unknown problem, it is not possible to communicate MSL data to the right selected\n# profile other than the owner profile\nreturn\n- # Todo: implement a way to let user change manually the watched status (values saved on db)\n- # then check from db if user has manually changed the watched status\n+ video_id = video_data['summary']['id']\n+ # Check from db if user has manually changed the watched status\n+ profile_guid = g.LOCAL_DB.get_active_profile_guid()\n+ override_is_watched = g.SHARED_DB.get_watched_status(profile_guid, video_id, None, bool)\n+\n+ if override_is_watched is None:\n# NOTE shakti 'watched' tag value:\n# in my tests playing a video (via web browser) until to the end this value is not changed to True\n# seem not respect really if a video is watched to the end or this tag have other purposes\n@@ -376,6 +380,8 @@ def _set_progress_status(list_item, video_data, infos):\nif playcount == '0' and video_data['bookmarkPosition'] > 0:\nlist_item.setProperty('ResumeTime', str(video_data['bookmarkPosition']))\nlist_item.setProperty('TotalTime', str(video_data['runtime']))\n+ else:\n+ playcount = '1' if override_is_watched else '0'\n# We have to set playcount with setInfo(), because the setProperty('PlayCount', ) have a bug\n# when a item is already watched and you force to set again watched, the override do not work\ninfos['PlayCount'] = playcount\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/actions.py",
"new_path": "resources/lib/navigation/actions.py",
"diff": "@@ -11,12 +11,11 @@ from __future__ import absolute_import, division, unicode_literals\nimport xbmc\n-from resources.lib.globals import g\n-import resources.lib.common as common\nimport resources.lib.api.shakti as api\n+import resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n-\n-from resources.lib.api.exceptions import (MissingCredentialsError, WebsiteParsingError)\n+from resources.lib.api.exceptions import MissingCredentialsError, WebsiteParsingError\n+from resources.lib.globals import g\nclass AddonActionExecutor(object):\n@@ -155,6 +154,28 @@ class AddonActionExecutor(object):\n# Open root page\nxbmc.executebuiltin('Container.Update({},replace)'.format(url)) # replace=reset history\n+ def change_watched_status(self, pathitems=None):\n+ from os import path\n+ videoid = path.basename(path.normpath(xbmc.getInfoLabel('ListItem.Path')))\n+ if videoid.isdigit():\n+ # Todo: how get resumetime/playcount of selected item for calculate current watched status?\n+\n+ profile_guid = g.LOCAL_DB.get_active_profile_guid()\n+ current_value = g.SHARED_DB.get_watched_status(profile_guid, videoid, None, bool)\n+ if current_value:\n+ txt_index = 1\n+ g.SHARED_DB.set_watched_status(profile_guid, videoid, False)\n+ elif current_value is not None and not current_value:\n+ txt_index = 2\n+ g.SHARED_DB.delete_watched_status(profile_guid, videoid)\n+ else:\n+ txt_index = 0\n+ g.SHARED_DB.set_watched_status(profile_guid, videoid, True)\n+ ui.show_notification(common.get_local_string(30237).split('|')[txt_index])\n+ common.refresh_container()\n+ else:\n+ common.error('No video id found in the current path: {}', path)\n+\ndef _sync_library(videoid, operation):\noperation = {\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added context menu to manually change watched status
At this moment Kodi do not allow to use the context menu
"Mark as watched/unwatched" when you override playcount/resumetime |
106,046 | 18.02.2020 16:18:20 | -3,600 | 549d5db115c3451d0d9de39a9b1cbcc19d8478ac | Fixed and improved db upgrade | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/database/db_update.py",
"new_path": "resources/lib/database/db_update.py",
"diff": "@@ -13,20 +13,20 @@ import resources.lib.common as common\nfrom resources.lib.globals import g\n-def run_local_db_updates(db_version, db_new_version): # pylint: disable=unused-argument\n+def run_local_db_updates(current_version, upgrade_to_version): # pylint: disable=unused-argument\n\"\"\"Perform database actions for a db version change\"\"\"\n# The changes must be left in sequence to allow cascade operations on non-updated databases\n- if common.is_less_version(db_version, '0.2'):\n+ if common.is_less_version(current_version, '0.2'):\npass\n- if common.is_less_version(db_version, '0.3'):\n+ if common.is_less_version(current_version, '0.3'):\npass\n-def run_shared_db_updates(db_version, db_new_version): # pylint: disable=unused-argument\n+def run_shared_db_updates(current_version, upgrade_to_version): # pylint: disable=unused-argument\n\"\"\"Perform database actions for a db version change\"\"\"\n# The changes must be left in sequence to allow cascade operations on non-updated databases\n- if common.is_less_version(db_version, '0.2'):\n+ if common.is_less_version(current_version, '0.2'):\n# Changes: added table 'watched_status_override'\n# SQLite\n@@ -70,5 +70,5 @@ def run_shared_db_updates(db_version, db_new_version): # pylint: disable=unused\ncur.execute(alter_tbl)\nshared_db_conn.conn.close()\n- if common.is_less_version(db_version, '0.3'):\n+ if common.is_less_version(current_version, '0.3'):\npass\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/upgrade_controller.py",
"new_path": "resources/lib/upgrade_controller.py",
"diff": "@@ -26,11 +26,18 @@ def check_addon_upgrade():\ndef check_service_upgrade():\n\"\"\"Check service upgrade and perform necessary update operations\"\"\"\n# Upgrades to be performed before starting the service\n- # Database upgrade\n- local_db_version = g.LOCAL_DB.get_value('local_db_version', '0.1')\n- shared_db_version = g.LOCAL_DB.get_value('shared_db_version', '0.1')\n- _perform_local_db_changes(local_db_version)\n- _perform_shared_db_changes(shared_db_version)\n+ # Upgrade the local database\n+ current_local_db_version = g.LOCAL_DB.get_value('local_db_version', None)\n+ upgrade_to_local_db_version = '0.1'\n+ if current_local_db_version != upgrade_to_local_db_version:\n+ _perform_local_db_changes(current_local_db_version, upgrade_to_local_db_version)\n+\n+ # Upgrade the shared databases\n+ current_shared_db_version = g.LOCAL_DB.get_value('shared_db_version', None)\n+ upgrade_to_shared_db_version = '0.2'\n+ if current_local_db_version != upgrade_to_local_db_version:\n+ _perform_shared_db_changes(current_shared_db_version, upgrade_to_shared_db_version)\n+\n# Perform service changes\nservice_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\nservice_current_ver = g.VERSION\n@@ -63,23 +70,28 @@ def _perform_service_changes(previous_ver, current_ver):\ng.LOCAL_DB.set_value('service_previous_version', current_ver)\n-def _perform_local_db_changes(db_version):\n+def _perform_local_db_changes(current_version, upgrade_to_version):\n\"\"\"Perform database actions for a db version change\"\"\"\n- db_new_version = '0.1'\n- if db_version != db_new_version:\n+ if current_version is not None:\nfrom resources.lib.common import debug\n- debug('Initialization of local database updates from version {} to {})',\n- db_version, db_new_version)\n- run_local_db_updates(db_version, db_new_version)\n- g.LOCAL_DB.set_value('local_db_version', db_new_version)\n+ debug('Initialization of local database updates from version {} to {})', current_version, upgrade_to_version)\n+ run_local_db_updates(current_version, upgrade_to_version)\n+ g.LOCAL_DB.set_value('local_db_version', upgrade_to_version)\n-def _perform_shared_db_changes(db_version):\n+def _perform_shared_db_changes(current_version, upgrade_to_version):\n\"\"\"Perform database actions for a db version change\"\"\"\n- db_new_version = '0.2'\n- if db_version != db_new_version:\n+ # This is a temporary bug fix, to be removed on future addon versions,\n+ # this because a previous oversight never saved the current version\n+ # Init fix\n+ from resources.lib.common import is_minimum_version\n+ service_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\n+ if current_version is None and not is_minimum_version(service_previous_ver, '0.17.0'):\n+ current_version = '0.1'\n+ # End fix\n+\n+ if current_version is not None:\nfrom resources.lib.common import debug\n- debug('Initialization of shared database updates from version {} to {})',\n- db_version, db_new_version)\n- run_shared_db_updates(db_version, db_new_version)\n- g.LOCAL_DB.set_value('shared_db_version', db_new_version)\n+ debug('Initialization of shared databases updates from version {} to {})', current_version, upgrade_to_version)\n+ run_shared_db_updates(current_version, upgrade_to_version)\n+ g.LOCAL_DB.set_value('shared_db_version', upgrade_to_version)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed and improved db upgrade |
106,046 | 20.02.2020 14:05:59 | -3,600 | 8c8da7e3c96215a760a74823f146f4b58e22eaae | xid value must be used for all subsequent requests until stop | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -23,6 +23,7 @@ import xbmc\n# import resources.lib.api.shakti as api\nimport resources.lib.cache as cache\nfrom resources.lib import common\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom resources.lib.services.msl import event_tag_builder\nfrom resources.lib.services.msl.msl_handler_base import build_request_data, ENDPOINTS\n@@ -200,7 +201,7 @@ class EventsHandler(threading.Thread):\nparams = {\n'event': event_type,\n- 'xid': previous_data.get('xid', str(timestamp + 1610)),\n+ 'xid': g.LOCAL_DB.get_value('xid', table=TABLE_SESSION),\n'position': player_state['elapsed_seconds'] * 1000, # Video time elapsed\n'clientTime': timestamp,\n'sessionStartTime': previous_data.get('sessionStartTime', timestamp),\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -11,18 +11,19 @@ from __future__ import absolute_import, division, unicode_literals\nimport json\nimport time\n+\nimport requests\nimport xbmcaddon\n-from resources.lib.globals import g\n-import resources.lib.common as common\nimport resources.lib.cache as cache\n+import resources.lib.common as common\n+from resources.lib.database.db_utils import TABLE_SESSION\n+from resources.lib.globals import g\n+from .converter import convert_to_dash\nfrom .events_handler import EventsHandler\nfrom .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info, build_request_data\n-\n-from .request_builder import MSLRequestBuilder\nfrom .profiles import enabled_profiles\n-from .converter import convert_to_dash\n+from .request_builder import MSLRequestBuilder\ntry: # Python 2\nunicode\n@@ -191,18 +192,21 @@ class MSLHandler(MSLHandlerBase):\ncommon.debug('Requesting license')\ntimestamp = int(time.time() * 10000)\n+ xid = str(timestamp + 1610)\n+\nparams = [{\n'sessionId': sid,\n'clientTime': int(timestamp / 10000),\n'challengeBase64': challenge,\n- 'xid': str(timestamp + 1610)\n+ 'xid': xid\n}]\n- url = self.last_license_url\n-\nresponse = self.chunked_request(ENDPOINTS['license'],\n- build_request_data(url, params, 'sessionId'),\n+ build_request_data(self.last_license_url, params, 'sessionId'),\ng.get_esn())\n+\n+ # This xid must be used for any future request, until playback stops\n+ g.LOCAL_DB.set_value('xid', xid, TABLE_SESSION)\nreturn response[0]['licenseResponseBase64']\[email protected]_execution(immediate=True)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | xid value must be used for all subsequent requests until stop |
106,046 | 20.02.2020 14:08:05 | -3,600 | fb681011b2c650a2356bb50c2a93d1f1758938fa | Implemented releasing server license | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/ipc.py",
"new_path": "resources/lib/common/ipc.py",
"diff": "@@ -32,6 +32,7 @@ class Signals(object): # pylint: disable=no-init\n# pylint: disable=too-few-public-methods\nPLAYBACK_INITIATED = 'playback_initiated'\nESN_CHANGED = 'esn_changed'\n+ RELEASE_LICENSE = 'release_license'\nLIBRARY_UPDATE_REQUESTED = 'library_update_requested'\nUPNEXT_ADDON_INIT = 'upnext_data'\nINVALIDATE_SERVICE_CACHE = 'invalidate_service_cache'\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -34,7 +34,9 @@ except NameError: # Python 3\nclass MSLHandler(MSLHandlerBase):\n\"\"\"Handles session management and crypto for license and manifest\nrequests\"\"\"\n+ last_license_session_id = ''\nlast_license_url = ''\n+ last_license_release_url = ''\nlast_drm_context = ''\nlast_playback_context = ''\nsession = requests.session()\n@@ -62,6 +64,9 @@ class MSLHandler(MSLHandlerBase):\ncommon.register_slot(\nsignal=common.Signals.ESN_CHANGED,\ncallback=self.perform_key_handshake)\n+ common.register_slot(\n+ signal=common.Signals.RELEASE_LICENSE,\n+ callback=self.release_license)\n@display_error_info\[email protected]_execution(immediate=True)\n@@ -207,8 +212,32 @@ class MSLHandler(MSLHandlerBase):\n# This xid must be used for any future request, until playback stops\ng.LOCAL_DB.set_value('xid', xid, TABLE_SESSION)\n+ self.last_license_session_id = sid\n+ self.last_license_release_url = response[0]['links']['releaseLicense']['href']\nreturn response[0]['licenseResponseBase64']\n+ @display_error_info\n+ @common.time_execution(immediate=True)\n+ def release_license(self, data=None): # pylint: disable=unused-argument\n+ \"\"\"\n+ Release the server license\n+ \"\"\"\n+ common.debug('Releasing license')\n+\n+ params = [{\n+ 'url': self.last_license_release_url,\n+ 'params': {\n+ 'sessionId': self.last_license_session_id,\n+ 'xid': g.LOCAL_DB.get_value('xid', table=TABLE_SESSION)\n+ },\n+ 'echo': 'sessionId'\n+ }]\n+\n+ response = self.chunked_request(ENDPOINTS['license'],\n+ build_request_data('/bundle', params),\n+ g.get_esn())\n+ common.debug('License release response: {}', response)\n+\[email protected]_execution(immediate=True)\ndef __tranform_to_dash(self, manifest):\nself.last_license_url = manifest['links']['license']['href']\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/controller.py",
"new_path": "resources/lib/services/playback/controller.py",
"diff": "@@ -121,6 +121,8 @@ class PlaybackController(xbmc.Monitor):\ndef _on_playback_stopped(self):\nself.tracking = False\nself.active_player_id = None\n+ # Immediately send the request to release the license\n+ common.send_signal(signal=common.Signals.RELEASE_LICENSE, non_blocking=True)\nself._notify_all(PlaybackActionManager.on_playback_stopped)\nself.action_managers = None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implemented releasing server license |
106,046 | 22.02.2020 19:44:33 | -3,600 | e3a976f83c7c56f4584b12e2db41a2fdaa967a87 | Avoid operations on frontend when there are no credentials | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/settings_monitor.py",
"new_path": "resources/lib/services/settings_monitor.py",
"diff": "@@ -108,6 +108,11 @@ class SettingsMonitor(xbmc.Monitor):\ng.LOCAL_DB.set_value('content_profiles_int', collect_int, TABLE_SETTINGS_MONITOR)\nclean_cache = True\n+ # Avoid perform these operations when the add-on is installed from scratch and there are no credentials\n+ if (clean_cache or reboot_addon) and not common.check_credentials():\n+ clean_cache = False\n+ reboot_addon = False\n+\nif clean_cache:\ncommon.run_plugin('plugin://plugin.video.netflix/action/purge_cache/'\n'?on_disk=True&no_notification=True')\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Avoid operations on frontend when there are no credentials |
106,046 | 22.02.2020 10:37:09 | -3,600 | 4bf20b96bb25850d083ab07b629acf7ece94da9a | Do not change pylint max line length | [
{
"change_type": "MODIFY",
"old_path": ".editorconfig",
"new_path": ".editorconfig",
"diff": "@@ -14,8 +14,6 @@ charset = utf-8\ntrim_trailing_whitespace = true\n# A file must end with an empty line - this is good for version control systems\ninsert_final_newline = true\n-# A line should not have more than this amount of chars (not supported by all plugins)\n-max_line_length = 100\n[*.{py,md,txt}]\nindent_size = 4\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Do not change pylint max line length |
106,046 | 22.02.2020 11:13:22 | -3,600 | e77aca7771bb0354d97bf04194ef8b241039c650 | Reworked msl classes
*there are some revert back to allow you to understand the changes in
the follow commit | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/android_crypto.py",
"new_path": "resources/lib/services/msl/android_crypto.py",
"diff": "@@ -23,28 +23,21 @@ from .exceptions import MSLError\nclass AndroidMSLCrypto(MSLBaseCrypto):\n\"\"\"Crypto handler for Android platforms\"\"\"\n- def __init__(self, msl_data=None): # pylint: disable=super-on-old-class\n- # pylint: disable=broad-except\n+ def __init__(self):\n+ super(AndroidMSLCrypto, self).__init__()\n+ self.crypto_session = None\n+ self.keyset_id = None\n+ self.key_id = None\n+ self.hmac_key_id = None\ntry:\nself.crypto_session = xbmcdrm.CryptoSession(\n'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed', 'AES/CBC/NoPadding', 'HmacSHA256')\ncommon.debug('Widevine CryptoSession successful constructed')\n- except Exception:\n+ except Exception: # pylint: disable=broad-except\nimport traceback\ncommon.error(traceback.format_exc())\nraise MSLError('Failed to construct Widevine CryptoSession')\n- try:\n- super(AndroidMSLCrypto, self).__init__(msl_data)\n- self.keyset_id = base64.standard_b64decode(msl_data['key_set_id'])\n- self.key_id = base64.standard_b64decode(msl_data['key_id'])\n- self.hmac_key_id = base64.standard_b64decode(msl_data['hmac_key_id'])\n- self.crypto_session.RestoreKeys(self.keyset_id)\n- except Exception:\n- self.keyset_id = None\n- self.key_id = None\n- self.hmac_key_id = None\n-\ndrm_info = {\n'version': self.crypto_session.GetPropertyString('version'),\n'system_id': self.crypto_session.GetPropertyString('systemId'),\n@@ -75,6 +68,14 @@ class AndroidMSLCrypto(MSLBaseCrypto):\ncommon.debug('Widevine CryptoSession max hdcp level supported', drm_info['hdcp_level_max'])\ncommon.debug('Widevine CryptoSession algorithms: {}', self.crypto_session.GetPropertyString('algorithms'))\n+ def load_crypto_session(self, msl_data=None):\n+ if not msl_data:\n+ return\n+ self.keyset_id = base64.standard_b64decode(msl_data['key_set_id'])\n+ self.key_id = base64.standard_b64decode(msl_data['key_id'])\n+ self.hmac_key_id = base64.standard_b64decode(msl_data['hmac_key_id'])\n+ self.crypto_session.RestoreKeys(self.keyset_id)\n+\ndef __del__(self):\nself.crypto_session = None\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/base_crypto.py",
"new_path": "resources/lib/services/msl/base_crypto.py",
"diff": "@@ -18,18 +18,25 @@ import resources.lib.common as common\nclass MSLBaseCrypto(object):\n\"\"\"Common base class for MSL crypto operations.\nHandles mastertoken and sequence number\"\"\"\n- # pylint: disable=too-few-public-methods\n- def __init__(self, msl_data=None):\n- if msl_data:\n- self._set_mastertoken(msl_data['tokens']['mastertoken'])\n- else:\n+\n+ def __init__(self):\n+ self._msl_data = None\nself.mastertoken = None\n+ self.serial_number = None\n+ self.sequence_number = None\n+ self.renewal_window = None\n+ self.expiration = None\n+\n+ def load_msl_data(self, msl_data=None):\n+ self._msl_data = msl_data if msl_data else {}\n+ if msl_data:\n+ self.set_mastertoken(msl_data['tokens']['mastertoken'])\ndef compare_mastertoken(self, mastertoken):\n\"\"\"Check if the new mastertoken is different from current due to renew\"\"\"\nif not self._mastertoken_is_newer_that(mastertoken):\ncommon.debug('MSL mastertoken is changed due to renew')\n- self._set_mastertoken(mastertoken)\n+ self.set_mastertoken(mastertoken)\nself._save_msl_data()\ndef _mastertoken_is_newer_that(self, mastertoken):\n@@ -48,12 +55,12 @@ class MSLBaseCrypto(object):\ndef parse_key_response(self, headerdata, save_to_disk):\n\"\"\"Parse a key response and update crypto keys\"\"\"\n- self._set_mastertoken(headerdata['keyresponsedata']['mastertoken'])\n+ self.set_mastertoken(headerdata['keyresponsedata']['mastertoken'])\nself._init_keys(headerdata['keyresponsedata'])\nif save_to_disk:\nself._save_msl_data()\n- def _set_mastertoken(self, mastertoken):\n+ def set_mastertoken(self, mastertoken):\n\"\"\"Set the mastertoken and check it for validity\"\"\"\ntokendata = json.loads(\nbase64.standard_b64decode(mastertoken['tokendata'].encode('utf-8')).decode('utf-8'))\n@@ -65,9 +72,9 @@ class MSLBaseCrypto(object):\ndef _save_msl_data(self):\n\"\"\"Save crypto keys and mastertoken to disk\"\"\"\n- msl_data = {'tokens': {'mastertoken': self.mastertoken}}\n- msl_data.update(self._export_keys())\n- common.save_file('msl_data.json', json.dumps(msl_data).encode('utf-8'))\n+ self._msl_data['tokens'] = {'mastertoken': self.mastertoken}\n+ self._msl_data.update(self._export_keys())\n+ common.save_file('msl_data.json', json.dumps(self._msl_data).encode('utf-8'))\ncommon.debug('Successfully saved MSL data to disk')\ndef _init_keys(self, key_response_data):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/default_crypto.py",
"new_path": "resources/lib/services/msl/default_crypto.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import json\nimport base64\n+import json\n+\ntry: # Python 3\nfrom Crypto.Random import get_random_bytes\nfrom Crypto.Hash import HMAC, SHA256\n@@ -30,23 +31,29 @@ except ImportError: # Python 2\nimport resources.lib.common as common\nfrom .base_crypto import MSLBaseCrypto\n+from .exceptions import MSLError\nclass DefaultMSLCrypto(MSLBaseCrypto):\n\"\"\"Crypto Handler for non-Android platforms\"\"\"\n- def __init__(self, msl_data=None): # pylint: disable=super-on-old-class\n- # pylint: disable=broad-except\n+\n+ def __init__(self):\n+ super(DefaultMSLCrypto, self).__init__()\n+ self.rsa_key = None\n+ self.encryption_key = None\n+ self.sign_key = None\n+\n+ def load_crypto_session(self, msl_data=None):\ntry:\n- super(DefaultMSLCrypto, self).__init__(msl_data)\nself.encryption_key = base64.standard_b64decode(\nmsl_data['encryption_key'])\nself.sign_key = base64.standard_b64decode(\nmsl_data['sign_key'])\nif not self.encryption_key or not self.sign_key:\n- raise ValueError('Missing encryption_key or sign_key')\n+ raise MSLError('Missing encryption_key or sign_key')\nself.rsa_key = RSA.importKey(\nbase64.standard_b64decode(msl_data['rsa_key']))\n- except Exception:\n+ except Exception: # pylint: disable=broad-except\ncommon.debug('Generating new RSA keys')\nself.rsa_key = RSA.generate(2048)\nself.encryption_key = None\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -25,20 +25,14 @@ import resources.lib.cache as cache\nfrom resources.lib import common\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\n-from resources.lib.services.msl import event_tag_builder\n-from resources.lib.services.msl.msl_handler_base import build_request_data, ENDPOINTS\n+from resources.lib.services.msl import msl_utils\n+from resources.lib.services.msl.msl_utils import EVENT_START, EVENT_STOP, EVENT_ENGAGE, ENDPOINTS\ntry:\nimport Queue as queue\nexcept ImportError: # Python 3\nimport queue\n-EVENT_START = 'start' # events/start : Video starts\n-EVENT_STOP = 'stop' # events/stop : Video stops\n-EVENT_KEEP_ALIVE = 'keepAlive' # events/keepAlive : Update progress status\n-EVENT_ENGAGE = 'engage' # events/engage : After user interaction (before stop, on skip, on pause)\n-EVENT_BIND = 'bind' # events/bind : ?\n-\nclass Event(object):\n\"\"\"Object representing an event request to be processed\"\"\"\n@@ -160,7 +154,12 @@ class EventsHandler(threading.Thread):\nevent_type, previous_data.get('xid'))\nreturn\n- event_data = build_request_data(url, self._build_event_params(event_type, event_data, player_state, manifest))\n+ from resources.lib.services.msl.msl_request_builder import MSLRequestBuilder\n+ event_data = MSLRequestBuilder.build_request_data(url,\n+ self._build_event_params(event_type,\n+ event_data,\n+ player_state,\n+ manifest))\ntry:\nself.queue_events.put_nowait(Event(event_data))\nexcept queue.Full:\n@@ -192,11 +191,11 @@ class EventsHandler(threading.Thread):\n# else:\n# list_id = g.LOCAL_DB.get_value('last_menu_id', 'unknown')\n- if event_tag_builder.is_media_changed(previous_player_state, player_state):\n- play_times, media_id = event_tag_builder.build_media_tag(player_state, manifest)\n+ if msl_utils.is_media_changed(previous_player_state, player_state):\n+ play_times, media_id = msl_utils.build_media_tag(player_state, manifest)\nelse:\nplay_times = previous_data['playTimes']\n- event_tag_builder.update_play_times_duration(play_times, player_state)\n+ msl_utils.update_play_times_duration(play_times, player_state)\nmedia_id = previous_data['mediaId']\nparams = {\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "\"\"\"\nCopyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\nCopyright (C) 2017 Trummerjo (original implementation module)\n- Proxy service to convert manifest and provide license data\n+ Proxy service to convert manifest, provide license data and handle events\nSPDX-License-Identifier: MIT\nSee LICENSES/MIT.md for more information.\n@@ -12,7 +12,6 @@ from __future__ import absolute_import, division, unicode_literals\nimport json\nimport time\n-import requests\nimport xbmcaddon\nimport resources.lib.cache as cache\n@@ -21,9 +20,9 @@ from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom .converter import convert_to_dash\nfrom .events_handler import EventsHandler\n-from .msl_handler_base import MSLHandlerBase, ENDPOINTS, display_error_info, build_request_data\n+from .msl_requests import MSLRequests\n+from .msl_utils import ENDPOINTS, display_error_info\nfrom .profiles import enabled_profiles\n-from .request_builder import MSLRequestBuilder\ntry: # Python 2\nunicode\n@@ -31,39 +30,31 @@ except NameError: # Python 3\nunicode = str # pylint: disable=redefined-builtin\n-class MSLHandler(MSLHandlerBase):\n- \"\"\"Handles session management and crypto for license and manifest\n- requests\"\"\"\n+class MSLHandler(object):\n+ \"\"\"Handles session management and crypto for license, manifest and event requests\"\"\"\nlast_license_session_id = ''\nlast_license_url = ''\nlast_license_release_url = ''\nlast_drm_context = ''\nlast_playback_context = ''\n- session = requests.session()\ndef __init__(self):\nsuper(MSLHandler, self).__init__()\n- # pylint: disable=broad-except\nself.request_builder = None\ntry:\nmsl_data = json.loads(common.load_file('msl_data.json'))\ncommon.info('Loaded MSL data from disk')\n- except Exception:\n+ except Exception: # pylint: disable=broad-except\nmsl_data = None\n- try:\n- self.request_builder = MSLRequestBuilder(msl_data)\n- # Addon just installed, the service starts but there is no esn\n- if g.get_esn():\n- self.check_mastertoken_validity()\n- events_handler = EventsHandler(self.chunked_request)\n+ self.request_builder = MSLRequests(msl_data)\n+\n+ events_handler = EventsHandler(self.request_builder.chunked_request)\nevents_handler.start()\n- except Exception:\n- import traceback\n- common.error(traceback.format_exc())\n+\ncommon.register_slot(\nsignal=common.Signals.ESN_CHANGED,\n- callback=self.perform_key_handshake)\n+ callback=self.request_builder.perform_key_handshake)\ncommon.register_slot(\nsignal=common.Signals.RELEASE_LICENSE,\ncallback=self.release_license)\n@@ -93,13 +84,13 @@ class MSLHandler(MSLHandlerBase):\ncommon.debug('Loading EDGE manifest')\nesn = g.get_edge_esn()\ncommon.debug('Switching MSL data to EDGE')\n- self.perform_key_handshake(esn)\n+ self.request_builder.perform_key_handshake(esn)\nmanifest = self._load_manifest(viewable_id, esn)\nmanifest['playbackContextId'] = chrome_manifest['playbackContextId']\nmanifest['drmContextId'] = chrome_manifest['drmContextId']\ncommon.debug('Successfully loaded EDGE manifest')\ncommon.debug('Resetting MSL data to Chrome')\n- self.perform_key_handshake()\n+ self.request_builder.perform_key_handshake()\nreturn manifest\[email protected]_execution(immediate=True)\n@@ -169,12 +160,9 @@ class MSLHandler(MSLHandlerBase):\n'preferAssistiveAudio': False\n}\n- # Get and check mastertoken validity\n- mt_validity = self.check_mastertoken_validity()\n- manifest = self.chunked_request(ENDPOINTS['manifest'],\n- build_request_data('/manifest', params),\n- esn,\n- mt_validity)\n+ manifest = self.request_builder.chunked_request(ENDPOINTS['manifest'],\n+ self.request_builder.build_request_data('/manifest', params),\n+ esn)\nif common.is_debug_verbose():\n# Save the manifest to disk as reference\ncommon.save_file('manifest.json', json.dumps(manifest).encode('utf-8'))\n@@ -198,22 +186,22 @@ class MSLHandler(MSLHandlerBase):\ntimestamp = int(time.time() * 10000)\nxid = str(timestamp + 1610)\n-\nparams = [{\n'sessionId': sid,\n'clientTime': int(timestamp / 10000),\n'challengeBase64': challenge,\n'xid': xid\n}]\n-\n- response = self.chunked_request(ENDPOINTS['license'],\n- build_request_data(self.last_license_url, params, 'sessionId'),\n+ response = self.request_builder.chunked_request(ENDPOINTS['license'],\n+ self.request_builder.build_request_data(self.last_license_url,\n+ params,\n+ 'sessionId'),\ng.get_esn())\n-\n# This xid must be used for any future request, until playback stops\ng.LOCAL_DB.set_value('xid', xid, TABLE_SESSION)\nself.last_license_session_id = sid\nself.last_license_release_url = response[0]['links']['releaseLicense']['href']\n+\nreturn response[0]['licenseResponseBase64']\n@display_error_info\n@@ -222,7 +210,7 @@ class MSLHandler(MSLHandlerBase):\n\"\"\"\nRelease the server license\n\"\"\"\n- common.debug('Releasing license')\n+ common.debug('Requesting releasing license')\nparams = [{\n'url': self.last_license_release_url,\n@@ -233,8 +221,8 @@ class MSLHandler(MSLHandlerBase):\n'echo': 'sessionId'\n}]\n- response = self.chunked_request(ENDPOINTS['license'],\n- build_request_data('/bundle', params),\n+ response = self.request_builder.chunked_request(ENDPOINTS['license'],\n+ self.request_builder.build_request_data('/bundle', params),\ng.get_esn())\ncommon.debug('License release response: {}', response)\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/services/msl/request_builder.py",
"new_path": "resources/lib/services/msl/msl_request_builder.py",
"diff": "@@ -35,11 +35,24 @@ else:\nclass MSLRequestBuilder(object):\n\"\"\"Provides mechanisms to create MSL requests\"\"\"\n- def __init__(self, msl_data=None):\n+ def __init__(self):\nself.current_message_id = None\n- self.user_id_token = None\nself.rndm = random.SystemRandom()\n- self.crypto = MSLCrypto(msl_data)\n+ self.crypto = MSLCrypto()\n+\n+ @staticmethod\n+ def build_request_data(url, params=None, echo=''):\n+ \"\"\"Create a standard request data\"\"\"\n+ timestamp = int(time.time() * 10000)\n+ request_data = {\n+ 'version': 2,\n+ 'url': url,\n+ 'id': timestamp,\n+ 'languages': [g.LOCAL_DB.get_profile_config('language')],\n+ 'params': params,\n+ 'echo': echo\n+ }\n+ return request_data\[email protected]_execution(immediate=True)\ndef msl_request(self, data, esn):\n@@ -91,7 +104,7 @@ class MSLRequestBuilder(object):\nheader_data['keyrequestdata'] = self.crypto.key_request_data()\nelse:\nheader_data['sender'] = esn\n- _add_auth_info(header_data, self.user_id_token)\n+ self._add_auth_info(header_data)\nreturn json.dumps(header_data)\n@@ -121,13 +134,8 @@ class MSLRequestBuilder(object):\nreturn json.loads(self.crypto.decrypt(init_vector, cipher_text))\nreturn header_data\n-\n-def _add_auth_info(header_data, user_id_token):\n+ def _add_auth_info(self, header_data):\n\"\"\"User authentication identifies the application user associated with a message\"\"\"\n- if user_id_token and _is_useridtoken_valid(user_id_token):\n- # Authentication with user ID token containing the user identity\n- header_data['useridtoken'] = user_id_token\n- else:\n# Authentication with the user credentials\ncredentials = common.get_credentials()\nheader_data['userauthdata'] = {\n@@ -137,9 +145,3 @@ def _add_auth_info(header_data, user_id_token):\n'password': credentials['password']\n}\n}\n-\n-\n-def _is_useridtoken_valid(user_id_token):\n- \"\"\"Check if user id token is not expired\"\"\"\n- token_data = json.loads(base64.standard_b64decode(user_id_token['tokendata']))\n- return token_data['expiration'] > time.time()\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/services/msl/msl_handler_base.py",
"new_path": "resources/lib/services/msl/msl_requests.py",
"diff": "# -*- coding: utf-8 -*-\n\"\"\"\nCopyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n- Copyright (C) 2017 Trummerjo (original implementation module)\n- Proxy service to convert manifest and provide license data\n+ Copyright (C) 2018 Caphm (original implementation module)\n+ MSL request building\nSPDX-License-Identifier: MIT\nSee LICENSES/MIT.md for more information.\n@@ -14,76 +14,36 @@ import json\nimport re\nimport time\nimport zlib\n-from functools import wraps\nimport requests\nimport resources.lib.common as common\n-import resources.lib.kodi.ui as ui\nfrom resources.lib.globals import g\nfrom resources.lib.services.msl.exceptions import MSLError\n-from resources.lib.services.msl.request_builder import MSLRequestBuilder\n+from resources.lib.services.msl.msl_request_builder import MSLRequestBuilder\n+from resources.lib.services.msl.msl_utils import display_error_info, ENDPOINTS\n-try: # Python 2\n- unicode\n-except NameError: # Python 3\n- unicode = str # pylint: disable=redefined-builtin\n+class MSLRequests(MSLRequestBuilder):\n-CHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\n-ENDPOINTS = {\n- 'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n- 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router',\n- 'events': CHROME_BASE_URL + 'pbo_events/%5E1.0.0/router'\n-}\n+ def __init__(self, msl_data=None):\n+ super(MSLRequests, self).__init__()\n+ self.session = requests.session()\n+ self._load_msl_data(msl_data)\n-\n-def display_error_info(func):\n- \"\"\"Decorator that catches errors raise by the decorated function,\n- displays an error info dialog in the UI and reraises the error\"\"\"\n- # pylint: disable=missing-docstring\n- @wraps(func)\n- def error_catching_wrapper(*args, **kwargs):\n+ def _load_msl_data(self, msl_data):\ntry:\n- return func(*args, **kwargs)\n- except Exception as exc:\n- ui.show_error_info(common.get_local_string(30028), unicode(exc),\n- unknown_error=not(unicode(exc)),\n- netflix_error=isinstance(exc, MSLError))\n- raise\n- return error_catching_wrapper\n-\n-\n-class MSLHandlerBase(object):\n- \"\"\"Handles session management and crypto for license, manifest and event requests\"\"\"\n- last_license_url = ''\n- last_drm_context = ''\n- last_playback_context = ''\n- session = requests.session()\n+ self.crypto.load_msl_data(msl_data)\n+ self.crypto.load_crypto_session(msl_data)\n- def __init__(self):\n- self.request_builder = None\n-\n- def check_mastertoken_validity(self):\n- \"\"\"Return the mastertoken validity and executes a new key handshake when necessary\"\"\"\n- if self.request_builder.crypto.mastertoken:\n- time_now = time.time()\n- renewable = self.request_builder.crypto.renewal_window < time_now\n- expired = self.request_builder.crypto.expiration <= time_now\n- else:\n- renewable = False\n- expired = True\n- if expired:\n- if not self.request_builder.crypto.mastertoken:\n- common.debug('Stored MSL data not available, a new key handshake will be performed')\n- self.request_builder = MSLRequestBuilder()\n- else:\n- common.debug('Stored MSL data is expired, a new key handshake will be performed')\n- if self.perform_key_handshake():\n- self.request_builder = MSLRequestBuilder(json.loads(\n- common.load_file('msl_data.json')))\n- return self.check_mastertoken_validity()\n- return {'renewable': renewable, 'expired': expired}\n+ # Add-on just installed, the service starts but there is no esn\n+ if g.get_esn():\n+ self._check_mastertoken_validity()\n+ except MSLError:\n+ raise\n+ except Exception: # pylint: disable=broad-except\n+ import traceback\n+ common.error(traceback.format_exc())\n@display_error_info\[email protected]_execution(immediate=True)\n@@ -97,21 +57,45 @@ class MSLHandlerBase(object):\ncommon.debug('Performing key handshake. ESN: {}', esn)\n- response = _process_json_response(\n- self._post(ENDPOINTS['manifest'],\n- self.request_builder.handshake_request(esn)))\n- header_data = self.request_builder.decrypt_header_data(response['headerdata'], False)\n- self.request_builder.crypto.parse_key_response(header_data, not common.is_edge_esn(esn))\n- # Reset the user id token\n- self.request_builder.user_id_token = None\n+ response = _process_json_response(self._post(ENDPOINTS['manifest'], self.handshake_request(esn)))\n+ header_data = self.decrypt_header_data(response['headerdata'], False)\n+ self.crypto.parse_key_response(header_data, not common.is_edge_esn(esn))\n+\n+ # Delete all the user id tokens (are correlated to the previous mastertoken)\n+ # self.crypto.clear_user_id_tokens()\ncommon.debug('Key handshake successful')\nreturn True\n+ def _check_mastertoken_validity(self):\n+ \"\"\"Return the mastertoken validity and executes a new key handshake when necessary\"\"\"\n+ if self.crypto.mastertoken:\n+ time_now = time.time()\n+ renewable = self.crypto.renewal_window < time_now\n+ expired = self.crypto.expiration <= time_now\n+ else:\n+ renewable = False\n+ expired = True\n+ if expired:\n+ if not self.crypto.mastertoken:\n+ debug_msg = 'Stored MSL data not available, a new key handshake will be performed'\n+ else:\n+ debug_msg = 'Stored MSL data is expired, a new key handshake will be performed'\n+ common.debug(debug_msg)\n+ if self.perform_key_handshake():\n+ msl_data = json.loads(common.load_file('msl_data.json'))\n+ self.crypto.load_msl_data(msl_data)\n+ self.crypto.load_crypto_session(msl_data)\n+ return self._check_mastertoken_validity()\n+ return {'renewable': renewable, 'expired': expired}\n+\[email protected]_execution(immediate=True)\n- def chunked_request(self, endpoint, request_data, esn, mt_validity=None):\n+ def chunked_request(self, endpoint, request_data, esn):\n\"\"\"Do a POST request and process the chunked response\"\"\"\n+\n+ mt_validity = self._check_mastertoken_validity()\n+\nchunked_response = self._process_chunked_response(\n- self._post(endpoint, self.request_builder.msl_request(request_data, esn)),\n+ self._post(endpoint, self.msl_request(request_data, esn)),\nmt_validity['renewable'] if mt_validity else None)\nreturn chunked_response['result']\n@@ -144,37 +128,16 @@ class MSLHandlerBase(object):\n# # Check if mastertoken is renewed\n# self.request_builder.crypto.compare_mastertoken(response['header']['mastertoken'])\n- header_data = self.request_builder.decrypt_header_data(\n- response['header'].get('headerdata'))\n+ # header_data = self.decrypt_header_data(response['header'].get('headerdata'))\n- if 'useridtoken' in header_data:\n- # After the first call, it is possible get the 'user id token' that contains the\n- # user identity to use instead of 'User Authentication Data' with user credentials\n- self.request_builder.user_id_token = header_data['useridtoken']\n# if 'keyresponsedata' in header_data:\n# common.debug('Found key handshake in response data')\n# # Update current mastertoken\n# self.request_builder.crypto.parse_key_response(header_data, True)\n- decrypted_response = _decrypt_chunks(response['payloads'], self.request_builder.crypto)\n+ decrypted_response = _decrypt_chunks(response['payloads'], self.crypto)\nreturn _raise_if_error(decrypted_response)\n-def build_request_data(url, params=None, echo=''):\n- \"\"\"Create a standard request data\"\"\"\n- if not params:\n- raise Exception('Cannot build the message without parameters')\n- timestamp = int(time.time() * 10000)\n- request_data = {\n- 'version': 2,\n- 'url': url,\n- 'id': timestamp,\n- 'languages': [g.LOCAL_DB.get_profile_config('language')],\n- 'params': params,\n- 'echo': echo\n- }\n- return request_data\n-\n-\[email protected]_execution(immediate=True)\ndef _process_json_response(response):\n\"\"\"Execute a post request and expect a JSON response\"\"\"\n@@ -203,9 +166,7 @@ def _raise_if_error(decoded_response):\ndef _get_error_details(decoded_response):\n# Catch a chunk error\nif 'errordata' in decoded_response:\n- return json.loads(\n- base64.standard_b64decode(\n- decoded_response['errordata']))['errormsg']\n+ return json.loads(base64.standard_b64decode(decoded_response['errordata']))['errormsg']\n# Catch a manifest error\nif 'error' in decoded_response:\nif decoded_response['error'].get('errorDisplayMessage'):\n@@ -221,8 +182,7 @@ def _get_error_details(decoded_response):\[email protected]_execution(immediate=True)\ndef _parse_chunks(message):\nheader = json.loads(message.split('}}')[0] + '}}')\n- payloads = re.split(',\\\"signature\\\":\\\"[0-9A-Za-z=/+]+\\\"}',\n- message.split('}}')[1])\n+ payloads = re.split(',\\\"signature\\\":\\\"[0-9A-Za-z=/+]+\\\"}', message.split('}}')[1])\npayloads = [x + '}' for x in payloads][:-1]\nreturn {'header': header, 'payloads': payloads}\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/services/msl/event_tag_builder.py",
"new_path": "resources/lib/services/msl/msl_utils.py",
"diff": "\"\"\"\nCopyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\nCopyright (C) 2019 Stefano Gottardo - @CastagnaIT (original implementation module)\n- Build event tags values\n+ Msl utils\nSPDX-License-Identifier: MIT\nSee LICENSES/MIT.md for more information.\n\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+from functools import wraps\n+\n+import resources.lib.kodi.ui as ui\nfrom resources.lib import common\n+from resources.lib.services.msl.exceptions import MSLError\n+\n+try: # Python 2\n+ unicode\n+except NameError: # Python 3\n+ unicode = str # pylint: disable=redefined-builtin\n+\n+CHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\n+\n+ENDPOINTS = {\n+ 'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n+ 'license': CHROME_BASE_URL + 'pbo_licenses/%5E1.0.0/router',\n+ 'events': CHROME_BASE_URL + 'pbo_events/%5E1.0.0/router',\n+ 'logblobs': CHROME_BASE_URL + 'pbo_logblobs/%5E1.0.0/router'\n+}\n+\n+EVENT_START = 'start' # events/start : Video starts\n+EVENT_STOP = 'stop' # events/stop : Video stops\n+EVENT_KEEP_ALIVE = 'keepAlive' # events/keepAlive : Update progress status\n+EVENT_ENGAGE = 'engage' # events/engage : After user interaction (before stop, on skip, on pause)\n+EVENT_BIND = 'bind' # events/bind : ?\nAUDIO_CHANNELS_CONV = {1: '1.0', 2: '2.0', 6: '5.1', 8: '7.1'}\n+def display_error_info(func):\n+ \"\"\"Decorator that catches errors raise by the decorated function,\n+ displays an error info dialog in the UI and re-raises the error\"\"\"\n+ # pylint: disable=missing-docstring\n+ @wraps(func)\n+ def error_catching_wrapper(*args, **kwargs):\n+ try:\n+ return func(*args, **kwargs)\n+ except Exception as exc:\n+ ui.show_error_info(common.get_local_string(30028), unicode(exc),\n+ unknown_error=not(unicode(exc)),\n+ netflix_error=isinstance(exc, MSLError))\n+ raise\n+ return error_catching_wrapper\n+\n+\ndef is_media_changed(previous_player_state, player_state):\n\"\"\"Check if there are variations in player state to avoids overhead processing\"\"\"\nif not previous_player_state:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "@@ -13,7 +13,7 @@ from xbmcgui import Window\nimport resources.lib.common as common\nfrom resources.lib.globals import g\n-from resources.lib.services.msl.events_handler import EVENT_STOP, EVENT_KEEP_ALIVE, EVENT_START, EVENT_ENGAGE\n+from resources.lib.services.msl.msl_utils import EVENT_START, EVENT_ENGAGE, EVENT_STOP, EVENT_KEEP_ALIVE\nfrom .action_manager import PlaybackActionManager\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Reworked msl classes
*there are some revert back to allow you to understand the changes in
the follow commit |
106,046 | 22.02.2020 11:38:28 | -3,600 | 4fb863dc16bfc90091d427e823dba9ea178a4a44 | Implemented the MSL switch profile | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/base_crypto.py",
"new_path": "resources/lib/services/msl/base_crypto.py",
"diff": "@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, unicode_literals\nimport json\nimport base64\n+import time\nimport resources.lib.common as common\n@@ -84,3 +85,32 @@ class MSLBaseCrypto(object):\ndef _export_keys(self):\n\"\"\"Export crypto keys to a dict\"\"\"\nraise NotImplementedError\n+\n+ def get_user_id_token(self, profile_guid):\n+ \"\"\"Get a valid the user id token associated to a profile guid\"\"\"\n+ if 'user_id_tokens' in self._msl_data:\n+ user_id_token = self._msl_data['user_id_tokens'].get(profile_guid)\n+ if user_id_token and self.is_user_id_token_valid(user_id_token):\n+ return user_id_token\n+ return None\n+\n+ def save_user_id_token(self, profile_guid, user_token_id):\n+ \"\"\"Save or update a user id token associated to a profile guid\"\"\"\n+ if 'user_id_tokens' not in self._msl_data:\n+ self._msl_data['user_id_tokens'] = {\n+ profile_guid: user_token_id\n+ }\n+ else:\n+ self._msl_data['user_id_tokens'][profile_guid] = user_token_id\n+ self._save_msl_data()\n+\n+ def clear_user_id_tokens(self):\n+ \"\"\"Clear all user id tokens\"\"\"\n+ self._msl_data.pop('user_id_tokens', None)\n+ self._save_msl_data()\n+\n+ def is_user_id_token_valid(self, user_id_token):\n+ \"\"\"Check if user id token is not expired\"\"\"\n+ token_data = json.loads(base64.standard_b64decode(user_id_token['tokendata']))\n+ # Subtract 5min as a safety measure\n+ return (token_data['expiration'] - 300) > time.time()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -162,7 +162,8 @@ class MSLHandler(object):\nmanifest = self.request_builder.chunked_request(ENDPOINTS['manifest'],\nself.request_builder.build_request_data('/manifest', params),\n- esn)\n+ esn,\n+ disable_msl_switch=False)\nif common.is_debug_verbose():\n# Save the manifest to disk as reference\ncommon.save_file('manifest.json', json.dumps(manifest).encode('utf-8'))\n@@ -202,8 +203,25 @@ class MSLHandler(object):\nself.last_license_session_id = sid\nself.last_license_release_url = response[0]['links']['releaseLicense']['href']\n+ if self.request_builder.msl_switch_requested:\n+ self.request_builder.msl_switch_requested = False\n+ self.bind_events()\nreturn response[0]['licenseResponseBase64']\n+ def bind_events(self):\n+ \"\"\"\n+ Bind events\n+ \"\"\"\n+ # I don't know the real purpose of its use, it seems to be requested after the license and before starting\n+ # playback, and only the first time after a switch,\n+ # in the response you can also understand if the msl switch has worked\n+ common.debug('Requesting bind events')\n+ response = self.request_builder.chunked_request(ENDPOINTS['events'],\n+ self.request_builder.build_request_data('/bind', {}),\n+ g.get_esn(),\n+ disable_msl_switch=False)\n+ common.debug('Bind events response: {}', response)\n+\n@display_error_info\[email protected]_execution(immediate=True)\ndef release_license(self, data=None): # pylint: disable=unused-argument\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_request_builder.py",
"new_path": "resources/lib/services/msl/msl_request_builder.py",
"diff": "@@ -55,9 +55,9 @@ class MSLRequestBuilder(object):\nreturn request_data\[email protected]_execution(immediate=True)\n- def msl_request(self, data, esn):\n+ def msl_request(self, data, esn, auth_data):\n\"\"\"Create an encrypted MSL request\"\"\"\n- return (json.dumps(self._signed_header(esn)) +\n+ return (json.dumps(self._signed_header(esn, auth_data)) +\njson.dumps(self._encrypted_chunk(data, esn)))\[email protected]_execution(immediate=True)\n@@ -69,15 +69,15 @@ class MSLRequestBuilder(object):\n'authdata': {'identity': esn}},\n'headerdata':\nbase64.standard_b64encode(\n- self._headerdata(is_handshake=True).encode('utf-8')).decode('utf-8'),\n+ self._headerdata(auth_data={}, is_handshake=True).encode('utf-8')).decode('utf-8'),\n'signature': ''\n}, sort_keys=True)\npayload = json.dumps(self._encrypted_chunk(envelope_payload=False))\nreturn header + payload\[email protected]_execution(immediate=True)\n- def _signed_header(self, esn):\n- encryption_envelope = self.crypto.encrypt(self._headerdata(esn=esn), esn)\n+ def _signed_header(self, esn, auth_data):\n+ encryption_envelope = self.crypto.encrypt(self._headerdata(auth_data=auth_data, esn=esn), esn)\nreturn {\n'headerdata': base64.standard_b64encode(\nencryption_envelope.encode('utf-8')).decode('utf-8'),\n@@ -85,7 +85,7 @@ class MSLRequestBuilder(object):\n'mastertoken': self.crypto.mastertoken,\n}\n- def _headerdata(self, esn=None, compression=None, is_handshake=False):\n+ def _headerdata(self, auth_data, esn=None, compression=None, is_handshake=False):\n\"\"\"\nFunction that generates a MSL header dict\n:return: The base64 encoded JSON String of the header\n@@ -104,7 +104,7 @@ class MSLRequestBuilder(object):\nheader_data['keyrequestdata'] = self.crypto.key_request_data()\nelse:\nheader_data['sender'] = esn\n- self._add_auth_info(header_data)\n+ self._add_auth_info(header_data, auth_data)\nreturn json.dumps(header_data)\n@@ -134,8 +134,27 @@ class MSLRequestBuilder(object):\nreturn json.loads(self.crypto.decrypt(init_vector, cipher_text))\nreturn header_data\n- def _add_auth_info(self, header_data):\n+ def _add_auth_info(self, header_data, auth_data):\n\"\"\"User authentication identifies the application user associated with a message\"\"\"\n+ # Warning: the user id token contains also contains the identity of the netflix profile\n+ # therefore it is necessary to use the right user id token for the request\n+ if auth_data.get('user_id_token'):\n+ if auth_data['use_switch_profile']:\n+ # The SWITCH_PROFILE is a custom Netflix MSL user authentication scheme\n+ # that is needed for switching profile on MSL side\n+ # works only combined with user id token and can not be used with all endpoints\n+ # after use it you will get user id token of the profile specified in the response\n+ header_data['userauthdata'] = {\n+ 'scheme': 'SWITCH_PROFILE',\n+ 'authdata': {\n+ 'useridtoken': auth_data['user_id_token'],\n+ 'profileguid': g.LOCAL_DB.get_active_profile_guid()\n+ }\n+ }\n+ else:\n+ # Authentication with user ID token containing the user identity (netflix profile)\n+ header_data['useridtoken'] = auth_data['user_id_token']\n+ else:\n# Authentication with the user credentials\ncredentials = common.get_credentials()\nheader_data['userauthdata'] = {\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_requests.py",
"new_path": "resources/lib/services/msl/msl_requests.py",
"diff": "@@ -21,7 +21,12 @@ import resources.lib.common as common\nfrom resources.lib.globals import g\nfrom resources.lib.services.msl.exceptions import MSLError\nfrom resources.lib.services.msl.msl_request_builder import MSLRequestBuilder\n-from resources.lib.services.msl.msl_utils import display_error_info, ENDPOINTS\n+from resources.lib.services.msl.msl_utils import display_error_info, generate_logblobs_params, EVENT_BIND, ENDPOINTS\n+\n+try: # Python 2\n+ from urllib import urlencode\n+except ImportError: # Python 3\n+ from urllib.parse import urlencode\nclass MSLRequests(MSLRequestBuilder):\n@@ -30,6 +35,7 @@ class MSLRequests(MSLRequestBuilder):\nsuper(MSLRequests, self).__init__()\nself.session = requests.session()\nself._load_msl_data(msl_data)\n+ self.msl_switch_requested = False\ndef _load_msl_data(self, msl_data):\ntry:\n@@ -62,10 +68,29 @@ class MSLRequests(MSLRequestBuilder):\nself.crypto.parse_key_response(header_data, not common.is_edge_esn(esn))\n# Delete all the user id tokens (are correlated to the previous mastertoken)\n- # self.crypto.clear_user_id_tokens()\n+ self.crypto.clear_user_id_tokens()\ncommon.debug('Key handshake successful')\nreturn True\n+ def _get_owner_user_id_token(self):\n+ \"\"\"A way to get the user token id of owner profile\"\"\"\n+ # In order to get a user id token of another (non-owner) profile you must make a request with SWITCH_PROFILE\n+ # authentication scheme (a custom authentication for netflix), and this request can be directly included\n+ # in the MSL manifest request.\n+ # But in order to execute this switch profile, you need to have the user id token of the main (owner) profile.\n+ # The only way (found to now) to get it immediately, is send a logblob event request, and save the\n+ # user id token obtained in the response.\n+ common.debug('Requesting logblog')\n+ params = {'reqAttempt': 1,\n+ 'reqPriority': 0,\n+ 'reqName': EVENT_BIND}\n+ url = ENDPOINTS['logblobs'] + '?' + urlencode(params).replace('%2F', '/')\n+ response = self.chunked_request(url,\n+ self.build_request_data('/logblob', generate_logblobs_params()),\n+ g.get_esn(),\n+ force_auth_credential=True)\n+ common.debug('Response of logblob request: {}', response)\n+\ndef _check_mastertoken_validity(self):\n\"\"\"Return the mastertoken validity and executes a new key handshake when necessary\"\"\"\nif self.crypto.mastertoken:\n@@ -88,15 +113,56 @@ class MSLRequests(MSLRequestBuilder):\nreturn self._check_mastertoken_validity()\nreturn {'renewable': renewable, 'expired': expired}\n+ def _check_user_id_token(self, disable_msl_switch, force_auth_credential=False):\n+ \"\"\"\n+ Performs user id token checks and return the auth data\n+ checks: uid token validity, get if needed the owner uid token, set when use the switch\n+\n+ :param: disable_msl_switch: to be used in requests that cannot make the switch\n+ :param: force_auth_credential: force the use of authentication with credentials\n+ :return: auth data that will be used in MSLRequestBuilder _add_auth_info\n+ \"\"\"\n+ # Warning: the user id token contains also contains the identity of the netflix profile\n+ # therefore it is necessary to use the right user id token for the request\n+ current_profile_guid = g.LOCAL_DB.get_active_profile_guid()\n+ owner_profile_guid = g.LOCAL_DB.get_guid_owner_profile()\n+ use_switch_profile = False\n+ user_id_token = None\n+\n+ if not force_auth_credential:\n+ if current_profile_guid == owner_profile_guid:\n+ # It is not necessary to get a token id because by default MSL it is associated to the main profile\n+ # So you do not even need to run the MSL profile switch\n+ user_id_token = self.crypto.get_user_id_token(current_profile_guid)\n+ # user_id_token can return None when the add-on is installed from scratch, in this case will be used\n+ # the authentication with the user credentials\n+ else:\n+ # The request must be executed from a non-owner profile\n+ # Check if the token for the profile exist and valid\n+ user_id_token = self.crypto.get_user_id_token(current_profile_guid)\n+ if not user_id_token and not disable_msl_switch:\n+ # If it is not there, first check if the main profile token exist and valid\n+ use_switch_profile = True\n+ user_id_token = self.crypto.get_user_id_token(owner_profile_guid)\n+ # If it is not there, you must obtain it before making the MSL switch\n+ if not user_id_token:\n+ self._get_owner_user_id_token()\n+ user_id_token = self.crypto.get_user_id_token(owner_profile_guid)\n+ # Mark msl_switch_requested as True in order to make a bind event request\n+ self.msl_switch_requested = True\n+ return {'use_switch_profile': use_switch_profile, 'user_id_token': user_id_token}\n+\[email protected]_execution(immediate=True)\n- def chunked_request(self, endpoint, request_data, esn):\n+ def chunked_request(self, endpoint, request_data, esn, disable_msl_switch=True, force_auth_credential=False):\n\"\"\"Do a POST request and process the chunked response\"\"\"\nmt_validity = self._check_mastertoken_validity()\n+ auth_data = self._check_user_id_token(disable_msl_switch, force_auth_credential)\nchunked_response = self._process_chunked_response(\n- self._post(endpoint, self.msl_request(request_data, esn)),\n- mt_validity['renewable'] if mt_validity else None)\n+ self._post(endpoint, self.msl_request(request_data, esn, auth_data)),\n+ mt_validity['renewable'] if mt_validity else None,\n+ save_uid_token_to_owner=auth_data['user_id_token'] is None)\nreturn chunked_response['result']\[email protected]_execution(immediate=True)\n@@ -112,7 +178,7 @@ class MSLRequests(MSLRequestBuilder):\n# pylint: disable=unused-argument\[email protected]_execution(immediate=True)\n- def _process_chunked_response(self, response, mt_renewable):\n+ def _process_chunked_response(self, response, mt_renewable, save_uid_token_to_owner=False):\n\"\"\"Parse and decrypt an encrypted chunked response. Raise an error\nif the response is plaintext json\"\"\"\ntry:\n@@ -128,8 +194,13 @@ class MSLRequests(MSLRequestBuilder):\n# # Check if mastertoken is renewed\n# self.request_builder.crypto.compare_mastertoken(response['header']['mastertoken'])\n- # header_data = self.decrypt_header_data(response['header'].get('headerdata'))\n+ header_data = self.decrypt_header_data(response['header'].get('headerdata'))\n+ if 'useridtoken' in header_data:\n+ # Save the user id token for the future msl requests\n+ profile_guid = g.LOCAL_DB.get_guid_owner_profile() if save_uid_token_to_owner else\\\n+ g.LOCAL_DB.get_active_profile_guid()\n+ self.crypto.save_user_id_token(profile_guid, header_data['useridtoken'])\n# if 'keyresponsedata' in header_data:\n# common.debug('Found key handshake in response data')\n# # Update current mastertoken\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_utils.py",
"new_path": "resources/lib/services/msl/msl_utils.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+import json\n+import random\n+import re\n+import time\nfrom functools import wraps\n+import xbmcgui\n+\nimport resources.lib.kodi.ui as ui\nfrom resources.lib import common\n+from resources.lib.database.db_utils import TABLE_SESSION\n+from resources.lib.globals import g\nfrom resources.lib.services.msl.exceptions import MSLError\ntry: # Python 2\n@@ -137,3 +145,65 @@ def _find_video_data(player_state, manifest):\n# Not found?\nraise Exception('build_media_tag: unable to find video data with codec: {}, width: {}, height: {}'\n.format(codec, width, height))\n+\n+\n+def generate_logblobs_params():\n+ \"\"\"Generate the initial log blog\"\"\"\n+ # It seems that this log is sent when logging in to a profile the first time\n+ # i think it is the easiest to reproduce, the others contain too much data\n+ screen_size = str(xbmcgui.getScreenWidth()) + 'x' + str(xbmcgui.getScreenHeight())\n+ timestamp_utc = time.time()\n+ timestamp = int(timestamp_utc * 1000)\n+ client_ver = g.LOCAL_DB.get_value('asset_core', '', table=TABLE_SESSION)\n+ app_id = int(time.time()) * 10000 + random.randint(1, 10001) # Should be used with all log requests\n+ if client_ver:\n+ result = re.search(r'-([0-9\\.]+)\\.js$', client_ver)\n+ client_ver = result.groups()[0]\n+\n+ # Here you have to enter only the real data, falsifying the data would cause repercussions in netflix server logs\n+ # therefore since it is possible to exclude data, we avoid entering data that we do not have\n+ blob = {\n+ 'browserua': common.get_user_agent().replace(' ', '#'),\n+ 'browserhref': 'https://www.netflix.com/browse',\n+ # 'initstart': 988,\n+ # 'initdelay': 268,\n+ 'screensize': screen_size, # '1920x1080',\n+ 'screenavailsize': screen_size, # '1920x1040',\n+ 'clientsize': screen_size, # '1920x944',\n+ # 'pt_navigationStart': -1880,\n+ # 'pt_fetchStart': -1874,\n+ # 'pt_secureConnectionStart': -1880,\n+ # 'pt_requestStart': -1853,\n+ # 'pt_domLoading': -638,\n+ # 'm_asl_start': 990,\n+ # 'm_stf_creat': 993,\n+ # 'm_idb_open': 993,\n+ # 'm_idb_succ': 1021,\n+ # 'm_msl_load_no_data': 1059,\n+ # 'm_asl_comp': 1256,\n+ 'type': 'startup',\n+ 'sev': 'info',\n+ 'devmod': 'chrome-cadmium',\n+ 'clver': client_ver, # e.g. '6.0021.220.051'\n+ 'osplatform': g.LOCAL_DB.get_value('browser_info_os_name', '', table=TABLE_SESSION),\n+ 'osver': g.LOCAL_DB.get_value('browser_info_os_version', '', table=TABLE_SESSION),\n+ 'browsername': 'Chrome',\n+ 'browserver': g.LOCAL_DB.get_value('browser_info_version', '', table=TABLE_SESSION),\n+ 'appLogSeqNum': 0,\n+ 'uniqueLogId': common.get_random_uuid(),\n+ 'appId': app_id,\n+ 'esn': g.get_esn(),\n+ 'lver': '',\n+ # 'jssid': '15822792997793', # Same value of appId\n+ # 'jsoffms': 1261,\n+ 'clienttime': timestamp,\n+ 'client_utc': timestamp_utc,\n+ 'uiver': g.LOCAL_DB.get_value('ui_version', '', table=TABLE_SESSION)\n+ }\n+\n+ blobs_container = {\n+ 'entries': [blob]\n+ }\n+ blobs_dump = json.dumps(blobs_container)\n+ blobs_dump = blobs_dump.replace('\"', '\\\"').replace(' ', '').replace('#', ' ')\n+ return {'logblobs': blobs_dump}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implemented the MSL switch profile |
106,046 | 22.02.2020 11:38:50 | -3,600 | 33292cf6f08b8ab9ba9b0bca66a826bd8f069b64 | Updated test stub | [
{
"change_type": "MODIFY",
"old_path": "test/xbmcgui.py",
"new_path": "test/xbmcgui.py",
"diff": "@@ -16,6 +16,16 @@ INPUT_TYPE_NUMBER = 1\nALPHANUM_HIDE_INPUT = 1\n+def getScreenHeight():\n+ \"\"\"A stub implementation of the xbmcgui getScreenHeight() function\"\"\"\n+ return 1080\n+\n+\n+def getScreenWidth():\n+ \"\"\"A stub implementation of the xbmcgui getScreenWidth() function\"\"\"\n+ return 1920\n+\n+\nclass Control:\n\"\"\"A reimplementation of the xbmcgui Control class\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Updated test stub |
106,046 | 22.02.2020 14:52:01 | -3,600 | f88e831aa9743294a7089c26b010cc0f67280f12 | Enabled sync watched status with all profiles | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -965,7 +965,7 @@ msgid \"Install Up Next add-on\"\nmsgstr \"\"\nmsgctxt \"#30235\"\n-msgid \"[WIP] Send/Receive progress and watched status of the videos (works only with the main profile)\"\n+msgid \"[WIP] Synchronize the watched status of the videos with Netflix\"\nmsgstr \"\"\nmsgctxt \"#30236\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/context_menu.py",
"new_path": "resources/lib/kodi/context_menu.py",
"diff": "@@ -102,7 +102,7 @@ def generate_context_menu_items(videoid):\nif videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\n# Add menu to allow change manually the watched status when progress manager is enabled\n- if g.ADDON.getSettingBool('ProgressManager_enabled') and g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ if g.ADDON.getSettingBool('ProgressManager_enabled'):\nitems.insert(0, _ctx_item('change_watched_status', videoid))\nreturn items\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -351,10 +351,7 @@ def _colorize_title(text, color, remove_color=False):\ndef _set_progress_status(list_item, video_data, infos):\n\"\"\"Check and set progress status (watched and resume)\"\"\"\n- if not g.ADDON.getSettingBool('ProgressManager_enabled') or \\\n- not g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n- # Currently due to a unknown problem, it is not possible to communicate MSL data to the right selected\n- # profile other than the owner profile\n+ if not g.ADDON.getSettingBool('ProgressManager_enabled'):\nreturn\nvideo_id = video_data['summary']['id']\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -89,10 +89,9 @@ def play(videoid):\nreturn\nif index_selected == 1:\nresume_position = None\n- elif g.ADDON.getSettingBool('ProgressManager_enabled') and g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n+ elif (g.ADDON.getSettingBool('ProgressManager_enabled') and\n+ videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]):\n# To now we have this limits:\n- # - enabled only if the owner profile is used. Currently due to a unknown problem,\n- # it is not possible to communicate MSL data to the right selected profile\n# - enabled only with items played inside the addon then not Kodi library, need impl. JSON-RPC lib update code\nevent_data = _get_event_data(videoid)\nevent_data['videoid'] = videoid.to_dict()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "@@ -12,7 +12,6 @@ from __future__ import absolute_import, division, unicode_literals\nfrom xbmcgui import Window\nimport resources.lib.common as common\n-from resources.lib.globals import g\nfrom resources.lib.services.msl.msl_utils import EVENT_START, EVENT_ENGAGE, EVENT_STOP, EVENT_KEEP_ALIVE\nfrom .action_manager import PlaybackActionManager\n@@ -32,15 +31,6 @@ class ProgressManager(PlaybackActionManager):\nself.window_cls = Window(10000) # Kodi home window\ndef _initialize(self, data):\n- if not g.LOCAL_DB.get_profile_config('isAccountOwner', False):\n- # Currently due to a unknown problem, it is not possible to communicate MSL data to the right selected\n- # profile other than the owner profile\n- self.enabled = False\n- return\n- videoid = common.VideoId.from_dict(data['videoid'])\n- if videoid.mediatype not in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\n- self.enabled = False\n- return\nif not data['event_data']:\ncommon.warn('ProgressManager: disabled due to no event data')\nself.enabled = False\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Enabled sync watched status with all profiles |
106,046 | 22.02.2020 14:52:47 | -3,600 | 8984455d5a754771b5d2997ff89519603add56b1 | Fixed wrong watched status threshold | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -368,7 +368,7 @@ def _set_progress_status(list_item, video_data, infos):\nif not video_data.get('creditsOffset'):\n# NOTE shakti 'creditsOffset' tag not exists on video type 'movie',\n# then simulate the default Kodi playcount behaviour (playcountminimumpercent)\n- watched_threshold = video_data['runtime'] - (video_data['runtime'] / 100 * 90)\n+ watched_threshold = video_data['runtime'] / 100 * 90\nelse:\nwatched_threshold = video_data['creditsOffset']\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed wrong watched status threshold |
106,046 | 22.02.2020 16:35:55 | -3,600 | 0dd4fd88c15eb55d25eecb8fbe68319c68906a58 | Added required info from react context | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -47,7 +47,12 @@ PAGE_ITEMS_API_URL = {\n# 'ichnaea_log': 'models/serverDefs/data/ICHNAEA_ROOT', can be for XSS attacks?\n'api_endpoint_root_url': 'models/serverDefs/data/API_ROOT',\n'api_endpoint_url': 'models/playerModel/data/config/ui/initParams/apiUrl',\n- 'request_id': 'models/serverDefs/data/requestId'\n+ 'request_id': 'models/serverDefs/data/requestId',\n+ 'asset_core': 'models/playerModel/data/config/core/assets/core',\n+ 'ui_version': 'models/playerModel/data/config/ui/initParams/uiVersion',\n+ 'browser_info_version': 'models/browserInfo/data/version',\n+ 'browser_info_os_name': 'models/browserInfo/data/os/name',\n+ 'browser_info_os_version': 'models/browserInfo/data/os/version',\n}\nPAGE_ITEM_ERROR_CODE = 'models/flow/data/fields/errorCode/value'\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added required info from react context |
106,046 | 22.02.2020 18:22:18 | -3,600 | 218d4d7eb3898f788408eec5d93e2e48f7dbcdc3 | Fixed upgrade fix on install from scratch | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/upgrade_controller.py",
"new_path": "resources/lib/upgrade_controller.py",
"diff": "@@ -86,7 +86,9 @@ def _perform_shared_db_changes(current_version, upgrade_to_version):\n# Init fix\nfrom resources.lib.common import is_minimum_version\nservice_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\n- if current_version is None and not is_minimum_version(service_previous_ver, '0.17.0'):\n+ if service_previous_ver is not None and\\\n+ current_version is None and\\\n+ not is_minimum_version(service_previous_ver, '0.17.0'):\ncurrent_version = '0.1'\n# End fix\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed upgrade fix on install from scratch |
106,046 | 23.02.2020 10:26:35 | -3,600 | cceefa6ab3781bf785ea3134641109dcf207ab36 | Improved watched threshold | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -365,11 +365,10 @@ def _set_progress_status(list_item, video_data, infos):\n# seem not respect really if a video is watched to the end or this tag have other purposes\n# to now, the only way to know if a video is watched is compare the bookmarkPosition with creditsOffset value\n- if not video_data.get('creditsOffset'):\n# NOTE shakti 'creditsOffset' tag not exists on video type 'movie',\n# then simulate the default Kodi playcount behaviour (playcountminimumpercent)\nwatched_threshold = video_data['runtime'] / 100 * 90\n- else:\n+ if video_data.get('creditsOffset') and video_data['creditsOffset'] < watched_threshold:\nwatched_threshold = video_data['creditsOffset']\n# NOTE shakti 'bookmarkPosition' tag when it is not set have -1 value\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Improved watched threshold |
106,046 | 24.02.2020 08:54:33 | -3,600 | 4892d5da6fb37bb7766ca64e91100d633ace991a | Fixed wrong ESN generation on devices without characteristics tv | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -252,19 +252,24 @@ def generate_esn(user_data):\nmodel = subprocess.check_output(\n['/system/bin/getprop',\n'ro.product.model']).decode('utf-8').strip(' \\t\\n\\r')\n- product_characteristics = subprocess.check_output(\n- ['/system/bin/getprop',\n- 'ro.build.characteristics']).decode('utf-8').strip(' \\t\\n\\r')\n+\n+ # This product_characteristics check seem no longer used, some L1 devices not have the 'tv' value\n+ # like Xiaomi Mi Box 3 or SM-T590 devices and is cause of wrong esn generation\n+ # product_characteristics = subprocess.check_output(\n+ # ['/system/bin/getprop',\n+ # 'ro.build.characteristics']).decode('utf-8').strip(' \\t\\n\\r')\n# Property ro.build.characteristics may also contain more then one value\n- has_product_characteristics_tv = any(\n- value.strip(' ') == 'tv' for value in product_characteristics.split(','))\n+ # has_product_characteristics_tv = any(\n+ # value.strip(' ') == 'tv' for value in product_characteristics.split(','))\n+\n# Netflix Ready Device Platform (NRDP)\nnrdp_modelgroup = subprocess.check_output(\n['/system/bin/getprop',\n'ro.nrdp.modelgroup']).decode('utf-8').strip(' \\t\\n\\r')\n- if has_product_characteristics_tv and \\\n- g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1':\n+ # if has_product_characteristics_tv and \\\n+ # g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1':\n+ if g.LOCAL_DB.get_value('drm_security_level', '', table=TABLE_SESSION) == 'L1':\nesn = 'NFANDROID2-PRV-'\nif nrdp_modelgroup:\nesn += nrdp_modelgroup + '-'\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed wrong ESN generation on devices without characteristics tv |
106,046 | 03.02.2020 10:12:38 | -3,600 | dc737a0d27e847c7ff596f5ba55fe14e3f7563eb | Updated test stub impl. | [
{
"change_type": "MODIFY",
"old_path": "test/run.py",
"new_path": "test/run.py",
"diff": "@@ -32,7 +32,8 @@ run_addon.g.init_globals(sys.argv)\nrun_addon.info('Started (Version {})'.format(run_addon.g.VERSION))\nrun_addon.info('URL is {}'.format(run_addon.g.URL))\nif run_addon._check_valid_credentials(): # pylint: disable=protected-access\n- run_addon.check_addon_upgrade()\n- run_addon.g.initial_addon_configuration()\n+ if run_addon.check_addon_upgrade():\n+ from resources.lib.config_wizard import run_addon_configuration # pylint: disable=wrong-import-position\n+ run_addon_configuration()\nrun_addon.route(path.split('/'))\nrun_addon.g.CACHE.commit()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Updated test stub impl. |
106,046 | 23.02.2020 11:11:16 | -3,600 | 01326d8176492b58f61f9edf9d5fa00a00e60224 | Automatically sets hdcp in the manifest | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -97,31 +97,29 @@ class MSLHandler(object):\n# The manifest must be requested once and maintained for its entire duration\nmanifest = g.CACHE.get(cache.CACHE_MANIFESTS, cache_identifier, False)\nif common.is_debug_verbose():\n- common.debug('Manifest for {} with ESN {} obtained from the cache', viewable_id, esn)\n+ common.debug('Manifest for {} obtained from the cache', viewable_id)\n# Save the manifest to disk as reference\ncommon.save_file('manifest.json', json.dumps(manifest).encode('utf-8'))\nreturn manifest\nexcept cache.CacheMiss:\npass\n- common.debug('Requesting manifest for {} with ESN {}', viewable_id, esn)\n- profiles = enabled_profiles()\n- import pprint\n- common.info('Requested profiles:\\n{}', pprint.pformat(profiles, indent=2))\n-\n- ia_addon = xbmcaddon.Addon('inputstream.adaptive')\n- hdcp = ia_addon is not None and ia_addon.getSetting('HDCPOVERRIDE') == 'true'\n- # TODO: Future implementation when available,\n- # request the HDCP version from Kodi through a function\n- # in CryptoSession currently not implemented\n- # so there will be no more need to use the HDCPOVERRIDE = true\n+ isa_addon = xbmcaddon.Addon('inputstream.adaptive')\n+ hdcp_override = isa_addon is not None and isa_addon.getSettingBool('HDCPOVERRIDE')\n+ hdcp_4k_capable = common.is_device_4k_capable() or g.ADDON.getSettingBool('enable_force_hdcp')\nhdcp_version = []\n- if not g.ADDON.getSettingBool('enable_force_hdcp') and hdcp:\n+ if not hdcp_4k_capable and hdcp_override:\nhdcp_version = ['1.4']\n- if g.ADDON.getSettingBool('enable_force_hdcp') and hdcp:\n+ if hdcp_4k_capable and hdcp_override:\nhdcp_version = ['2.2']\n+ common.info('Requesting manifest for {} with ESN {} and HDCP {}', viewable_id, esn, hdcp_version)\n+\n+ profiles = enabled_profiles()\n+ from pprint import pformat\n+ common.info('Requested profiles:\\n{}', pformat(profiles, indent=2))\n+\nparams = {\n'type': 'standard',\n'viewableId': [viewable_id],\n@@ -152,7 +150,7 @@ class MSLHandler(object):\n'type': 'DigitalVideoOutputDescriptor',\n'outputType': 'unknown',\n'supportedHdcpVersions': hdcp_version,\n- 'isHdcpEngaged': hdcp\n+ 'isHdcpEngaged': hdcp_override\n}],\n'preferAssistiveAudio': False\n}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Automatically sets hdcp in the manifest |
106,046 | 29.01.2020 21:02:52 | -3,600 | f4ef8187cbcc7d84d5bab512a2c17b14cd466b84 | Added censure method | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -344,6 +344,13 @@ def remove_html_tags(raw_html):\nreturn text\n+def censure(value, length=3):\n+ \"\"\"Censor part of the string with asterisks\"\"\"\n+ if not value:\n+ return value\n+ return value[:-length] + '*' * length\n+\n+\ndef is_device_4k_capable():\n\"\"\"Check if the device is 4k capable\"\"\"\n# Currently only on android is it possible to use 4K\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added censure method |
106,046 | 23.02.2020 11:13:50 | -3,600 | 970801eac1bf6c8530274daae7183cfb9b867278 | Censure esn in debug output if manual esn is used | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -114,7 +114,10 @@ class MSLHandler(object):\nif hdcp_4k_capable and hdcp_override:\nhdcp_version = ['2.2']\n- common.info('Requesting manifest for {} with ESN {} and HDCP {}', viewable_id, esn, hdcp_version)\n+ common.info('Requesting manifest for {} with ESN {} and HDCP {}',\n+ viewable_id,\n+ common.censure(esn) if g.ADDON.getSetting('esn') else esn,\n+ hdcp_version)\nprofiles = enabled_profiles()\nfrom pprint import pformat\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Censure esn in debug output if manual esn is used |
106,046 | 03.02.2020 10:19:11 | -3,600 | 284a18e8c4d30295bbb25b335deca33de61fb998 | Auto-enable media codec hw on android | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/config_wizard.py",
"new_path": "resources/lib/config_wizard.py",
"diff": "@@ -13,7 +13,7 @@ import inputstreamhelper\nfrom xbmcaddon import Addon\nfrom xbmcgui import getScreenHeight, getScreenWidth\n-from resources.lib.common import debug, get_system_platform, is_device_4k_capable, get_local_string\n+from resources.lib.common import debug, error, get_system_platform, is_device_4k_capable, get_local_string, json_rpc\nfrom resources.lib.globals import g\nfrom resources.lib.kodi.ui import show_ok_dialog\n@@ -29,6 +29,7 @@ def run_addon_configuration(show_end_msg=False):\nis_4k_capable = is_device_4k_capable()\n_set_profiles(system, is_4k_capable)\n+ _set_kodi_settings(system)\n_set_isa_addon_settings(is_4k_capable, system == 'android')\n# This settings for now used only with android devices and it should remain disabled (keep it for test),\n@@ -85,3 +86,14 @@ def _set_profiles(system, is_4k_capable):\ndef _ask_dolby_vision():\n# Todo: ask to user if want to enable dolby vision\npass\n+\n+\n+def _set_kodi_settings(system):\n+ \"\"\"Method for self-configuring Kodi settings\"\"\"\n+ if system == 'android':\n+ # Media Codec hardware acceleration is mandatory, otherwise only the audio stream is played\n+ try:\n+ json_rpc('Settings.SetSettingValue', {'setting': 'videoplayer.usemediacodecsurface', 'value': True})\n+ json_rpc('Settings.SetSettingValue', {'setting': 'videoplayer.usemediacodec', 'value': True})\n+ except IOError as exc:\n+ error('Changing Kodi settings caused the following error: {}', exc)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Auto-enable media codec hw on android |
106,046 | 03.02.2020 10:20:48 | -3,600 | 57cd8808538c20932911e7de6a0792c1f866f47e | Auto-enable UpNext if it is installed | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/config_wizard.py",
"new_path": "resources/lib/config_wizard.py",
"diff": "from __future__ import absolute_import, division, unicode_literals\nimport inputstreamhelper\n+from xbmc import getCondVisibility\nfrom xbmcaddon import Addon\nfrom xbmcgui import getScreenHeight, getScreenWidth\n@@ -36,6 +37,9 @@ def run_addon_configuration(show_end_msg=False):\n# in the future it may be useful for other platforms or it may be removed\ng.ADDON.setSettingBool('enable_force_hdcp', False)\n+ # Enable UpNext if it is installed and enabled\n+ g.ADDON.setSettingBool('UpNextNotifier_enabled', getCondVisibility('System.AddonIsEnabled(service.upnext)'))\n+\ng.settings_monitor_suspend(False)\nif show_end_msg:\nshow_ok_dialog(get_local_string(30154), get_local_string(30157))\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Auto-enable UpNext if it is installed |
106,046 | 03.02.2020 11:15:06 | -3,600 | 8b35e900178e6cb22c691f4ca395918c6e5cf876 | Up Next settings moved separately | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -975,3 +975,8 @@ msgstr \"\"\nmsgctxt \"#30237\"\nmsgid \"Marked as watched|Marked as unwatched|Restored Netflix watched status\"\nmsgstr \"\"\n+\n+msgctxt \"#30238\"\n+msgid \"Up Next notifications (watch next video)\"\n+msgstr \"\"\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"SectionSkipper_enabled\" type=\"bool\" label=\"30075\" default=\"true\"/>\n<setting id=\"auto_skip_credits\" type=\"bool\" label=\"30079\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"pause_on_skip\" type=\"bool\" label=\"30080\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n- <setting id=\"UpNextNotifier_enabled\" type=\"bool\" label=\"30129\" default=\"false\"/>\n- <setting id=\"upnext_install\" type=\"action\" label=\"30234\" action=\"InstallAddon(service.upnext)\" enable=\"eq(-1,true)\" visible=\"!System.HasAddon(service.upnext)\" subsetting=\"true\" option=\"close\"/>\n- <setting id=\"upnext_settings\" type=\"action\" label=\"30178\" action=\"Addon.OpenSettings(service.upnext)\" enable=\"eq(-2,true)\" visible=\"System.HasAddon(service.upnext)\" subsetting=\"true\" option=\"close\"/>\n<setting id=\"ResumeManager_enabled\" type=\"bool\" label=\"30176\" default=\"true\"/>\n<setting id=\"ResumeManager_dialog\" type=\"bool\" label=\"30177\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"forced_subtitle_workaround\" type=\"bool\" label=\"30181\" default=\"true\" />\n<setting id=\"ProgressManager_enabled\" type=\"bool\" label=\"30235\" default=\"false\"/>\n+ <setting label=\"30238\" type=\"lsep\"/>\n+ <setting id=\"upnext_install\" type=\"action\" label=\"30234\" action=\"InstallAddon(service.upnext)\" visible=\"!System.HasAddon(service.upnext)\" option=\"close\"/>\n+ <setting id=\"UpNextNotifier_enabled\" type=\"bool\" label=\"30129\" default=\"false\" enable=\"System.AddonIsEnabled(service.upnext)\"/>\n+ <setting id=\"upnext_settings\" type=\"action\" label=\"30178\" action=\"Addon.OpenSettings(service.upnext)\" visible=\"System.HasAddon(service.upnext)\" option=\"close\"/>\n</category>\n<category label=\"30023\"><!--Expert-->\n<setting id=\"configuration_wizard\" type=\"action\" label=\"30158\" action=\"RunPlugin(plugin://plugin.video.netflix/action/configuration_wizard/)\" option=\"close\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Up Next settings moved separately |
106,046 | 23.02.2020 11:29:13 | -3,600 | dda1ffa53c84ef42131a3b1b46c8689024009323 | Replaced deprecated xbox infolabel with uwp | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -115,7 +115,7 @@ def get_user_agent(enable_android_mediaflag_fix=False):\nif system in ['osx', 'ios', 'tvos']:\nreturn base.replace('%PL%', '(Macintosh; Intel Mac OS X 10_14_6)')\n- if system in ['windows', 'xbox']:\n+ if system in ['windows', 'uwp']:\nreturn base.replace('%PL%', '(Windows NT 10; Win64; x64)')\n# ARM based Linux\nif get_machine().startswith('arm'):\n@@ -394,8 +394,8 @@ def get_system_platform():\nplatform = \"linux\"\nelif xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android'):\nplatform = \"android\"\n- elif xbmc.getCondVisibility('system.platform.xbox'):\n- platform = \"xbox\"\n+ elif xbmc.getCondVisibility('system.platform.uwp'):\n+ platform = \"uwp\"\nelif xbmc.getCondVisibility('system.platform.windows'):\nplatform = \"windows\"\nelif xbmc.getCondVisibility('system.platform.osx'):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/uuid_device.py",
"new_path": "resources/lib/common/uuid_device.py",
"diff": "@@ -48,7 +48,7 @@ def _get_system_uuid():\nimport uuid\nuuid_value = None\nsystem = get_system_platform()\n- if system in ['windows', 'xbox']:\n+ if system in ['windows', 'uwp']:\nuuid_value = _get_windows_uuid()\nelif system == 'android':\nuuid_value = _get_android_uuid()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/config_wizard.py",
"new_path": "resources/lib/config_wizard.py",
"diff": "@@ -66,7 +66,7 @@ def _set_profiles(system, is_4k_capable):\nenable_hevc_profiles = False\nif system in ['osx', 'ios']:\nenable_hevc_profiles = True\n- elif system in ['windows', 'xbox']:\n+ elif system in ['windows', 'uwp']:\nenable_vp9_profiles = True\nelif system == 'android':\n# By default we do not enable VP9 because on some devices do not fully support it\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Replaced deprecated xbox infolabel with uwp |
106,046 | 23.02.2020 14:22:35 | -3,600 | da137e44b2f8ec97b6fce010f394784bb64563bc | Save the platform value | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -389,8 +389,12 @@ def get_machine():\ndef get_system_platform():\n+ if not hasattr(get_system_platform, 'cached'):\nplatform = \"unknown\"\nif xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):\n+ if xbmc.getCondVisibility('system.platform.linux.raspberrypi'):\n+ platform = \"linux raspberrypi\"\n+ else:\nplatform = \"linux\"\nelif xbmc.getCondVisibility('system.platform.linux') and xbmc.getCondVisibility('system.platform.android'):\nplatform = \"android\"\n@@ -404,7 +408,8 @@ def get_system_platform():\nplatform = \"ios\"\nelif xbmc.getCondVisibility('system.platform.tvos'): # Supported only on Kodi 19.x\nplatform = \"tvos\"\n- return platform\n+ get_system_platform.cached = platform\n+ return get_system_platform.cached\nclass GetKodiVersion(object):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Save the platform value |
106,046 | 25.02.2020 15:01:40 | -3,600 | 18d201cb9bb004a62815cae1c6ce8405d63b0c6c | Disable omx player on raspberry | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -94,6 +94,12 @@ def play(videoid):\nevent_data['videoid'] = videoid.to_dict()\nevent_data['is_played_by_library'] = g.IS_SKIN_CALL\n+ if 'raspberrypi' in common.get_system_platform():\n+ # OMX Player is not compatible with netflix video streams\n+ value = common.json_rpc('Settings.GetSettingValue', {'setting': 'videoplayer.useomxplayer'})\n+ if value.get('value'):\n+ common.json_rpc('Settings.SetSettingValue', {'setting': 'videoplayer.useomxplayer', 'value': False})\n+\nxbmcplugin.setResolvedUrl(handle=g.PLUGIN_HANDLE, succeeded=True, listitem=list_item)\nupnext_info = get_upnext_info(videoid, (infos, art), metadata) if is_up_next_enabled else None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Disable omx player on raspberry |
106,046 | 28.02.2020 09:45:36 | -3,600 | e2e9e1a042ad27b3581ba7fc947b85483b957b47 | Try handle invalid membership status: anonymous
I am not sure there is any relation to profiles cookies | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/exceptions.py",
"new_path": "resources/lib/api/exceptions.py",
"diff": "@@ -39,6 +39,10 @@ class InvalidMembershipStatusError(WebsiteParsingError):\n\"\"\"The user logging in does not have a valid subscription\"\"\"\n+class InvalidMembershipStatusAnonymous(WebsiteParsingError):\n+ \"\"\"The user logging failed because of Membership Status Anonymous\"\"\"\n+\n+\nclass LoginFailedError(Exception):\n\"\"\"The login attempt has failed\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/website.py",
"new_path": "resources/lib/api/website.py",
"diff": "@@ -19,7 +19,7 @@ from resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nfrom .paths import resolve_refs\nfrom .exceptions import (InvalidProfilesError, InvalidAuthURLError, InvalidMembershipStatusError,\n- WebsiteParsingError, LoginValidateError)\n+ WebsiteParsingError, LoginValidateError, InvalidMembershipStatusAnonymous)\ntry: # Python 2\nunicode\n@@ -74,6 +74,10 @@ def extract_session_data(content, validate=False):\nvalidate_login(react_context)\nuser_data = extract_userdata(react_context)\n+ if user_data.get('membershipStatus') == 'ANONYMOUS':\n+ # I don't know the real cause of this situation, maybe it is because of the expired cookies in the profiles,\n+ # but it is mandatory to login again\n+ raise InvalidMembershipStatusAnonymous\nif user_data.get('membershipStatus') != 'CURRENT_MEMBER':\n# When NEVER_MEMBER it is possible that the account has not been confirmed or renewed\ncommon.error('Can not login, the Membership status is {}',\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_requests.py",
"new_path": "resources/lib/services/nfsession/nfsession_requests.py",
"diff": "@@ -20,7 +20,7 @@ from resources.lib.globals import g\nfrom resources.lib.services.nfsession.nfsession_base import NFSessionBase, needs_login\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.api.exceptions import (APIError, WebsiteParsingError,\n- InvalidMembershipStatusError)\n+ InvalidMembershipStatusError, InvalidMembershipStatusAnonymous)\nBASE_URL = 'https://www.netflix.com'\n\"\"\"str: Secure Netflix url\"\"\"\n@@ -118,12 +118,12 @@ class NFSessionRequests(NFSessionBase):\nreturn True\nexcept InvalidMembershipStatusError:\nraise\n- except WebsiteParsingError:\n- # it is possible that cookies may not work anymore,\n- # it should be due to updates in the website,\n- # this can happen when opening the addon while executing update_profiles_data\n+ except (WebsiteParsingError, InvalidMembershipStatusAnonymous) as exc:\n+ # Possible known causes:\n+ # -Cookies may not work anymore most likely due to updates in the website\n+ # -Expired cookie profiles? might cause InvalidMembershipStatusAnonymous (i am not really sure)\nimport traceback\n- common.warn('Failed to refresh session data, login expired (WebsiteParsingError)')\n+ common.warn('Failed to refresh session data, login can be expired ({})', type(exc).__name__)\ncommon.debug(traceback.format_exc())\nself.session.cookies.clear()\nreturn self._login()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Try handle invalid membership status: anonymous
I am not sure there is any relation to profiles cookies |
106,046 | 28.02.2020 11:36:19 | -3,600 | f98a42155a364aaf2052fc86e3a61c3636dc2151 | Fixed msl error "No entity association record found for the user" | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/ipc.py",
"new_path": "resources/lib/common/ipc.py",
"diff": "@@ -37,6 +37,7 @@ class Signals(object): # pylint: disable=no-init\nUPNEXT_ADDON_INIT = 'upnext_data'\nINVALIDATE_SERVICE_CACHE = 'invalidate_service_cache'\nQUEUE_VIDEO_EVENT = 'queue_video_event'\n+ CLEAR_USER_ID_TOKENS = 'clean_user_id_tokens'\ndef register_slot(callback, signal=None, source_id=None):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -57,6 +57,9 @@ class MSLHandler(object):\ncommon.register_slot(\nsignal=common.Signals.RELEASE_LICENSE,\ncallback=self.release_license)\n+ common.register_slot(\n+ signal=common.Signals.CLEAR_USER_ID_TOKENS,\n+ callback=self.clear_user_id_tokens)\n@display_error_info\[email protected]_execution(immediate=True)\n@@ -239,6 +242,10 @@ class MSLHandler(object):\ng.get_esn())\ncommon.debug('License release response: {}', response)\n+ def clear_user_id_tokens(self, data=None): # pylint: disable=unused-argument\n+ \"\"\"Clear all user id tokens\"\"\"\n+ self.msl_requests.crypto.clear_user_id_tokens()\n+\[email protected]_execution(immediate=True)\ndef __tranform_to_dash(self, manifest):\nself.last_license_url = manifest['links']['license']['href']\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_requests.py",
"new_path": "resources/lib/services/nfsession/nfsession_requests.py",
"diff": "@@ -126,6 +126,9 @@ class NFSessionRequests(NFSessionBase):\ncommon.warn('Failed to refresh session data, login can be expired ({})', type(exc).__name__)\ncommon.debug(traceback.format_exc())\nself.session.cookies.clear()\n+ if isinstance(exc, InvalidMembershipStatusAnonymous):\n+ # This prevent the MSL error: No entity association record found for the user\n+ common.send_signal(signal=common.Signals.CLEAR_USER_ID_TOKENS)\nreturn self._login()\nexcept requests.exceptions.RequestException:\nimport traceback\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed msl error "No entity association record found for the user" |
106,046 | 24.02.2020 11:47:52 | -3,600 | 694edce1474852d1c722760fcf99cf64d7cd63b3 | New changes from netflix | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession.py",
"new_path": "resources/lib/services/nfsession/nfsession.py",
"diff": "@@ -16,6 +16,7 @@ import requests\nimport resources.lib.common as common\nimport resources.lib.api.paths as apipaths\nimport resources.lib.api.website as website\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom resources.lib.services.nfsession.nfsession_access import NFSessionAccess\nfrom resources.lib.services.nfsession.nfsession_base import needs_login\n@@ -212,7 +213,12 @@ class NetflixSession(NFSessionAccess):\n'drmSystem': 'widevine',\n# 'falcor_server': '0.1.0',\n'withSize': 'false',\n- 'materialize': 'false'\n+ 'materialize': 'false',\n+ 'routeAPIRequestsThroughFTL': 'false',\n+ 'isVolatileBillboardsEnabled': 'true',\n+ 'isWatchlistEnabled': 'false',\n+ 'original_path': '/shakti/{}/pathEvaluator'.format(\n+ g.LOCAL_DB.get_value('build_identifier', '', TABLE_SESSION))\n}\ndata = 'path=' + '&path='.join(json.dumps(path) for path in paths)\ndata += '&authURL=' + self.auth_url\n@@ -251,7 +257,9 @@ class NetflixSession(NFSessionAccess):\n'materialize': 'true',\n'routeAPIRequestsThroughFTL': 'false',\n'isVolatileBillboardsEnabled': 'true',\n- 'isWatchlistEnabled': 'false'\n+ 'isWatchlistEnabled': 'false',\n+ 'original_path': '/shakti/{}/pathEvaluator'.format(\n+ g.LOCAL_DB.get_value('build_identifier', '', TABLE_SESSION))\n}\ndata = 'callPath=' + '&callPath='.join(json.dumps(callpath) for callpath in callpaths)\nif params:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_base.py",
"new_path": "resources/lib/services/nfsession/nfsession_base.py",
"diff": "@@ -80,8 +80,10 @@ class NFSessionBase(object):\ndef set_session_header_data(self):\ntry:\n# When the addon is installed from scratch there is no profiles in the database\n- self.session.headers.update(\n- {'x-netflix.request.client.user.guid': g.LOCAL_DB.get_active_profile_guid()})\n+ self.session.headers.update({\n+ 'x-netflix.nq.stack': 'prod',\n+ 'x-netflix.request.client.user.guid': g.LOCAL_DB.get_active_profile_guid()\n+ })\nexcept ProfilesMissing:\npass\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | New changes from netflix |
106,046 | 24.02.2020 11:49:28 | -3,600 | 4e9b962499ccc9d690239ffc083c9ee3845b95d8 | Implemented update bookmark position
This solves the problem of progress watched on android | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -102,13 +102,9 @@ def root_lists():\nART_PARTIAL_PATHS)))\n-def update_lolomo_context(context_name, video_id=None):\n+def update_lolomo_context(context_name):\n\"\"\"Update the lolomo list by context\"\"\"\n# Should update the context list but it doesn't, what is missing?\n- # The remaining requests made on the website that are missing here are of logging type,\n- # it seems strange that they use log data to finish the operations are almost impossible to reproduce here:\n- # pbo_logblobs /logblob\n- # personalization/cl2\nlolomo_data = common.make_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\n# Note: lolomo root seem differs according to the profile in use\n@@ -140,12 +136,24 @@ def update_lolomo_context(context_name, video_id=None):\nresponse = common.make_http_call('callpath_request', callargs)\ncommon.debug('refreshListByContext response: {}', response)\n+\n+def update_videoid_bookmark(video_id):\n+ \"\"\"Update the videoid bookmark position\"\"\"\n+ # You can check if this function works through the official android app\n+ # by checking if the status bar watched of the video will be updated\ncallargs = {\n'callpaths': [['refreshVideoCurrentPositions']],\n- 'params': ['[' + video_id + ']', ''],\n+ 'params': ['[' + video_id + ']', '[]'],\n}\n+ try:\nresponse = common.make_http_call('callpath_request', callargs)\ncommon.debug('refreshVideoCurrentPositions response: {}', response)\n+ except Exception: # pylint: disable=broad-except\n+ # I do not know the reason yet, but sometimes continues to return error 401,\n+ # making it impossible to update the bookmark position\n+ ui.show_notification(title=common.get_local_string(30105),\n+ msg='An error prevented the update the status watched on netflix',\n+ time=10000)\[email protected]_output(cache.CACHE_COMMON, identify_from_kwarg_name='list_type')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -20,7 +20,7 @@ except ImportError: # Python 3\nimport xbmc\n-# import resources.lib.api.shakti as api\n+import resources.lib.api.shakti as api\nimport resources.lib.cache as cache\nfrom resources.lib import common\nfrom resources.lib.database.db_utils import TABLE_SESSION\n@@ -124,7 +124,8 @@ class EventsHandler(threading.Thread):\ncommon.error('EVENT [{}] - The request has failed: {}', event, exc)\nif event.event_type == EVENT_STOP:\nself.clear_queue()\n- # api.update_lolomo_context('continueWatching', video_id=event.get_video_id())\n+ # api.update_lolomo_context('continueWatching')\n+ api.update_videoid_bookmark(event.get_video_id())\nif not event.is_response_success():\n# The event request is unsuccessful then there is some problem,\n# no longer make any future requests from this event id\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implemented update bookmark position
This solves the problem of progress watched on android |
106,046 | 24.02.2020 17:35:46 | -3,600 | a4334cd968369828c30663a13017905adbd955a6 | Some info updated | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -11,7 +11,6 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\nfrom future.utils import iteritems\n-from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.cache as cache\n@@ -104,19 +103,24 @@ def root_lists():\ndef update_lolomo_context(context_name):\n\"\"\"Update the lolomo list by context\"\"\"\n- # Should update the context list but it doesn't, what is missing?\n-\n- lolomo_data = common.make_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\n- # Note: lolomo root seem differs according to the profile in use\n+ lolomo_data = common.make_http_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\n+ # Note: every profile has its root lolomo (that are visible in the lhpuuidh-browse profiles cookies)\nlolomo_root = lolomo_data['lolomo'][1]\ncontext_index = lolomo_data['lolomos'][lolomo_root][context_name][2]\ncontext_id = lolomo_data['lolomos'][lolomo_root][context_index][1]\npath = [['lolomos', lolomo_root, 'refreshListByContext']]\n+ # The fourth parameter is like a request-id, but it doesn't seem to match to\n+ # serverDefs/date/requestId of reactContext (g.LOCAL_DB.get_value('request_id', table=TABLE_SESSION))\n+ # nor to request_id of the video event request\n+ # has a kind of relationship with renoMessageId suspect with the logblob but i'm not sure because my debug crashed,\n+ # and i am no longer able to trace the source.\n+ # I noticed also that this request can also be made with the fourth parameter empty,\n+ # but it still doesn't update the continueWatching list of lolomo, that is strange because of no error\nparams = [common.enclose_quotes(context_id),\ncontext_index,\ncommon.enclose_quotes(context_name),\n- common.enclose_quotes(g.LOCAL_DB.get_value('request_id', table=TABLE_SESSION))]\n+ '']\n# path_suffixs = [\n# [['trackIds', 'context', 'length', 'genreId', 'videoId', 'displayName', 'isTallRow', 'isShowAsARow',\n# 'impressionToken', 'showAsARow', 'id', 'requestId']],\n@@ -133,8 +137,15 @@ def update_lolomo_context(context_name):\n'params': params,\n# 'path_suffixs': path_suffixs\n}\n+ try:\nresponse = common.make_http_call('callpath_request', callargs)\ncommon.debug('refreshListByContext response: {}', response)\n+ except Exception: # pylint: disable=broad-except\n+ # I do not know the reason yet, but sometimes continues to return error 401,\n+ # making it impossible to update the bookmark position\n+ ui.show_notification(title=common.get_local_string(30105),\n+ msg='An error prevented the update the lolomo context on netflix',\n+ time=10000)\ndef update_videoid_bookmark(video_id):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Some info updated |
106,046 | 25.02.2020 13:33:09 | -3,600 | b249b3545559d54dbbc40e54c1149fd4b941a128 | Removed activate profile
seem not needed if there is the switch_profile call | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -75,7 +75,7 @@ def update_profiles_data():\ndef activate_profile(profile_id):\n\"\"\"Activate the profile with the given ID\"\"\"\n- if common.make_call('activate_profile', profile_id):\n+ common.make_call('activate_profile', profile_id)\ng.CACHE.invalidate()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession.py",
"new_path": "resources/lib/services/nfsession/nfsession.py",
"diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import time\nimport json\nimport requests\n@@ -79,25 +78,21 @@ class NetflixSession(NFSessionAccess):\[email protected]_execution(immediate=True)\ndef activate_profile(self, guid):\n\"\"\"Set the profile identified by guid as active\"\"\"\n- common.info('Activating profile {}', guid)\n- if guid == g.LOCAL_DB.get_active_profile_guid():\n- common.debug('Profile {} is already active', guid)\n- return False\n- # When switch profile is performed the authURL change\n+ common.debug('Switching to profile {}', guid)\nresponse = self._get('switch_profile', params={'tkn': guid})\nreact_context = website.extract_json(response, 'reactContext')\nself.auth_url = website.extract_api_data(react_context)['auth_url']\n- self._get(component='activate_profile',\n- req_type='api',\n- params={'switchProfileGuid': guid,\n- '_': int(time.time()),\n- 'authURL': self.auth_url})\n+ # if guid != g.LOCAL_DB.get_active_profile_guid():\n+ # common.info('Activating profile {}', guid)\n+ # self._get(component='activate_profile',\n+ # req_type='api',\n+ # params={'switchProfileGuid': guid,\n+ # '_': int(time.time()),\n+ # 'authURL': self.auth_url})\ng.LOCAL_DB.switch_active_profile(guid)\nself.update_session_data()\n- common.debug('Successfully activated profile {}', guid)\n- return True\[email protected]_return_call\n@needs_login\n@@ -114,11 +109,11 @@ class NetflixSession(NFSessionAccess):\n# Current profile active\ncurrent_profile_guid = g.LOCAL_DB.get_active_profile_guid()\n# Switch profile (only if necessary) in order to get My List videos\n- is_profile_switched = self.activate_profile(mylist_profile_guid)\n+ self.activate_profile(mylist_profile_guid)\n# Get the My List data\npath_response = self._perpetual_path_request(paths, length_params, perpetual_range_start,\nno_limit_req)\n- if is_profile_switched:\n+ if mylist_profile_guid != current_profile_guid:\n# Reactive again the previous profile\nself.activate_profile(current_profile_guid)\nreturn path_response\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Removed activate profile
seem not needed if there is the switch_profile call |
106,046 | 25.02.2020 08:51:14 | -3,600 | ea1dc963ba1dc0ecbc987b5e6d7dff4f197dbe28 | Save resume time also on skip | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/progress_manager.py",
"new_path": "resources/lib/services/playback/progress_manager.py",
"diff": "@@ -85,6 +85,7 @@ class ProgressManager(PlaybackActionManager):\nreturn\nself.tick_elapsed = 0\n_send_event(EVENT_ENGAGE, self.event_data, player_state)\n+ self._save_resume_time(player_state['elapsed_seconds'])\ndef _on_playback_stopped(self):\nif not self.is_event_start_sent or self.lock_events:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Save resume time also on skip |
106,046 | 25.02.2020 09:21:00 | -3,600 | 2964a9a69d5e7dd3d3024cc6cd3379dc6a584ebb | Allow future requests to be sent anyway | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -126,10 +126,11 @@ class EventsHandler(threading.Thread):\nself.clear_queue()\n# api.update_lolomo_context('continueWatching')\napi.update_videoid_bookmark(event.get_video_id())\n- if not event.is_response_success():\n+ # Below commented lines: let future requests continue to be sent, unstable connections like wi-fi cause problems\n+ # if not event.is_response_success():\n# The event request is unsuccessful then there is some problem,\n# no longer make any future requests from this event id\n- return False\n+ # return False\nreturn True\ndef callback_event_video_queue(self, data=None):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Allow future requests to be sent anyway |
106,046 | 25.02.2020 10:07:02 | -3,600 | c2384cb3e1601ff004bab397277ac0e75c9f013d | Do not save call data with supplemental | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -305,7 +305,7 @@ def episodes(videoid, videoid_value, perpetual_range_start=None): # pylint: dis\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_SUPPLEMENTAL, save_call_data=True)\[email protected]_output(cache.CACHE_SUPPLEMENTAL)\ndef supplemental_video_list(videoid, supplemental_type):\n\"\"\"Retrieve a supplemental video list\"\"\"\nif videoid.mediatype != common.VideoId.SHOW and videoid.mediatype != common.VideoId.MOVIE:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Do not save call data with supplemental |
106,046 | 25.02.2020 13:28:20 | -3,600 | b3cccb7c2522eeae636bf70dc0980b6aa93ba07f | Fixed problem with resumetime and ctx menu Change watched status | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -358,6 +358,7 @@ def _set_progress_status(list_item, video_data, infos):\n# Check from db if user has manually changed the watched status\nprofile_guid = g.LOCAL_DB.get_active_profile_guid()\noverride_is_watched = g.SHARED_DB.get_watched_status(profile_guid, video_id, None, bool)\n+ resume_time = 0\nif override_is_watched is None:\n# NOTE shakti 'watched' tag value:\n@@ -374,10 +375,11 @@ def _set_progress_status(list_item, video_data, infos):\n# NOTE shakti 'bookmarkPosition' tag when it is not set have -1 value\nplaycount = '1' if video_data['bookmarkPosition'] >= watched_threshold else '0'\nif playcount == '0' and video_data['bookmarkPosition'] > 0:\n- list_item.setProperty('ResumeTime', str(video_data['bookmarkPosition']))\n- list_item.setProperty('TotalTime', str(video_data['runtime']))\n+ resume_time = video_data['bookmarkPosition']\nelse:\nplaycount = '1' if override_is_watched else '0'\n# We have to set playcount with setInfo(), because the setProperty('PlayCount', ) have a bug\n# when a item is already watched and you force to set again watched, the override do not work\ninfos['PlayCount'] = playcount\n+ list_item.setProperty('TotalTime', str(video_data['runtime']))\n+ list_item.setProperty('ResumeTime', str(resume_time))\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed problem with resumetime and ctx menu Change watched status |
106,046 | 25.02.2020 14:15:57 | -3,600 | f4273f452f2659ba281ac51c3e590bf22548060f | Improved action change watched status | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/actions.py",
"new_path": "resources/lib/navigation/actions.py",
"diff": "@@ -154,27 +154,24 @@ class AddonActionExecutor(object):\n# Open root page\nxbmc.executebuiltin('Container.Update({},replace)'.format(url)) # replace=reset history\n- def change_watched_status(self, pathitems=None): # pylint: disable=unused-argument\n- from os import path\n- videoid = path.basename(path.normpath(xbmc.getInfoLabel('ListItem.Path')))\n- if videoid.isdigit():\n+ @common.inject_video_id(path_offset=1)\n+ def change_watched_status(self, videoid):\n+ \"\"\"Change the watched status locally\"\"\"\n# Todo: how get resumetime/playcount of selected item for calculate current watched status?\nprofile_guid = g.LOCAL_DB.get_active_profile_guid()\n- current_value = g.SHARED_DB.get_watched_status(profile_guid, videoid, None, bool)\n+ current_value = g.SHARED_DB.get_watched_status(profile_guid, videoid.value, None, bool)\nif current_value:\ntxt_index = 1\n- g.SHARED_DB.set_watched_status(profile_guid, videoid, False)\n+ g.SHARED_DB.set_watched_status(profile_guid, videoid.value, False)\nelif current_value is not None and not current_value:\ntxt_index = 2\n- g.SHARED_DB.delete_watched_status(profile_guid, videoid)\n+ g.SHARED_DB.delete_watched_status(profile_guid, videoid.value)\nelse:\ntxt_index = 0\n- g.SHARED_DB.set_watched_status(profile_guid, videoid, True)\n+ g.SHARED_DB.set_watched_status(profile_guid, videoid.value, True)\nui.show_notification(common.get_local_string(30237).split('|')[txt_index])\ncommon.refresh_container()\n- else:\n- common.error('No video id found in the current path: {}', path)\ndef configuration_wizard(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Run the add-on configuration wizard\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Improved action change watched status |
106,046 | 25.02.2020 14:10:35 | -3,600 | 06081f6883251ed284e158b55f8af094c8fdff6c | Get xid from previous data if exists, avoid possible mixing | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -202,7 +202,7 @@ class EventsHandler(threading.Thread):\nparams = {\n'event': event_type,\n- 'xid': g.LOCAL_DB.get_value('xid', table=TABLE_SESSION),\n+ 'xid': previous_data.get('xid', g.LOCAL_DB.get_value('xid', table=TABLE_SESSION)),\n'position': player_state['elapsed_seconds'] * 1000, # Video time elapsed\n'clientTime': timestamp,\n'sessionStartTime': previous_data.get('sessionStartTime', timestamp),\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Get xid from previous data if exists, avoid possible mixing |
106,046 | 27.02.2020 15:29:05 | -3,600 | df835e3683ea95e0bbb0cca4f0ab8527959a029d | Fixed problem with "Play from beginning" ctx menu | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -53,7 +53,7 @@ def get_info(videoid, item, raw_data):\nreturn infos, quality_infos\n-def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False):\n+def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False, skip_set_progress_status=False):\n\"\"\"Add infolabels to the list_item. The passed in list_item is modified\nin place and the infolabels are returned.\"\"\"\ninfos, quality_infos = get_info(videoid, item, raw_data)\n@@ -65,6 +65,7 @@ def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False)\nlist_item.setProperty('isFolder', 'false')\nlist_item.setProperty('IsPlayable', 'true')\n# Set the resume and watched status to the list item\n+ if not skip_set_progress_status:\n_set_progress_status(list_item, item, infos_copy)\nelse:\nlist_item.setProperty('isFolder', 'true')\n@@ -111,7 +112,7 @@ def get_info_for_playback(videoid, skip_add_from_library):\[email protected]_execution(immediate=False)\n-def add_info_for_playback(videoid, list_item, skip_add_from_library):\n+def add_info_for_playback(videoid, list_item, skip_add_from_library, skip_set_progress_status=False):\n\"\"\"Retrieve infolabels and art info and add them to the list_item\"\"\"\n# By getting the info from the library you can not get the length of video required for Up Next addon\n# waiting for a suitable solution we avoid this method by using skip_add_from_library\n@@ -120,7 +121,7 @@ def add_info_for_playback(videoid, list_item, skip_add_from_library):\nreturn add_info_from_library(videoid, list_item)\nexcept library.ItemNotFound:\ncommon.debug('Can not get infolabels from the library, submit a request to netflix')\n- return add_info_from_netflix(videoid, list_item)\n+ return add_info_from_netflix(videoid, list_item, skip_set_progress_status)\ndef parse_info(videoid, item, raw_data):\n@@ -266,16 +267,17 @@ def get_info_from_netflix(videoid):\nreturn infos, art\n-def add_info_from_netflix(videoid, list_item):\n+def add_info_from_netflix(videoid, list_item, skip_set_progress_status):\n\"\"\"Apply infolabels with info from Netflix API\"\"\"\ntry:\n- infos = add_info(videoid, list_item, None, None)\n+ infos = add_info(videoid, list_item, None, None, skip_set_progress_status=skip_set_progress_status)\nart = add_art(videoid, list_item, None)\ncommon.debug('Got infolabels and art from cache')\nexcept (AttributeError, TypeError):\ncommon.debug('Infolabels or art were not in cache, retrieving from API')\napi_data = api.single_info(videoid)\n- infos = add_info(videoid, list_item, api_data['videos'][videoid.value], api_data)\n+ infos = add_info(videoid, list_item, api_data['videos'][videoid.value], api_data,\n+ skip_set_progress_status=skip_set_progress_status)\nart = add_art(videoid, list_item, api_data['videos'][videoid.value])\nreturn infos, art\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -70,7 +70,7 @@ def play(videoid):\nreturn\nlist_item = get_inputstream_listitem(videoid)\n- infos, art = infolabels.add_info_for_playback(videoid, list_item, is_up_next_enabled)\n+ infos, art = infolabels.add_info_for_playback(videoid, list_item, is_up_next_enabled, skip_set_progress_status=True)\nresume_position = {}\nevent_data = {}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed problem with "Play from beginning" ctx menu |
106,046 | 28.02.2020 13:19:51 | -3,600 | a803cf663cafbc20f1c43d3323f9be1ce14fc14b | Some fixes for refreshListByContext request
Now you can get a good response from refreshListByContext request
but the problem is not yet resolved the continue watching list is not updated | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\nfrom future.utils import iteritems\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.cache as cache\n@@ -76,6 +77,8 @@ def update_profiles_data():\ndef activate_profile(profile_id):\n\"\"\"Activate the profile with the given ID\"\"\"\ncommon.make_call('activate_profile', profile_id)\n+ if g.ADDON.getSettingBool('ProgressManager_enabled'):\n+ save_current_lolomo_data('continueWatching')\ng.CACHE.invalidate()\n@@ -101,13 +104,23 @@ def root_lists():\nART_PARTIAL_PATHS)))\n-def update_lolomo_context(context_name):\n- \"\"\"Update the lolomo list by context\"\"\"\n- lolomo_data = common.make_http_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\n- # Note: every profile has its root lolomo (that are visible in the lhpuuidh-browse profiles cookies)\n+def save_current_lolomo_data(context_name):\n+ \"\"\"Save the current lolomo data of the current selected profile\"\"\"\n+ # Note: every profile has its root lolomo (that are also visible in the lhpuuidh-browse profiles cookies)\n+ lolomo_data = common.make_call('path_request', [[\"lolomo\", [context_name], ['context', 'id', 'index']]])\nlolomo_root = lolomo_data['lolomo'][1]\ncontext_index = lolomo_data['lolomos'][lolomo_root][context_name][2]\ncontext_id = lolomo_data['lolomos'][lolomo_root][context_index][1]\n+ g.LOCAL_DB.set_value('lolomo_root_id', lolomo_root, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('lolomo_continue_watching_index', context_index, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('lolomo_continue_watching_id', context_id, TABLE_SESSION)\n+\n+\n+def update_lolomo_context(context_name):\n+ \"\"\"Update the lolomo list by context\"\"\"\n+ lolomo_root = g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION)\n+ context_index = g.LOCAL_DB.get_value('lolomo_continue_watching_index', '', TABLE_SESSION)\n+ context_id = g.LOCAL_DB.get_value('lolomo_continue_watching_id', '', TABLE_SESSION)\npath = [['lolomos', lolomo_root, 'refreshListByContext']]\n# The fourth parameter is like a request-id, but it doesn't seem to match to\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/events_handler.py",
"new_path": "resources/lib/services/msl/events_handler.py",
"diff": "@@ -124,7 +124,7 @@ class EventsHandler(threading.Thread):\ncommon.error('EVENT [{}] - The request has failed: {}', event, exc)\nif event.event_type == EVENT_STOP:\nself.clear_queue()\n- # api.update_lolomo_context('continueWatching')\n+ api.update_lolomo_context('continueWatching')\napi.update_videoid_bookmark(event.get_video_id())\n# Below commented lines: let future requests continue to be sent, unstable connections like wi-fi cause problems\n# if not event.is_response_success():\n@@ -184,8 +184,8 @@ class EventsHandler(threading.Thread):\n# Context location values can be easily viewed from tag data-ui-tracking-context\n# of a preview box in website html\n- play_ctx_location = 'WATCHNOW' # We currently leave a fixed value, we leave support for future changes\n- # play_ctx_location = 'MyListAsGallery' if event_data['is_in_mylist'] else 'browseTitles'\n+ # play_ctx_location = 'WATCHNOW'\n+ play_ctx_location = 'MyListAsGallery' if event_data['is_in_mylist'] else 'browseTitles'\n# To now it is not mandatory, we leave support for future changes\n# if event_data['is_played_by_library']:\n@@ -218,7 +218,8 @@ class EventsHandler(threading.Thread):\n'preferUnletterboxed': True, # Should be set equal to the manifest request\n'uiplaycontext': {\n# 'list_id': list_id, # not mandatory\n- # 'lolomo_id': g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION), # not mandatory\n+ # Add 'lolomo_id' seems to prevent failure of the 'refreshListByContext' request\n+ 'lolomo_id': g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION), # not mandatory\n'location': play_ctx_location,\n'rank': 0, # Perhaps this is a reference of cdn rank used in the manifest? (we use always 0)\n'request_id': event_data['request_id'],\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Some fixes for refreshListByContext request
Now you can get a good response from refreshListByContext request
but the problem is not yet resolved the continue watching list is not updated |
106,046 | 28.02.2020 17:02:32 | -3,600 | 8d35a42d5c27818fb35a14aa0a7968af8ea667f4 | Upnext is incompatible with watched status sync
It needs many changes to make it compatible, it will be done in the future | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -93,6 +93,14 @@ def play(videoid):\nevent_data = _get_event_data(videoid)\nevent_data['videoid'] = videoid.to_dict()\nevent_data['is_played_by_library'] = g.IS_SKIN_CALL\n+ # Todo: UpNext addon is incompatible with netflix watched status sync feature\n+ # Problems:\n+ # - Need to modify the cache (to update the watched status) on every played item\n+ # - Modifying the cache after the stop, is wrong due to below problems\n+ # - The new fast play, 'play_url' method, cause problems with the Player callbacks, after press play next is missing the Stop event in the controller!\n+ # - To verify possibility problems of data mixing of controller._get_player_state()\n+ # - The call of next video from UpNext is recognized as Skin call, because it's an external addon call, so it causes several operating problems\n+ is_up_next_enabled = False\nif 'raspberrypi' in common.get_system_platform():\n# OMX Player is not compatible with netflix video streams\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Upnext is incompatible with watched status sync
It needs many changes to make it compatible, it will be done in the future |
106,046 | 29.02.2020 11:07:21 | -3,600 | a13c8c08c8e82ac3c9dedda36d0e0685f507fd41 | Fixed a rare error of StreamContinuityManager
message: StreamContinuityManager disabled due to exception: 'NoneType' object is not subscriptable | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/playback/stream_continuity.py",
"new_path": "resources/lib/services/playback/stream_continuity.py",
"diff": "@@ -96,6 +96,12 @@ class StreamContinuityManager(PlaybackActionManager):\n# otherwise Kodi reacts strangely if only one value of these is restored\ncurrent_stream = self.current_streams['subtitle']\nplayer_stream = player_state.get(STREAMS['subtitle']['current'])\n+ if player_stream is None:\n+ # I don't know the cause:\n+ # Very rarely can happen that Kodi starts the playback with the subtitles enabled,\n+ # but after some seconds subtitles become disabled, and 'currentsubtitle' of player_state data become 'None'\n+ # Then _is_stream_value_equal() throw error. We do not handle it as a setting change from the user.\n+ return\nis_sub_stream_equal = self._is_stream_value_equal(current_stream, player_stream)\ncurrent_sub_enabled = self.current_streams['subtitleenabled']\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed a rare error of StreamContinuityManager
message: StreamContinuityManager disabled due to exception: 'NoneType' object is not subscriptable |
106,046 | 01.03.2020 10:13:34 | -3,600 | 3b8c10088c52f7dd55b2147f832c9b282f6afd2b | Omx player has been removed in Kodi 19 | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/player.py",
"new_path": "resources/lib/navigation/player.py",
"diff": "@@ -102,8 +102,9 @@ def play(videoid):\n# - The call of next video from UpNext is recognized as Skin call, because it's an external addon call, so it causes several operating problems\nis_up_next_enabled = False\n- if 'raspberrypi' in common.get_system_platform():\n+ if 'raspberrypi' in common.get_system_platform() and '18' in common.GetKodiVersion().version:\n# OMX Player is not compatible with netflix video streams\n+ # Only Kodi 18 has this property, on Kodi 19 Omx Player has been removed\nvalue = common.json_rpc('Settings.GetSettingValue', {'setting': 'videoplayer.useomxplayer'})\nif value.get('value'):\ncommon.json_rpc('Settings.SetSettingValue', {'setting': 'videoplayer.useomxplayer', 'value': False})\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Omx player has been removed in Kodi 19 |
106,046 | 01.03.2020 12:11:52 | -3,600 | 46e5a72b31b470a5e7d0e24b211b3826f75fce64 | Improved GetKodiVersion | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -414,29 +414,33 @@ def get_system_platform():\nclass GetKodiVersion(object):\n\"\"\"Get the kodi version, git date, stage name\"\"\"\n-\n- def __init__(self):\n# Examples of some types of supported strings:\n# 10.1 Git:Unknown PRE-11.0 Git:Unknown 11.0-BETA1 Git:20111222-22ad8e4\n# 18.1-RC1 Git:20190211-379f5f9903 19.0-ALPHA1 Git:20190419-c963b64487\n+\n+ def __init__(self):\n+ self._build_version = xbmc.getInfoLabel('System.BuildVersion')\n+\n+ @property\n+ def version(self):\nimport re\n- build_version_str = xbmc.getInfoLabel('System.BuildVersion')\n- re_kodi_version = re.search('\\\\d+\\\\.\\\\d+?(?=(\\\\s|-))', build_version_str)\n- if re_kodi_version:\n- self.version = re_kodi_version.group(0)\n- else:\n- self.version = 'Unknown'\n- re_git_date = re.search('(Git:)(\\\\d+?(?=(-|$)))', build_version_str)\n- if re_git_date and len(re_git_date.groups()) >= 2:\n- self.date = int(re_git_date.group(2))\n- else:\n- self.date = 0\n- re_stage = re.search('(\\\\d+\\\\.\\\\d+-)(.+)(?=\\\\s)', build_version_str)\n- if not re_stage:\n- re_stage = re.search('^(.+)(-\\\\d+\\\\.\\\\d+)', build_version_str)\n- self.stage = re_stage.group(1) if re_stage else ''\n- else:\n- self.stage = re_stage.group(2) if re_stage else ''\n+ result = re.search('\\\\d+\\\\.\\\\d+?(?=(\\\\s|-))', self._build_version)\n+ return result.group(0) if result else 'Unknown'\n+\n+ @property\n+ def date(self):\n+ import re\n+ result = re.search('(Git:)(\\\\d+?(?=(-|$)))', self._build_version)\n+ return int(result.group(2)) if result and len(result.groups()) >= 2 else None\n+\n+ @property\n+ def stage(self):\n+ import re\n+ result = re.search('(\\\\d+\\\\.\\\\d+-)(.+)(?=\\\\s)', self._build_version)\n+ if not result:\n+ result = re.search('^(.+)(-\\\\d+\\\\.\\\\d+)', self._build_version)\n+ return result.group(1) if result else ''\n+ return result.group(2) if result else ''\ndef update_cache_videoid_runtime(window_cls):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Improved GetKodiVersion |
106,046 | 02.03.2020 13:11:42 | -3,600 | 668356be0bf39003242b27e7d1cea68967a84e56 | Fixed wrong behaviour of release license
caused by upnext and supplemental media type videoid | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_handler.py",
"new_path": "resources/lib/services/msl/msl_handler.py",
"diff": "@@ -32,11 +32,10 @@ except NameError: # Python 3\nclass MSLHandler(object):\n\"\"\"Handles session management and crypto for license, manifest and event requests\"\"\"\n- last_license_session_id = ''\nlast_license_url = ''\n- last_license_release_url = ''\n- last_drm_context = ''\n- last_playback_context = ''\n+ licenses_session_id = []\n+ licenses_xid = []\n+ licenses_release_url = []\ndef __init__(self):\nsuper(MSLHandler, self).__init__()\n@@ -200,10 +199,12 @@ class MSLHandler(object):\nparams,\n'sessionId'),\ng.get_esn())\n- # This xid must be used for any future request, until playback stops\n+ # This xid must be used also for each future Event request, until playback stops\ng.LOCAL_DB.set_value('xid', xid, TABLE_SESSION)\n- self.last_license_session_id = sid\n- self.last_license_release_url = response[0]['links']['releaseLicense']['href']\n+\n+ self.licenses_xid.insert(0, xid)\n+ self.licenses_session_id.insert(0, sid)\n+ self.licenses_release_url.insert(0, response[0]['links']['releaseLicense']['href'])\nif self.msl_requests.msl_switch_requested:\nself.msl_requests.msl_switch_requested = False\n@@ -226,13 +227,19 @@ class MSLHandler(object):\[email protected]_execution(immediate=True)\ndef release_license(self, data=None): # pylint: disable=unused-argument\n\"\"\"Release the server license\"\"\"\n- common.debug('Requesting releasing license')\n+ try:\n+ # When UpNext is used a new video is loaded while another one is running and not yet released,\n+ # so you need to take the right data of first added license\n+ url = self.licenses_release_url.pop()\n+ sid = self.licenses_session_id.pop()\n+ xid = self.licenses_xid.pop()\n+ common.debug('Requesting releasing license')\nparams = [{\n- 'url': self.last_license_release_url,\n+ 'url': url,\n'params': {\n- 'sessionId': self.last_license_session_id,\n- 'xid': g.LOCAL_DB.get_value('xid', table=TABLE_SESSION)\n+ 'sessionId': sid,\n+ 'xid': xid\n},\n'echo': 'sessionId'\n}]\n@@ -241,6 +248,9 @@ class MSLHandler(object):\nself.msl_requests.build_request_data('/bundle', params),\ng.get_esn())\ncommon.debug('License release response: {}', response)\n+ except IndexError:\n+ # Example the supplemental media type have no license\n+ common.debug('No license to release')\ndef clear_user_id_tokens(self, data=None): # pylint: disable=unused-argument\n\"\"\"Clear all user id tokens\"\"\"\n@@ -249,8 +259,6 @@ class MSLHandler(object):\[email protected]_execution(immediate=True)\ndef __tranform_to_dash(self, manifest):\nself.last_license_url = manifest['links']['license']['href']\n- self.last_playback_context = manifest['playbackContextId']\n- self.last_drm_context = manifest['drmContextId']\nreturn convert_to_dash(manifest)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed wrong behaviour of release license
caused by upnext and supplemental media type videoid |
106,046 | 02.03.2020 12:58:49 | -3,600 | 9f96632d2666fe1cb86f644260f05b9000f7f925 | Fixed problem with reset esn | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/globals.py",
"new_path": "resources/lib/globals.py",
"diff": "@@ -314,7 +314,7 @@ class GlobalVariables(object):\n\"\"\"Get the generated esn or if set get the custom esn\"\"\"\nfrom resources.lib.database.db_utils import TABLE_SESSION\ncustom_esn = g.ADDON.getSetting('esn')\n- return custom_esn if custom_esn else g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\n+ return custom_esn if custom_esn else g.LOCAL_DB.get_value('esn', '', table=TABLE_SESSION)\ndef get_edge_esn(self):\n\"\"\"Get a previously generated edge ESN from the settings or generate\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/nfsession_base.py",
"new_path": "resources/lib/services/nfsession/nfsession_base.py",
"diff": "@@ -72,10 +72,9 @@ class NFSessionBase(object):\ncommon.info('Initialized new session')\ndef update_session_data(self, old_esn=None):\n- old_esn = old_esn or g.get_esn()\nself.set_session_header_data()\ncookies.save(self.account_hash, self.session.cookies)\n- _update_esn(old_esn)\n+ _update_esn(g.get_esn() if old_esn is None else old_esn)\ndef set_session_header_data(self):\ntry:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed problem with reset esn |
106,046 | 02.03.2020 13:28:15 | -3,600 | d636215631bc04872aefafb4f321e82702a94747 | Fixed issue with highlight titles
you must not modify the cache data | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -75,7 +75,7 @@ def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False,\n# Short information about future release of tv show season or other\ninfos_copy['plot'] += '[CR][COLOR green]{}[/COLOR]'.format(item['dpSupplementalMessage'])\nif handle_highlighted_title:\n- add_highlighted_title(list_item, videoid, infos)\n+ add_highlighted_title(list_item, videoid, infos_copy)\nlist_item.setInfo('video', infos_copy)\nreturn infos_copy\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed issue with highlight titles
you must not modify the cache data |
106,046 | 02.03.2020 13:40:48 | -3,600 | 37f3d199bc8899757a35c13fa361473d2d219420 | Stop annoying notifications of lolomo context update
Shows only when debugging is verbose,
i don't know how much time you will need and if you will find a way to find a solution to this problem | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -156,6 +156,8 @@ def update_lolomo_context(context_name):\nexcept Exception: # pylint: disable=broad-except\n# I do not know the reason yet, but sometimes continues to return error 401,\n# making it impossible to update the bookmark position\n+ if not common.is_debug_verbose():\n+ return\nui.show_notification(title=common.get_local_string(30105),\nmsg='An error prevented the update the lolomo context on netflix',\ntime=10000)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Stop annoying notifications of lolomo context update
Shows only when debugging is verbose,
i don't know how much time you will need and if you will find a way to find a solution to this problem |
106,046 | 02.03.2020 18:31:39 | -3,600 | 3fcc21d947e8d6ce5691866fdd76c1877870e22c | Deleted unused PersistentStorage | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/__init__.py",
"new_path": "resources/lib/common/__init__.py",
"diff": "@@ -14,7 +14,6 @@ from .logging import *\nfrom .ipc import * # pylint: disable=redefined-builtin\nfrom .videoid import * # pylint: disable=redefined-builtin\nfrom .credentials import *\n-from .storage import *\nfrom .fileops import *\nfrom .kodiops import * # pylint: disable=redefined-builtin\nfrom .pathops import *\n"
},
{
"change_type": "DELETE",
"old_path": "resources/lib/common/storage.py",
"new_path": null,
"diff": "-# -*- coding: utf-8 -*-\n-\"\"\"\n- Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n- Copyright (C) 2018 Caphm (original implementation module)\n- Generic persistent on disk storage\n-\n- SPDX-License-Identifier: MIT\n- See LICENSES/MIT.md for more information.\n-\"\"\"\n-from __future__ import absolute_import, division, unicode_literals\n-\n-import json\n-\n-from .logging import debug, warn\n-from .fileops import save_file, load_file\n-\n-\n-class PersistentStorage(object):\n- \"\"\"\n- Key-Value storage with a backing file on disk.\n- Reads entire dict structure into memory on first access and updates\n- the backing file with each changed entry.\n-\n- IMPORTANT: Changes to mutable objects inserted into the key-value-store\n- are not automatically written to disk. You need to call commit() to\n- persist these changes.\n- \"\"\"\n- def __init__(self, storage_id, no_save_on_destroy=False):\n- self.storage_id = storage_id\n- self.backing_file = self.storage_id + '.ndb'\n- self._contents = {}\n- self._dirty = True\n- self._no_save_on_destroy = no_save_on_destroy\n- debug('Instantiated {}'.format(self.storage_id))\n-\n- def __del__(self):\n- debug('Destroying storage instance (no_save_on_destroy={0}) {1}'.format(str(self._no_save_on_destroy), self.storage_id))\n- if not self._no_save_on_destroy:\n- self.commit()\n-\n- def __getitem__(self, key):\n- return self.contents[key]\n-\n- def __setitem__(self, key, value):\n- self.contents[key] = value\n- self.commit()\n-\n- @property\n- def contents(self):\n- \"\"\"\n- The contents of the storage file\n- \"\"\"\n- if self._dirty:\n- self._load_from_disk()\n- return self._contents\n-\n- def get(self, key, default=None):\n- \"\"\"\n- Return the value associated with key. If key does not exist,\n- return default (defaults to None)\n- \"\"\"\n- return self.contents.get(key, default)\n-\n- def commit(self):\n- \"\"\"\n- Write current contents to disk\n- \"\"\"\n- save_file(self.backing_file, json.dumps(self._contents))\n- debug('Committed changes to backing file')\n-\n- def clear(self):\n- \"\"\"\n- Clear contents and backing file\n- \"\"\"\n- self._contents = {}\n- self.commit()\n-\n- def _load_from_disk(self):\n- # pylint: disable=broad-except\n- debug('Trying to load contents from disk')\n- try:\n- self._contents = json.loads(load_file(self.backing_file))\n- debug('Loaded contents from backing file: {}'\n- .format(self._contents))\n- except Exception:\n- warn('Backing file does not exist or is not readable')\n- self._dirty = False\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Deleted unused PersistentStorage |
106,046 | 03.03.2020 20:15:59 | -3,600 | 657cf37f570908e22db0a38127add91359c227d9 | Fixed possible error on empty results | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/data_types.py",
"new_path": "resources/lib/api/data_types.py",
"diff": "@@ -177,7 +177,7 @@ class CustomVideoList:\ndef __init__(self, path_response):\nself.perpetual_range_selector = path_response.get('_perpetual_range_selector')\nself.data = path_response\n- self.videos = self.data.get('videos')\n+ self.videos = self.data.get('videos', {})\nself.videoids = _get_videoids(self.videos)\n# self.artitem = next(itervalues(self.videos))\nself.artitem = list(self.videos.values())[0] if self.videos else None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed possible error on empty results |
106,046 | 03.03.2020 20:16:56 | -3,600 | d5a745549766e50fe0dca788444226c969d4a0f3 | Added chunked custom video list | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/shakti.py",
"new_path": "resources/lib/api/shakti.py",
"diff": "@@ -246,8 +246,7 @@ def video_list_sorted(context_name, context_id=None, perpetual_range_start=None,\[email protected]_execution(immediate=False)\ndef custom_video_list(video_ids, custom_paths=None):\n- \"\"\"Retrieve a video list which contains the videos specified by\n- video_ids\"\"\"\n+ \"\"\"Retrieve a video list which contains the videos specified by video_ids\"\"\"\ncommon.debug('Requesting custom video list with {} videos', len(video_ids))\nreturn CustomVideoList(common.make_call(\n'path_request',\n@@ -255,6 +254,22 @@ def custom_video_list(video_ids, custom_paths=None):\ncustom_paths if custom_paths else VIDEO_LIST_PARTIAL_PATHS)))\[email protected]_execution(immediate=False)\n+def chunked_custom_video_list(chunked_video_list):\n+ \"\"\"Retrieve a video list which contains the videos specified by video_ids\"\"\"\n+ chunked_video_ids = chunked_video_list['video_ids']\n+ common.debug('Requesting custom video list with {} chunked video list', len(chunked_video_ids))\n+ merged_response = {}\n+ for video_ids in chunked_video_ids:\n+ path_response = common.make_call('path_request', build_paths(['videos', video_ids], VIDEO_LIST_PARTIAL_PATHS))\n+ common.merge_dicts(path_response, merged_response)\n+\n+ perpetual_range_selector = chunked_video_list['perpetual_range_selector']\n+ if perpetual_range_selector:\n+ merged_response.update(perpetual_range_selector)\n+ return CustomVideoList(merged_response)\n+\n+\[email protected]_execution(immediate=False)\[email protected]_output(cache.CACHE_GENRES, identify_from_kwarg_name='genre_id')\ndef genre(genre_id):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added chunked custom video list |
106,046 | 03.03.2020 20:17:29 | -3,600 | 6e895b66fd51aca11387d7ecb20960cfbb944ec5 | Added list converter in to chunked list | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/common/misc_utils.py",
"new_path": "resources/lib/common/misc_utils.py",
"diff": "@@ -145,6 +145,11 @@ def compare_dicts(dict_a, dict_b, excluded_keys=None):\nreturn all(dict_a[k] == dict_b[k] for k in dict_a if k not in excluded_keys)\n+def chunked_list(seq, chunk_len):\n+ for start in range(0, len(seq), chunk_len):\n+ yield seq[start:start+chunk_len]\n+\n+\ndef any_value_except(mapping, excluded_keys):\n\"\"\"Return a random value from a dict that is not associated with excluded_key.\nRaises StopIteration if there are no other keys than excluded_key\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added list converter in to chunked list |
106,046 | 03.03.2020 20:40:11 | -3,600 | 715a46be59613b0f21be5e5bba93e7480be12adc | Fixed exported menu error when there are many elements
When there are more than 50 items exported the shakti request cause this error:
413 Client Error: Request Entity Too Large
it is necessary to manage the requests as a paged list by limiting the amount of videoid to request | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/library.py",
"new_path": "resources/lib/kodi/library.py",
"diff": "@@ -18,6 +18,7 @@ import resources.lib.api.shakti as api\nimport resources.lib.common as common\nimport resources.lib.kodi.nfo as nfo\nimport resources.lib.kodi.ui as ui\n+from resources.lib.api.paths import MAX_PATH_REQUEST_SIZE\nfrom resources.lib.globals import g\nfrom resources.lib.kodi.library_items import (export_item, remove_item, export_new_item, get_item,\nItemNotFound, FOLDER_MOVIES, FOLDER_TV, library_path)\n@@ -44,10 +45,33 @@ def update_kodi_library(library_operation):\nreturn kodi_library_update_wrapper\n-def list_contents():\n- \"\"\"Return a list of all video IDs (movies, shows)\n- contained in the library\"\"\"\n- return g.SHARED_DB.get_all_video_id_list()\n+def list_contents(perpetual_range_start):\n+ \"\"\"Return a chunked list of all video IDs (movies, shows) contained in the library\"\"\"\n+ perpetual_range_start = int(perpetual_range_start) if perpetual_range_start else 0\n+ number_of_requests = 2\n+ video_id_list = g.SHARED_DB.get_all_video_id_list()\n+ count = 0\n+ results = []\n+ perpetual_range_selector = {}\n+\n+ for index, chunk in enumerate(common.chunked_list(video_id_list, MAX_PATH_REQUEST_SIZE)):\n+ if index >= perpetual_range_start:\n+ if number_of_requests == 0:\n+ if len(video_id_list) > count:\n+ # Exists others elements\n+ perpetual_range_selector['_perpetual_range_selector'] = {'next_start': perpetual_range_start + 1}\n+ break\n+ results.append(chunk)\n+ number_of_requests -= 1\n+ count += len(chunk)\n+\n+ if perpetual_range_start > 0:\n+ previous_start = perpetual_range_start - 1\n+ if '_perpetual_range_selector' in perpetual_range_selector:\n+ perpetual_range_selector['_perpetual_range_selector']['previous_start'] = previous_start\n+ else:\n+ perpetual_range_selector['_perpetual_range_selector'] = {'previous_start': previous_start}\n+ return {'video_ids': results, 'perpetual_range_selector': perpetual_range_selector}\ndef is_in_library(videoid):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/navigation/directory.py",
"new_path": "resources/lib/navigation/directory.py",
"diff": "@@ -176,13 +176,14 @@ class DirectoryBuilder(object):\[email protected]_execution(immediate=False)\ndef exported(self, pathitems=None):\n\"\"\"List all items that are exported to the Kodi library\"\"\"\n- # pylint: disable=unused-argument\n- library_contents = library.list_contents()\n- if library_contents:\n- listings.build_video_listing(api.custom_video_list(library_contents), g.MAIN_MENU_ITEMS['exported'])\n+ library_contents = library.list_contents(self.perpetual_range_start)\n+ if library_contents['video_ids']:\n+ listings.build_video_listing(api.chunked_custom_video_list(library_contents),\n+ g.MAIN_MENU_ITEMS['exported'],\n+ pathitems)\n_handle_endofdirectory(self.dir_update_listing)\nelse:\n- ui.show_notification(common.get_local_string(30013))\n+ ui.show_notification(common.get_local_string(30111))\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\[email protected]_execution(immediate=False)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed exported menu error when there are many elements
When there are more than 50 items exported the shakti request cause this error:
413 Client Error: Request Entity Too Large
it is necessary to manage the requests as a paged list by limiting the amount of videoid to request |
106,046 | 04.03.2020 10:35:10 | -3,600 | 751d02d8b25e3d3f29db70d8a1920e5d902e56f9 | Fixed unescaped auto-profile name in settings | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/listings.py",
"new_path": "resources/lib/kodi/listings.py",
"diff": "@@ -92,7 +92,6 @@ def _create_profile_item(profile_guid, is_active, html_parser):\ndescription.append(common.get_local_string(30221))\nif is_kids:\ndescription.append(common.get_local_string(30222))\n- enc_profile_name = profile_name.encode('utf-8')\nlist_item = list_item_skeleton(\nlabel=unescaped_profile_name,\nicon=g.LOCAL_DB.get_profile_config('avatar', '', guid=profile_guid),\n@@ -100,7 +99,7 @@ def _create_profile_item(profile_guid, is_active, html_parser):\nlist_item.select(is_active)\nautologin_url = common.build_url(\npathitems=['save_autologin', profile_guid],\n- params={'autologin_user': enc_profile_name},\n+ params={'autologin_user': unescaped_profile_name.encode('utf-8')},\nmode=g.MODE_ACTION)\nlist_item.addContextMenuItems(\n[(common.get_local_string(30053),\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed unescaped auto-profile name in settings |
106,046 | 04.03.2020 12:03:17 | -3,600 | fa119a22504da892847c1abd7268d033262f24e5 | Update README.md
Dolby Vision has been fixed also on Kodi 18.6 | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -30,7 +30,7 @@ The trademark \"Netflix\" is registered by \"Netflix, Inc.\"\n- Possibility of playback at 1080P and 4K (see high resolutions table)\n- Support of hi-res audio Dolby Digital Plus and Dolby Digital Atmos (requires a premium account)\n- Support of HDR / HDR10 only on capable android devices (requires a premium account)\n-- Support of Dolby Vision only on Kodi 19.x and capable android devices (requires a premium account)\n+- Support of Dolby Vision only on capable android devices (requires a premium account)\n- Support integration with Up Next add-on (proposes to play the next episode automatically)\n## Installation & Updates\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Update README.md
Dolby Vision has been fixed also on Kodi 18.6 |
106,046 | 06.03.2020 13:43:54 | -3,600 | e33d867044907c25006b1d4a65ba7c3bd10df715 | Version bump (1.0.0) | [
{
"change_type": "MODIFY",
"old_path": "addon.xml",
"new_path": "addon.xml",
"diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.16.4\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"1.0.0\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.addon.signals\" version=\"0.0.3\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n-v0.16.4 (2020-01-28)\n--Up Next is now supported only from version 1.1.0 and up\n--Added czech language\n--Added \"because you liked\" to recommendations menu\n--Added Up Next install option\n--Implemented Up Next feature, end time information\n--Implemented Up Next feature, fast start next video\n--Fixed the error \"Request failed validation during key exchange\"\n--Fixed an issue that causing opening Up Next notification in wrong position\n--Fixed html tags in profiles names\n--Fixed STRM files resume workaround\n--Fixed retrieving infolabels from library on python 3\n--Managed user id token key expiration\n--Manifest is saved to hdd with enabled verbose debugging only\n--Updated de, es, hu, it translations\n--Some minor changes, fixes\n-\n-v0.16.3 (2020-01-18)\n--Fixed an issue that causing addon freeze on export/update to library\n--Fixed an regression issue that causing http error 401\n--Fixed an issue that causing unicodedecode error at startup\n--Fixed an issue that in some cases prevented the export of a tv show season\n--Generally optimized addon speed\n--Many improvements to the code\n+v1.0.0 (2020-03-06)\n+-Added watched status sync with Netflix services WIP (details on github wiki)\n+-Reworked add-on/kodi auto-configuration based on device and system characteristics\n+-Reworked MSL service\n+-Added support to MSL switch profile, this fixes very old issues:\n+ -Requests are now performed with the right msl profile\n+ -No more missing audio languages on non-owner profiles\n+ -No more missing subtitle languages on non-owner profiles\n+ -No more video not available error when main profile has age limits and other profile are set as adults\n+ -You can update watched status on all profiles\n+-Added workaround to fix 4k media flag with android device 4k capable\n+-Added turkish language\n+-Changes on nfsession profile switch in order to get the profiles cookies\n+-Improved ESN generation on android devices\n+-Automatically turn off omx player on raspberry (not compatible)\n+-Fixed the error when opening the Export menu caused by too many exported items\n+-Fixed an issue that causing delayed start of services features after start playback\n+-Fixed issues with ios/tvos restrictions (but due to missing widevine library for now are not supported)\n+-Fixed service databases upgrade\n+-Fixed an issue that caused wrong behaviour with Reset ESN\n+-Fixed an issue that caused wrong behaviour with highlighted titles\n+-Fixed a rare issue that caused \"stream continuity\" to stop working\n+-Updated jp, kr, it, pl, hu, hr, de, fr, es translations\n+-A lot of other code changes\n</news>\n</extension>\n</addon>\n"
},
{
"change_type": "MODIFY",
"old_path": "changelog.txt",
"new_path": "changelog.txt",
"diff": "+v0.16.4 (2020-01-28)\n+-Up Next is now supported only from version 1.1.0 and up\n+-Added czech language\n+-Added \"because you liked\" to recommendations menu\n+-Added Up Next install option\n+-Implemented Up Next feature, end time information\n+-Implemented Up Next feature, fast start next video\n+-Fixed the error \"Request failed validation during key exchange\"\n+-Fixed an issue that causing opening Up Next notification in wrong position\n+-Fixed html tags in profiles names\n+-Fixed STRM files resume workaround\n+-Fixed retrieving infolabels from library on python 3\n+-Managed user id token key expiration\n+-Manifest is saved to hdd with enabled verbose debugging only\n+-Updated de, es, hu, it translations\n+-Some minor changes, fixes\n+\n+v0.16.3 (2020-01-18)\n+-Fixed an issue that causing addon freeze on export/update to library\n+-Fixed an regression issue that causing http error 401\n+-Fixed an issue that causing unicodedecode error at startup\n+-Fixed an issue that in some cases prevented the export of a tv show season\n+-Generally optimized addon speed\n+-Many improvements to the code\n+\nv0.16.2 (2020-01-07)\n-Improved add-on startup\n-Improved loading of profiles list\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump (1.0.0) |
106,046 | 09.03.2020 14:12:23 | -3,600 | 7a7f1608a87286b05a4571e40a996622fae6cb1c | Fixed supplemental message and credits offset | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/paths.py",
"new_path": "resources/lib/api/paths.py",
"diff": "@@ -41,7 +41,7 @@ ART_PARTIAL_PATHS = [\nVIDEO_LIST_PARTIAL_PATHS = [\n[['requestId', 'summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue',\n'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount',\n- 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'creditsOffset'\n+ 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'creditsOffset',\n'dpSupplementalMessage', 'watched', 'delivery']],\n[['genres', 'tags', 'creators', 'directors', 'cast'],\n{'from': 0, 'to': 10}, ['id', 'name']]\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed supplemental message and credits offset |
106,046 | 09.03.2020 15:06:27 | -3,600 | 7e7fee34f7d956d843eba0e060272a6ec191f970 | Added support for sequiturEvidence infos | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/api/paths.py",
"new_path": "resources/lib/api/paths.py",
"diff": "@@ -42,7 +42,7 @@ VIDEO_LIST_PARTIAL_PATHS = [\n[['requestId', 'summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue',\n'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount',\n'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'creditsOffset',\n- 'dpSupplementalMessage', 'watched', 'delivery']],\n+ 'dpSupplementalMessage', 'watched', 'delivery', 'sequiturEvidence']],\n[['genres', 'tags', 'creators', 'directors', 'cast'],\n{'from': 0, 'to': 10}, ['id', 'name']]\n] + ART_PARTIAL_PATHS\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -73,7 +73,17 @@ def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False,\nlist_item.addStreamInfo(stream_type, quality_infos)\nif item.get('dpSupplementalMessage'):\n# Short information about future release of tv show season or other\n- infos_copy['plot'] += '[CR][COLOR green]{}[/COLOR]'.format(item['dpSupplementalMessage'])\n+ if infos_copy['plot']:\n+ infos_copy['plot'] += '[CR][CR]'\n+ infos_copy['plot'] += '[COLOR green]{}[/COLOR]'.format(item['dpSupplementalMessage'])\n+ # The 'sequiturEvidence' dict can be of type 'hook' or 'watched'\n+ if (item.get('sequiturEvidence') and\n+ item['sequiturEvidence'].get('type') == 'hook' and\n+ item['sequiturEvidence'].get('value')):\n+ # Short information about the actors career/awards and similarities/connections with others films or tv shows\n+ if infos_copy['plot']:\n+ infos_copy['plot'] += '[CR][CR]'\n+ infos_copy['plot'] += '[COLOR green]{}[/COLOR]'.format(item['sequiturEvidence']['value']['text'])\nif handle_highlighted_title:\nadd_highlighted_title(list_item, videoid, infos_copy)\nlist_item.setInfo('video', infos_copy)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added support for sequiturEvidence infos |
106,046 | 10.03.2020 10:40:56 | -3,600 | fe026ae30050317c96424461c1927c1652fc8176 | Clean colorize text function | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "from __future__ import absolute_import, division, unicode_literals\nimport copy\n-import re\nfrom future.utils import iteritems, itervalues\n@@ -37,6 +36,8 @@ JSONRPC_MAPPINGS = {\n'userrating': 'rating'\n}\n+COLORS = [None, 'blue', 'red', 'green', 'white', 'yellow', 'black', 'gray']\n+\ndef get_info(videoid, item, raw_data):\n\"\"\"Get the infolabels data\"\"\"\n@@ -334,30 +335,26 @@ def _sanitize_infos(details):\ndef add_highlighted_title(list_item, videoid, infos):\n\"\"\"Highlight menu item title when the videoid is contained in my-list\"\"\"\n- highlight_index = g.ADDON.getSettingInt('highlight_mylist_titles')\n- if not highlight_index:\n+ color_index = g.ADDON.getSettingInt('highlight_mylist_titles')\n+ if not color_index:\nreturn\n- highlight_color = ['black', 'blue', 'red', 'green', 'white', 'yellow'][highlight_index]\n- remove_color = videoid not in api.mylist_items()\n+ apply_color = videoid in api.mylist_items()\nif list_item.getProperty('isFolder') == 'true':\n- updated_title = _colorize_title(g.py2_decode(list_item.getVideoInfoTag().getTitle()),\n- highlight_color,\n- remove_color)\n+ updated_title = _colorize_text(apply_color,\n+ color_index,\n+ g.py2_decode(list_item.getVideoInfoTag().getTitle()))\nlist_item.setLabel(updated_title)\ninfos['title'] = updated_title\nelse:\n# When menu item is not a folder 'label' is replaced by 'title' property of infoLabel\n- infos['title'] = _colorize_title(infos['title'], highlight_color, remove_color)\n+ infos['title'] = _colorize_text(apply_color,\n+ color_index,\n+ infos['title'])\n-def _colorize_title(text, color, remove_color=False):\n- matches = re.match(r'(\\[COLOR\\s.+\\])(.*)(\\[/COLOR\\])', text)\n- if remove_color:\n- if matches:\n- return matches.groups()[1]\n- else:\n- if not matches:\n- return '[COLOR {}]{}[/COLOR]'.format(color, text)\n+def _colorize_text(apply_color, color_index, text):\n+ if apply_color and COLORS[color_index]:\n+ return '[COLOR {}]{}[/COLOR]'.format(COLORS[color_index], text)\nreturn text\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"autologin_user\" type=\"text\" label=\"30055\" default=\"\" enable=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"autologin_id\" type=\"text\" label=\"30056\" default=\"\" enable=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting label=\"30015\" type=\"lsep\"/><!--Other options-->\n- <setting id=\"highlight_mylist_titles\" type=\"enum\" label=\"30215\" lvalues=\"13106|762|13343|13341|761|760\" default=\"1\"/>\n+ <setting id=\"highlight_mylist_titles\" type=\"enum\" label=\"30215\" lvalues=\"13106|762|13343|13341|761|760|731|767\" default=\"1\"/>\n<setting id=\"disable_startup_notification\" type=\"bool\" label=\"30141\" default=\"false\"/>\n</category>\n<category label=\"30025\"><!--Library-->\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Clean colorize text function |
106,046 | 10.03.2020 11:04:17 | -3,600 | eca582ac2d4ed084781a63df481c83f8d7f6dac0 | Added customizable color of suppl. info of plot | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -980,3 +980,6 @@ msgctxt \"#30238\"\nmsgid \"Up Next notifications (watch next video)\"\nmsgstr \"\"\n+msgctxt \"#30239\"\n+msgid \"Color of supplemental plot info\"\n+msgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/infolabels.py",
"new_path": "resources/lib/kodi/infolabels.py",
"diff": "@@ -72,23 +72,30 @@ def add_info(videoid, list_item, item, raw_data, handle_highlighted_title=False,\nlist_item.setProperty('isFolder', 'true')\nfor stream_type, quality_infos in iteritems(quality_infos):\nlist_item.addStreamInfo(stream_type, quality_infos)\n+ _add_supplemental_plot_info(item, infos_copy)\n+ if handle_highlighted_title:\n+ add_highlighted_title(list_item, videoid, infos_copy)\n+ list_item.setInfo('video', infos_copy)\n+ return infos_copy\n+\n+\n+def _add_supplemental_plot_info(item, infos_copy):\n+ \"\"\"Add supplemental info to plot description\"\"\"\n+ color_index = g.ADDON.getSettingInt('supplemental_info_color')\n+ suppl_info = []\nif item.get('dpSupplementalMessage'):\n# Short information about future release of tv show season or other\n- if infos_copy['plot']:\n- infos_copy['plot'] += '[CR][CR]'\n- infos_copy['plot'] += '[COLOR green]{}[/COLOR]'.format(item['dpSupplementalMessage'])\n+ suppl_info.append(item['dpSupplementalMessage'])\n# The 'sequiturEvidence' dict can be of type 'hook' or 'watched'\nif (item.get('sequiturEvidence') and\nitem['sequiturEvidence'].get('type') == 'hook' and\nitem['sequiturEvidence'].get('value')):\n# Short information about the actors career/awards and similarities/connections with others films or tv shows\n- if infos_copy['plot']:\n+ suppl_info.append(item['sequiturEvidence']['value']['text'])\n+ suppl_text = '[CR][CR]'.join(suppl_info)\n+ if suppl_text and infos_copy['plot']:\ninfos_copy['plot'] += '[CR][CR]'\n- infos_copy['plot'] += '[COLOR green]{}[/COLOR]'.format(item['sequiturEvidence']['value']['text'])\n- if handle_highlighted_title:\n- add_highlighted_title(list_item, videoid, infos_copy)\n- list_item.setInfo('video', infos_copy)\n- return infos_copy\n+ infos_copy['plot'] += _colorize_text(True, color_index, suppl_text)\ndef get_art(videoid, item, raw_data=None):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"autologin_id\" type=\"text\" label=\"30056\" default=\"\" enable=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting label=\"30015\" type=\"lsep\"/><!--Other options-->\n<setting id=\"highlight_mylist_titles\" type=\"enum\" label=\"30215\" lvalues=\"13106|762|13343|13341|761|760|731|767\" default=\"1\"/>\n+ <setting id=\"supplemental_info_color\" type=\"enum\" label=\"30239\" lvalues=\"13106|762|13343|13341|761|760|731|767\" default=\"3\"/>\n<setting id=\"disable_startup_notification\" type=\"bool\" label=\"30141\" default=\"false\"/>\n</category>\n<category label=\"30025\"><!--Library-->\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added customizable color of suppl. info of plot |
106,046 | 10.03.2020 11:31:58 | -3,600 | 8dc767d1bffc19cf69eececc35df6b3c716e5f3c | More http server security | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/http_server.py",
"new_path": "resources/lib/services/msl/http_server.py",
"diff": "@@ -41,6 +41,11 @@ class MSLHttpRequestHandler(BaseHTTPRequestHandler):\ndef do_POST(self):\n\"\"\"Loads the licence for the requested resource\"\"\"\ntry:\n+ url_parse = urlparse(self.path)\n+ common.debug('Handling HTTP POST IPC call to {}', url_parse.path)\n+ if '/license' not in url_parse:\n+ self.send_response(404)\n+ return\nlength = int(self.headers.get('content-length', 0))\ndata = self.rfile.read(length).decode('utf-8').split('!')\nb64license = self.server.msl_handler.get_license(\n@@ -56,7 +61,12 @@ class MSLHttpRequestHandler(BaseHTTPRequestHandler):\ndef do_GET(self):\n\"\"\"Loads the XML manifest for the requested resource\"\"\"\ntry:\n- params = parse_qs(urlparse(self.path).query)\n+ url_parse = urlparse(self.path)\n+ common.debug('Handling HTTP GET IPC call to {}', url_parse.path)\n+ if '/manifest' not in url_parse:\n+ self.send_response(404)\n+ return\n+ params = parse_qs(url_parse.query)\ndata = self.server.msl_handler.load_manifest(int(params['id'][0]))\nself.send_response(200)\nself.send_header('Content-type', 'application/xml')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/nfsession/http_server.py",
"new_path": "resources/lib/services/nfsession/http_server.py",
"diff": "@@ -32,7 +32,7 @@ class NetflixHttpRequestHandler(BaseHTTPRequestHandler):\ndef do_POST(self):\n\"\"\"Loads the licence for the requested resource\"\"\"\n- common.debug('Handling HTTP IPC call to {}', self.path[1:])\n+ common.debug('Handling HTTP POST IPC call to {}', self.path[1:])\nfunc = getattr(NetflixSession, self.path[1:])\nlength = int(self.headers.get('content-length', 0))\ndata = json.loads(self.rfile.read(length)) or None\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | More http server security |
106,046 | 10.03.2020 11:58:27 | -3,600 | 690b164de041b8dc90ffc1ff9aafbb7f8d70cae8 | Set headers on http msl session | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/services/msl/msl_requests.py",
"new_path": "resources/lib/services/msl/msl_requests.py",
"diff": "@@ -36,6 +36,11 @@ class MSLRequests(MSLRequestBuilder):\ndef __init__(self, msl_data=None):\nsuper(MSLRequests, self).__init__()\nself.session = requests.session()\n+ self.session.headers.update({\n+ 'User-Agent': common.get_user_agent(),\n+ 'Content-Type': 'text/plain',\n+ 'Accept': '*/*'\n+ })\nself._load_msl_data(msl_data)\nself.msl_switch_requested = False\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Set headers on http msl session |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.