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
11.03.2020 10:58:36
-3,600
71dd6502949b99475c0e9a5f940a200c49fc1cd8
Improved 30047 id
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.cs_cz/strings.po", "new_path": "resources/language/resource.language.cs_cz/strings.po", "diff": "@@ -203,7 +203,7 @@ msgid \"There is a problem with InputStream Adaptive add-on or the Widevine libra\nmsgstr \"\"\nmsgctxt \"#30047\"\n-msgid \"Finally remove?\"\n+msgid \"Do you want to remove it permanently?\"\nmsgstr \"Opravdu odstranit?\"\nmsgctxt \"#30048\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -203,7 +203,7 @@ msgid \"There is a problem with InputStream Adaptive add-on or the Widevine libra\nmsgstr \"\"\nmsgctxt \"#30047\"\n-msgid \"Finally remove?\"\n+msgid \"Do you want to remove it permanently?\"\nmsgstr \"\"\nmsgctxt \"#30048\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.nl_nl/strings.po", "new_path": "resources/language/resource.language.nl_nl/strings.po", "diff": "@@ -203,7 +203,7 @@ msgid \"There is a problem with InputStream Adaptive add-on or the Widevine libra\nmsgstr \"\"\nmsgctxt \"#30047\"\n-msgid \"Finally remove?\"\n+msgid \"Do you want to remove it permanently?\"\nmsgstr \"Definitief verwijderen?\"\nmsgctxt \"#30048\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.pt_br/strings.po", "new_path": "resources/language/resource.language.pt_br/strings.po", "diff": "@@ -203,7 +203,7 @@ msgid \"There is a problem with InputStream Adaptive add-on or the Widevine libra\nmsgstr \"\"\nmsgctxt \"#30047\"\n-msgid \"Finally remove?\"\n+msgid \"Do you want to remove it permanently?\"\nmsgstr \"Deseja remover?\"\nmsgctxt \"#30048\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Improved 30047 id
106,046
12.03.2020 19:26:09
-3,600
b91d83ce193f8bc269be860b20facfa28ffc49a8
Changes to lolomo update context
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -78,7 +78,7 @@ def activate_profile(profile_guid):\n\"\"\"Activate the profile with the given GUID\"\"\"\ncommon.make_call('activate_profile', profile_guid)\nif g.ADDON.getSettingBool('ProgressManager_enabled'):\n- save_current_lolomo_data('continueWatching')\n+ save_current_lolomo_data()\ng.CACHE.invalidate()\n@@ -104,24 +104,36 @@ def root_lists():\nART_PARTIAL_PATHS)))\n-def save_current_lolomo_data(context_name):\n+def save_current_lolomo_data():\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']]])\n+ context_names = ['continueWatching']\n+ lolomo_data = common.make_call('path_request',\n+ [['lolomo', context_names, ['context', 'id', 'index']]])\nlolomo_root = lolomo_data['lolomo'][1]\n+ g.LOCAL_DB.set_value('lolomo_root_id', lolomo_root, TABLE_SESSION)\n+ # Todo: In the new profiles, there is no 'continueWatching' list and no list is returned\n+ # How get the lolomo of continueWatching?\n+ for context_name in context_names:\n+ if context_name in lolomo_data['lolomos'][lolomo_root]:\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+ else:\n+ context_index = ''\n+ context_id = ''\n+ g.LOCAL_DB.set_value('lolomo_{}_index'.format(context_name.lower()), context_index, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('lolomo_{}_id'.format(context_name.lower()), context_id, TABLE_SESSION)\ndef update_lolomo_context(context_name):\n\"\"\"Update the lolomo list by context\"\"\"\nlolomo_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)\n+ context_index = g.LOCAL_DB.get_value('lolomo_{}_index'.format(context_name.lower()), '', TABLE_SESSION)\n+ context_id = g.LOCAL_DB.get_value('lolomo_{}_id'.format(context_name.lower()), '', TABLE_SESSION)\n+\n+ if not context_index:\n+ return\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" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -42,10 +42,11 @@ class Event(object):\nSTATUS_ERROR = 'ERROR'\nSTATUS_SUCCESS = 'SUCCESS'\n- def __init__(self, event_data):\n- self.event_type = event_data['params']['event']\n+ def __init__(self, request_data, event_data):\n+ self.event_type = request_data['params']['event']\nself.status = self.STATUS_INQUEUE\n- self.request_data = event_data\n+ self.event_data = event_data\n+ self.request_data = request_data\nself.response_data = None\nself.req_attempt = 0\ncommon.debug('EVENT [{}] - Added to queue', self.event_type)\n@@ -124,7 +125,14 @@ 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_data['is_in_mylist']:\n+ # If video is in my list, invalidate the continueWatching list (update lolomo context data)\napi.update_lolomo_context('continueWatching')\n+ else:\n+ # Else invalidate the 'queue' list (update lolomo context data)\n+ # Todo: get 'queue' lolomo id/index\n+ # api.update_lolomo_context('queue')\n+ pass\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@@ -157,13 +165,13 @@ class EventsHandler(threading.Thread):\nreturn\nfrom resources.lib.services.msl.msl_request_builder import MSLRequestBuilder\n- event_data = MSLRequestBuilder.build_request_data(url,\n+ request_data = MSLRequestBuilder.build_request_data(url,\nself._build_event_params(event_type,\nevent_data,\nplayer_state,\nmanifest))\ntry:\n- self.queue_events.put_nowait(Event(event_data))\n+ self.queue_events.put_nowait(Event(request_data, event_data))\nexcept queue.Full:\ncommon.warn('EVENT [{}] - Not added to the queue. The event queue is full.', event_type)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Changes to lolomo update context
106,046
12.03.2020 19:35:56
-3,600
46f2481a6dfc8a78ffa075a06057bde9057f2940
Added more contexts to recommendations menu
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -115,7 +115,8 @@ class GlobalVariables(object):\n'description_id': 30164,\n'icon': 'DefaultTVShows.png'}),\n('recommendations', {'path': ['recommendations', 'recommendations'],\n- 'lolomo_contexts': ['similars', 'becauseYouAdded', 'becauseYouLiked'],\n+ 'lolomo_contexts': ['similars', 'becauseYouAdded', 'becauseYouLiked', 'watchAgain',\n+ 'bigRow'],\n'lolomo_known': False,\n'label_id': 30001,\n'description_id': 30094,\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added more contexts to recommendations menu
106,046
13.03.2020 17:59:31
-3,600
3edf0d37e253b5d599eb6c740de37345c93f2da9
Add get hdcp level
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/device_utils.py", "new_path": "resources/lib/common/device_utils.py", "diff": "@@ -76,17 +76,24 @@ def is_device_4k_capable():\n\"\"\"Check if the device is 4k capable\"\"\"\n# Currently only on android is it possible to use 4K\nif get_system_platform() == 'android':\n- from re import findall\nfrom resources.lib.database.db_utils import TABLE_SESSION\n# Check if the drm has security level L1\nis_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+ hdcp_level = get_hdcp_level()\n+ hdcp_4k_capable = hdcp_level and hdcp_level >= 2.2\nreturn is_drm_l1_security_level and hdcp_4k_capable\nreturn False\n+def get_hdcp_level():\n+ \"\"\"Get the HDCP level when exist else None\"\"\"\n+ from re import findall\n+ from resources.lib.database.db_utils import TABLE_SESSION\n+ drm_hdcp_level = findall('\\\\d+\\\\.\\\\d+', g.LOCAL_DB.get_value('drm_hdcp_level', '', table=TABLE_SESSION))\n+ return float(drm_hdcp_level[0]) if drm_hdcp_level else None\n+\n+\ndef get_user_agent(enable_android_mediaflag_fix=False):\n\"\"\"\nDetermines the user agent string for the current platform.\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add get hdcp level
106,046
14.03.2020 15:50:09
-3,600
5a21f2eb50d0ae07d54e0c7a3c4f24f13928b997
Fixed wrong backslash and double quote escape Cause of error: ValueError: Invalid \escape: line 1 column 7891 (char 7890) WebsiteParsingError: Unable to extract reactContext Due to backslash in the profile name
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -309,12 +309,13 @@ def extract_json(content, name):\ntry:\njson_array = recompile(JSON_REGEX.format(name), DOTALL).findall(content.decode('utf-8'))\njson_str = json_array[0]\n- json_str = json_str.replace('\\\"', '\\\\\"') # Escape double-quotes\n- json_str = json_str.replace('\\\\s', '\\\\\\\\s') # Escape \\s\n- json_str = json_str.replace('\\\\n', '\\\\\\\\n') # Escape line feed\n- json_str = json_str.replace('\\\\t', '\\\\\\\\t') # Escape tab\n- json_str = json_str.encode().decode('unicode_escape') # finally decoding...\n- return json.loads(json_str)\n+ json_str_replace = json_str.replace('\\\\\"', '\\\\\\\\\"') # Escape double-quotes\n+ json_str_replace = json_str_replace.replace('\\\\s', '\\\\\\\\s') # Escape \\s\n+ json_str_replace = json_str_replace.replace('\\\\n', '\\\\\\\\n') # Escape line feed\n+ json_str_replace = json_str_replace.replace('\\\\t', '\\\\\\\\t') # Escape tab\n+ json_str_replace = json_str_replace.encode().decode('unicode_escape') # Decode the string as unicode\n+ json_str_replace = sub(r'\\\\(?![\"])', r'\\\\\\\\', json_str_replace) # Escape backslash (only when is not followed by double quotation marks \\\")\n+ return json.loads(json_str_replace)\nexcept Exception:\nif json_str:\ncommon.error('JSON string trying to load: {}', json_str)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed wrong backslash and double quote escape Cause of error: ValueError: Invalid \escape: line 1 column 7891 (char 7890) WebsiteParsingError: Unable to extract reactContext Due to backslash in the profile name
106,046
14.03.2020 17:51:36
-3,600
cd9b3866ec2c5908247f967369891ced6f18bb87
Updated some info
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -75,8 +75,10 @@ def extract_session_data(content, validate=False):\nuser_data = extract_userdata(react_context)\nif 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+ # Possible known causes:\n+ # -Login password has been changed\n+ # -Expired profiles cookies!? (not verified)\n+ # In these cases it is mandatory to login again\nraise InvalidMembershipStatusAnonymous\nif user_data.get('membershipStatus') != 'CURRENT_MEMBER':\n# When NEVER_MEMBER it is possible that the account has not been confirmed or renewed\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -121,9 +121,11 @@ class NFSessionRequests(NFSessionBase):\nexcept (WebsiteParsingError, InvalidMembershipStatusAnonymous) as exc:\n# Possible known causes:\n# -Cookies may not work anymore most likely due to updates in the website\n+ # -Login password has been changed\n# -Expired cookie profiles? might cause InvalidMembershipStatusAnonymous (i am not really sure)\nimport traceback\n- common.warn('Failed to refresh session data, login can be expired ({})', type(exc).__name__)\n+ common.warn('Failed to refresh session data, login can be expired or the password has been changed ({})',\n+ type(exc).__name__)\ncommon.debug(traceback.format_exc())\nself.session.cookies.clear()\nif isinstance(exc, InvalidMembershipStatusAnonymous):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated some info
106,046
14.03.2020 18:52:01
-3,600
0e1b0beae787cc4a6db126cbba7abd9d4230be6d
Fixed settings type error
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/device_utils.py", "new_path": "resources/lib/common/device_utils.py", "diff": "@@ -82,7 +82,7 @@ def is_device_4k_capable():\n# Check if HDCP level is 2.2 or up\nhdcp_level = get_hdcp_level()\nhdcp_4k_capable = hdcp_level and hdcp_level >= 2.2\n- return is_drm_l1_security_level and hdcp_4k_capable\n+ return bool(is_drm_l1_security_level and hdcp_4k_capable)\nreturn False\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed settings type error
106,046
14.03.2020 21:00:17
-3,600
059fa3a713a66572e043524f78ed60034bb5097f
Fixed debug cookie info
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/cookies.py", "new_path": "resources/lib/common/cookies.py", "diff": "@@ -58,12 +58,12 @@ def delete(account_hash):\ndef load(account_hash):\n\"\"\"Load cookies for a given account and check them for validity\"\"\"\nfilename = cookie_filename(account_hash)\n- common.debug('Loading cookies from {}', filename)\nif not xbmcvfs.exists(xbmc.translatePath(filename)):\ncommon.debug('Cookies file does not exist')\nraise MissingCookiesError()\n- try:\n+ common.debug('Loading cookies from {}', filename)\ncookie_file = xbmcvfs.File(filename, 'rb')\n+ try:\nif g.PY_IS_VER2:\n# pickle.loads on py2 wants string\ncookie_jar = pickle.loads(cookie_file.read())\n@@ -81,26 +81,21 @@ def load(account_hash):\ncookie_jar.clear(domain='.netflix.com', path='/', name='flwssn')\nexcept KeyError:\npass\n+ log_cookie(cookie_jar)\n+ return cookie_jar\n- debug_output = 'Loaded cookies:\\n'\n+\n+def log_cookie(cookie_jar):\n+ \"\"\"Print cookie info to the log\"\"\"\n+ if not common.is_debug_verbose():\n+ return\n+ debug_output = 'Cookies currently loaded:\\n'\nfor cookie in cookie_jar:\n- remaining_ttl = ((cookie.expires or 0) - time() / 60) if cookie.expires else None\n- debug_output += '{} (expires {} - remaining TTL {})\\n'.format(cookie.name,\n+ remaining_ttl = int((cookie.expires or 0) - time()) if cookie.expires else None\n+ debug_output += '{} (expires ts {} - remaining TTL {} sec)\\n'.format(cookie.name,\ncookie.expires,\nremaining_ttl)\ncommon.debug(debug_output)\n- # if expired(cookie_jar):\n- # raise CookiesExpiredError()\n- return cookie_jar\n-\n-\n-def expired(cookie_jar):\n- \"\"\"Check if one of the cookies in the jar is already expired\"\"\"\n- earliest_expiration = 99999999999999999999\n- for cookie in cookie_jar:\n- if cookie.expires is not None:\n- earliest_expiration = min(int(cookie.expires), earliest_expiration)\n- return int(time()) > earliest_expiration\ndef cookie_filename(account_hash):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_base.py", "new_path": "resources/lib/services/nfsession/nfsession_base.py", "diff": "@@ -74,6 +74,7 @@ class NFSessionBase(object):\ndef update_session_data(self, old_esn=None):\nself.set_session_header_data()\ncookies.save(self.account_hash, self.session.cookies)\n+ cookies.log_cookie(self.session.cookies)\n_update_esn(g.get_esn() if old_esn is None else old_esn)\ndef set_session_header_data(self):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed debug cookie info
106,046
15.03.2020 13:07:05
-3,600
bc248b8f495360a0ac6b665384077f7e80f47307
Moved time import and comments
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/data_conversion.py", "new_path": "resources/lib/common/data_conversion.py", "diff": "@@ -11,12 +11,9 @@ from __future__ import absolute_import, division, unicode_literals\nimport datetime\nimport json\n-import time\nfrom ast import literal_eval\nfrom collections import OrderedDict\n-# Workaround for http://bugs.python.org/issue8098 only to py2 caused by _conv_string_to_datetime()\n-# Error: ImportError: Failed to import _strptime because the import lockis held by another thread.\n-import _strptime # pylint: disable=unused-import\n+\nfrom .logging import error\n@@ -87,4 +84,8 @@ def _conv_string_to_datetime(value):\nreturn datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S.%f')\nexcept TypeError:\n# Python bug https://bugs.python.org/issue27400\n+ import time\n+ # Workaround for http://bugs.python.org/issue8098 only to py2\n+ # Error: ImportError: Failed to import _strptime because the import lockis held by another thread.\n+ import _strptime # pylint: disable=unused-import\nreturn datetime.datetime(*(time.strptime(value, '%Y-%m-%d %H:%M:%S.%f')[0:6]))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -110,6 +110,7 @@ def strp(value, form):\ntry:\nreturn datetime.strptime(value, form)\nexcept TypeError:\n+ # Python bug https://bugs.python.org/issue27400\ntry:\nfrom time import strptime\nreturn datetime(*(strptime(value, form)[0:6]))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Moved time import and comments
106,046
16.03.2020 15:40:49
-3,600
af542fbdf99842e268d4c4edb19fcdb86411f3fa
Try to do a more robust check for external calls
[ { "change_type": "MODIFY", "old_path": "resources/lib/cache.py", "new_path": "resources/lib/cache.py", "diff": "@@ -96,7 +96,7 @@ 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+ if save_call_data and not g.IS_ADDON_EXTERNAL_CALL:\ng.LOCAL_DB.set_value('cache_last_directory_call',\n{'bucket': bucket, 'identifier': identifier, 'to_disk': to_disk},\ntable=TABLE_SESSION)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -196,7 +196,7 @@ class GlobalVariables(object):\nmodule level if reusing a language invoker.\"\"\"\n# IS_ADDON_FIRSTRUN specifies when the addon is at its first run (reuselanguageinvoker is not yet used)\nself.IS_ADDON_FIRSTRUN = self.IS_ADDON_FIRSTRUN is None\n- self.IS_SKIN_CALL = False\n+ self.IS_ADDON_EXTERNAL_CALL = False\nself.PY_IS_VER2 = sys.version_info.major == 2\nself.COOKIES = {}\nself.ADDON = xbmcaddon.Addon()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -75,7 +75,7 @@ def play(videoid):\nresume_position = {}\nevent_data = {}\n- if g.IS_SKIN_CALL:\n+ if g.IS_ADDON_EXTERNAL_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@@ -92,7 +92,7 @@ def play(videoid):\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- event_data['is_played_by_library'] = g.IS_SKIN_CALL\n+ event_data['is_played_by_library'] = g.IS_ADDON_EXTERNAL_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" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -10,7 +10,7 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\n-from xbmc import getCondVisibility, Monitor\n+from xbmc import getCondVisibility, Monitor, getInfoLabel\nfrom xbmcgui import Window\nfrom resources.lib.globals import g\n@@ -68,23 +68,33 @@ def route(pathitems):\nexecute(_get_nav_handler(root_handler), pathitems[1:], g.REQUEST_PARAMS)\n-def _skin_widget_call(window_cls, prop_nf_service_status):\n- \"\"\"\n- Workaround to intercept calls made by the Skin Widgets currently in use.\n- Currently, the Skin widgets associated with add-ons are executed at Kodi startup immediately\n- without respecting any services needed by the add-ons. This is causing different\n- kinds of problems like widgets not loaded, add-on warning message, etc...\n- this loop freeze the add-on instance until the service is ready.\n- \"\"\"\n- # Note to \"Window.IsMedia\":\n+def _check_addon_external_call(window_cls, prop_nf_service_status):\n+ \"\"\"Check system to verify if the calls to the add-on are originated externally\"\"\"\n+ # The calls that are made from outside do not respect and do not check whether the services required\n+ # for the add-on are actually working and operational, causing problems with the execution of the frontend.\n+\n+ # A clear example are the Skin widgets, that are executed at Kodi startup immediately and this is cause of different\n+ # kinds of problems like widgets not loaded, add-on warning message, etc...\n+\n+ # Cases where it can happen:\n+ # - Calls made by the Skin Widgets, Scripts, Kodi library\n+ # - Calls made by others Kodi windows (like file browser)\n+ # - Calls made by other add-ons (not verified yet)\n+\n+ # To try to solve the problem, when the service is not ready a loop will be started to freeze the add-on instance\n+ # until the service will be ready.\n+\n+ is_other_plugin_name = getInfoLabel('Container.PluginName') != g.ADDON.getAddonInfo('id')\n+ limit_sec = 10\n+\n+ # Note to Kodi boolean condition \"Window.IsMedia\":\n# All widgets will be either on Home or in a Custom Window, so \"Window.IsMedia\" will be false\n# When the user is browsing the plugin, Window.IsMedia will be true because video add-ons open\n# in MyVideoNav.xml (which is a Media window)\n# This is not a safe solution, because DEPENDS ON WHICH WINDOW IS OPEN,\n# for example it can fail if you open add-on video browser while widget is still loading.\n# Needed a proper solution by script.skinshortcuts / script.skin.helper.service, and forks\n- limit_sec = 10\n- if not getCondVisibility(\"Window.IsMedia\"):\n+ if is_other_plugin_name or not getCondVisibility(\"Window.IsMedia\"):\nmonitor = Monitor()\nsec_elapsed = 0\nwhile not window_cls.getProperty(prop_nf_service_status) == 'running':\n@@ -92,7 +102,7 @@ def _skin_widget_call(window_cls, prop_nf_service_status):\nbreak\nsec_elapsed += 0.5\ndebug('Skin widget workaround enabled - time elapsed: {}', sec_elapsed)\n- g.IS_SKIN_CALL = True\n+ g.IS_ADDON_EXTERNAL_CALL = True\nreturn True\nreturn False\n@@ -152,10 +162,10 @@ def run(argv):\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())\n- is_widget_skin_call = _skin_widget_call(window_cls, prop_nf_service_status)\n+ is_external_call = _check_addon_external_call(window_cls, prop_nf_service_status)\nif window_cls.getProperty(prop_nf_service_status) != 'running':\n- if not is_widget_skin_call:\n+ if not is_external_call:\nfrom resources.lib.kodi.ui import show_backend_not_ready\nshow_backend_not_ready()\nsuccess = False\n@@ -167,7 +177,7 @@ def run(argv):\nif check_addon_upgrade():\nfrom resources.lib.config_wizard import run_addon_configuration\nrun_addon_configuration()\n- if not is_widget_skin_call:\n+ if not is_external_call:\nupdate_cache_videoid_runtime(window_cls)\nroute([part for part in g.PATH.split('/') if part])\nelse:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Try to do a more robust check for external calls
106,046
16.03.2020 18:54:50
-3,600
94080f15ac7e15fcbcf78ff8d92eaf02869c0ce8
Fixed attribute error and unicode decode issue
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_items.py", "new_path": "resources/lib/kodi/library_items.py", "diff": "@@ -34,16 +34,12 @@ class ItemNotFound(Exception):\[email protected]_execution(immediate=False)\ndef get_item(videoid):\n- \"\"\"Find an item in the Kodi library by its Netflix videoid and return\n- Kodi DBID and mediatype\"\"\"\n- # pylint: disable=broad-except\n+ \"\"\"Find an item in the Kodi library by its Netflix videoid and return Kodi DBID and mediatype\"\"\"\ntry:\nfile_path, media_type = _get_library_entry(videoid)\nreturn _get_item(media_type, file_path)\n- except (KeyError, AttributeError, IndexError, ItemNotFound):\n- raise ItemNotFound(\n- 'The video with id {} is not present in the Kodi library'\n- .format(videoid))\n+ except (KeyError, IndexError, ItemNotFound):\n+ raise ItemNotFound('The video with id {} is not present in the Kodi library'.format(videoid))\[email protected]_execution(immediate=False)\n@@ -75,10 +71,10 @@ def _get_library_entry(videoid):\ndef _get_item(mediatype, filename):\n# To ensure compatibility with previously exported items,\n# make the filename legal\n- fname = xbmc.makeLegalFilename(filename).decode(\"utf-8\")\n- untranslated_path = os.path.dirname(fname)\n- translated_path = os.path.dirname(xbmc.translatePath(fname).decode(\"utf-8\"))\n- shortname = os.path.basename(xbmc.translatePath(fname).decode(\"utf-8\"))\n+ fname = xbmc.makeLegalFilename(filename)\n+ untranslated_path = os.path.dirname(g.py2_decode(fname))\n+ translated_path = os.path.dirname(g.py2_decode(xbmc.translatePath(fname)))\n+ shortname = os.path.basename(g.py2_decode(xbmc.translatePath(fname)))\n# We get the data from Kodi library using filters.\n# This is much faster than loading all episodes in memory\n@@ -110,7 +106,7 @@ def get_previously_exported_items():\nvideoid_pattern = re.compile('video_id=(\\\\d+)')\nfor folder in _lib_folders(FOLDER_MOVIES) + _lib_folders(FOLDER_TV):\nfor filename in xbmcvfs.listdir(folder)[1]:\n- filepath = xbmc.makeLegalFilename('/'.join([folder, filename])).decode('utf-8')\n+ filepath = g.py2_decode(xbmc.makeLegalFilename('/'.join([folder, filename])))\nif filepath.endswith('.strm'):\ncommon.debug('Trying to migrate {}', filepath)\ntry:\n@@ -128,9 +124,8 @@ def get_previously_exported_items():\ndef _lib_folders(section):\n- section_dir = xbmc.translatePath(\n- xbmc.makeLegalFilename('/'.join([library_path(), section])))\n- return [xbmc.makeLegalFilename('/'.join([section_dir, folder.decode('utf-8')]))\n+ section_dir = g.py2_decode(xbmc.translatePath(xbmc.makeLegalFilename('/'.join([library_path(), section]))))\n+ return [g.py2_decode(xbmc.makeLegalFilename('/'.join([section_dir, folder.decode('utf-8')])))\nfor folder\nin xbmcvfs.listdir(section_dir)[0]]\n@@ -213,22 +208,21 @@ def remove_item(item_task, library_home=None):\ncommon.info('Removing {} from library', item_task['title'])\n- exported_filename = xbmc.translatePath(item_task['filepath'])\n+ exported_filename = g.py2_decode(xbmc.translatePath(item_task['filepath']))\nvideoid = item_task['videoid']\ncommon.debug('VideoId: {}', videoid)\ntry:\n- parent_folder = xbmc.translatePath(os.path.dirname(exported_filename))\n+ parent_folder = g.py2_decode(xbmc.translatePath(os.path.dirname(exported_filename)))\nif xbmcvfs.exists(exported_filename):\nxbmcvfs.delete(exported_filename)\nelse:\n- common.warn('Cannot delete {}, file does not exist', g.py2_decode(exported_filename))\n+ common.warn('Cannot delete {}, file does not exist', exported_filename)\n# Remove the NFO files if exists\n- nfo_file = os.path.splitext(g.py2_decode(exported_filename))[0] + '.nfo'\n+ nfo_file = os.path.splitext(exported_filename)[0] + '.nfo'\nif xbmcvfs.exists(nfo_file):\nxbmcvfs.delete(nfo_file)\ndirs, files = xbmcvfs.listdir(parent_folder)\n- tvshow_nfo_file = xbmc.makeLegalFilename(\n- '/'.join([g.py2_decode(parent_folder), 'tvshow.nfo']))\n+ tvshow_nfo_file = g.py2_decode(xbmc.makeLegalFilename('/'.join([parent_folder, 'tvshow.nfo'])))\n# Remove tvshow_nfo_file only when is the last file\n# (users have the option of removing even single seasons)\nif xbmcvfs.exists(tvshow_nfo_file) and not dirs and len(files) == 1:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed attribute error and unicode decode issue
106,046
16.03.2020 19:06:04
-3,600
117ed07dd29d5356083a0f085f1040fcb48ed0c1
Add delay on refresh after remove item from library I have noticed that in some cases, when remove an exported tv show, after the refresh the items of the page are not updated so the deleted item remain in the page add a delay of 1 second seem to fix the issue
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -108,8 +108,14 @@ def scan_library(path=\"\"):\nreturn json_rpc(method, params)\n-def refresh_container():\n+def refresh_container(use_delay=False):\n\"\"\"Refresh the current container\"\"\"\n+ if use_delay:\n+ # When operations are performed in the Kodi library before call this method\n+ # can be necessary to apply a delay before run the refresh, otherwise the page does not refresh correctly\n+ # seems to be caused by a race condition with the Kodi library update (but i am not really sure)\n+ from time import sleep\n+ sleep(1)\nxbmc.executebuiltin('Container.Refresh')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -42,7 +42,7 @@ class LibraryActionExecutor(object):\nlibrary.execute_library_tasks(videoid,\n[library.remove_item],\ncommon.get_local_string(30030))\n- common.refresh_container()\n+ common.refresh_container(use_delay=True)\[email protected]_video_id(path_offset=1)\ndef update(self, videoid):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add delay on refresh after remove item from library I have noticed that in some cases, when remove an exported tv show, after the refresh the items of the page are not updated so the deleted item remain in the page add a delay of 1 second seem to fix the issue
106,046
16.03.2020 20:55:43
-3,600
c36f4d5e22db1fd10fa08d352d2b8096b06a6eff
Fixed language id for kodi 19
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/dialogs.py", "new_path": "resources/lib/kodi/ui/dialogs.py", "diff": "@@ -100,7 +100,7 @@ def ask_for_resume(resume_position):\nreturn xbmcgui.Dialog().contextmenu(\n[\ncommon.get_local_string(12022).format(common.convert_seconds_to_hms_str(resume_position)),\n- common.get_local_string(12023)\n+ common.get_local_string(12023 if '18.' in common.GetKodiVersion().version else 12021)\n])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed language id for kodi 19
106,046
17.03.2020 13:39:39
-3,600
5462b17df0c057ed75c39dc7da3ec29df31e7e46
Removed 'XBMC.' prefix in built-in command
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -128,7 +128,7 @@ def get_local_string(string_id):\ndef run_plugin_action(path, block=False):\n\"\"\"Create an action that can be run with xbmc.executebuiltin in order to run a Kodi plugin specified by path.\nIf block is True (default=False), the execution of code will block until the called plugin has finished running.\"\"\"\n- return 'XBMC.RunPlugin({}, {})'.format(path, block)\n+ return 'RunPlugin({}, {})'.format(path, block)\ndef run_plugin(path, block=False):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Removed 'XBMC.' prefix in built-in command
106,046
17.03.2020 17:54:31
-3,600
78b2d04e78e9ab48b56fca3daf582465c62d0b80
Fix wrong tick count reset This fix the interruption of sending video status progress after video pause or seek
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/progress_manager.py", "new_path": "resources/lib/services/playback/progress_manager.py", "diff": "@@ -71,7 +71,7 @@ class ProgressManager(PlaybackActionManager):\ndef on_playback_pause(self, player_state):\nif not self.is_event_start_sent:\nreturn\n- self.tick_elapsed = 0\n+ self._reset_tick_count()\nself.is_player_in_pause = True\n_send_event(EVENT_ENGAGE, self.event_data, player_state)\n@@ -83,14 +83,14 @@ class ProgressManager(PlaybackActionManager):\nif not self.is_event_start_sent or self.lock_events:\n# This might happen when ResumeManager skip is performed\nreturn\n- self.tick_elapsed = 0\n+ self._reset_tick_count()\n_send_event(EVENT_ENGAGE, self.event_data, player_state)\nself._save_resume_time(player_state['elapsed_seconds'])\ndef _on_playback_stopped(self):\nif not self.is_event_start_sent or self.lock_events:\nreturn\n- self.tick_elapsed = 0\n+ self._reset_tick_count()\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@@ -107,6 +107,10 @@ class ProgressManager(PlaybackActionManager):\n# The callback _on_playback_stopped can not be used, because the loading of frontend happen before.\nself.window_cls.setProperty('nf_playback_resume_time', str(resume_time))\n+ def _reset_tick_count(self):\n+ self.tick_elapsed = 0\n+ self.last_tick_count = 0\n+\ndef _send_event(event_type, event_data, player_state):\nif not player_state:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix wrong tick count reset This fix the interruption of sending video status progress after video pause or seek
106,046
18.03.2020 17:51:27
-3,600
a091203516f633db0137166bdea32c469c3e1bcb
Use a common variable for msl data filename
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/base_crypto.py", "new_path": "resources/lib/services/msl/base_crypto.py", "diff": "@@ -14,6 +14,7 @@ import base64\nimport time\nimport resources.lib.common as common\n+from resources.lib.services.msl.msl_utils import MSL_DATA_FILENAME\nclass MSLBaseCrypto(object):\n@@ -75,7 +76,7 @@ class MSLBaseCrypto(object):\n\"\"\"Save crypto keys and mastertoken to disk\"\"\"\nself._msl_data['tokens'] = {'mastertoken': self.mastertoken}\nself._msl_data.update(self._export_keys())\n- common.save_file('msl_data.json', json.dumps(self._msl_data).encode('utf-8'))\n+ common.save_file(MSL_DATA_FILENAME, 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/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -21,7 +21,7 @@ from resources.lib.globals import g\nfrom .converter import convert_to_dash\nfrom .events_handler import EventsHandler\nfrom .msl_requests import MSLRequests\n-from .msl_utils import ENDPOINTS, display_error_info\n+from .msl_utils import ENDPOINTS, display_error_info, MSL_DATA_FILENAME\nfrom .profiles import enabled_profiles\ntry: # Python 2\n@@ -41,7 +41,7 @@ class MSLHandler(object):\nsuper(MSLHandler, self).__init__()\nself.msl_requests = None\ntry:\n- msl_data = json.loads(common.load_file('msl_data.json'))\n+ msl_data = json.loads(common.load_file(MSL_DATA_FILENAME))\ncommon.info('Loaded MSL data from disk')\nexcept Exception: # pylint: disable=broad-except\nmsl_data = None\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_requests.py", "new_path": "resources/lib/services/msl/msl_requests.py", "diff": "@@ -22,7 +22,8 @@ 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, generate_logblobs_params, EVENT_BIND, ENDPOINTS\n+from resources.lib.services.msl.msl_utils import (display_error_info, generate_logblobs_params, EVENT_BIND, ENDPOINTS,\n+ MSL_DATA_FILENAME)\ntry: # Python 2\nfrom urllib import urlencode\n@@ -114,7 +115,7 @@ class MSLRequests(MSLRequestBuilder):\ndebug_msg = 'Stored MSL data is expired, a new key handshake will be performed'\ncommon.debug(debug_msg)\nif self.perform_key_handshake():\n- msl_data = json.loads(common.load_file('msl_data.json'))\n+ msl_data = json.loads(common.load_file(MSL_DATA_FILENAME))\nself.crypto.load_msl_data(msl_data)\nself.crypto.load_crypto_session(msl_data)\nreturn self._check_mastertoken_validity()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_utils.py", "new_path": "resources/lib/services/msl/msl_utils.py", "diff": "@@ -37,6 +37,8 @@ ENDPOINTS = {\n'logblobs': CHROME_BASE_URL + 'pbo_logblobs/%5E1.0.0/router'\n}\n+MSL_DATA_FILENAME = 'msl_data.json'\n+\nEVENT_START = 'start' # events/start : Video starts\nEVENT_STOP = 'stop' # events/stop : Video stops\nEVENT_KEEP_ALIVE = 'keepAlive' # events/keepAlive : Update progress status\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Use a common variable for msl data filename
106,046
18.03.2020 18:34:37
-3,600
ac70ac84b09607182402c24fc811e257ca10bcbc
Reinitialize MSL handler when logout After logout the mastertoken and useridtokens must be deleted together with the esn used
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/ipc.py", "new_path": "resources/lib/common/ipc.py", "diff": "@@ -38,6 +38,7 @@ class Signals(object): # pylint: disable=no-init\nINVALIDATE_SERVICE_CACHE = 'invalidate_service_cache'\nQUEUE_VIDEO_EVENT = 'queue_video_event'\nCLEAR_USER_ID_TOKENS = 'clean_user_id_tokens'\n+ REINITIALIZE_MSL_HANDLER = 'reinitialize_msl_handler'\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": "@@ -39,6 +39,21 @@ class MSLHandler(object):\ndef __init__(self):\nsuper(MSLHandler, self).__init__()\n+ self._init_msl_handler()\n+ common.register_slot(\n+ signal=common.Signals.ESN_CHANGED,\n+ callback=self.msl_requests.perform_key_handshake)\n+ common.register_slot(\n+ signal=common.Signals.RELEASE_LICENSE,\n+ callback=self.release_license)\n+ common.register_slot(\n+ signal=common.Signals.CLEAR_USER_ID_TOKENS,\n+ callback=self.clear_user_id_tokens)\n+ common.register_slot(\n+ signal=common.Signals.REINITIALIZE_MSL_HANDLER,\n+ callback=self.reinitialize_msl_handler)\n+\n+ def _init_msl_handler(self):\nself.msl_requests = None\ntry:\nmsl_data = json.loads(common.load_file(MSL_DATA_FILENAME))\n@@ -47,18 +62,17 @@ class MSLHandler(object):\nmsl_data = None\nself.msl_requests = MSLRequests(msl_data)\n-\nEventsHandler(self.msl_requests.chunked_request).start()\n- common.register_slot(\n- signal=common.Signals.ESN_CHANGED,\n- callback=self.msl_requests.perform_key_handshake)\n- common.register_slot(\n- signal=common.Signals.RELEASE_LICENSE,\n- callback=self.release_license)\n- common.register_slot(\n- signal=common.Signals.CLEAR_USER_ID_TOKENS,\n- callback=self.clear_user_id_tokens)\n+ def reinitialize_msl_handler(self, data=None): # pylint: disable=unused-argument\n+ \"\"\"\n+ Reinitialize the MSL handler\n+ :param data: set True for delete the msl file data, and then reset all\n+ \"\"\"\n+ common.debug('Reinitializing MSL handler')\n+ if data is True:\n+ common.delete_file(MSL_DATA_FILENAME)\n+ self._init_msl_handler()\n@display_error_info\[email protected]_execution(immediate=True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -18,6 +18,7 @@ import resources.lib.common as common\nimport resources.lib.common.cookies as cookies\nimport resources.lib.api.website as website\nimport resources.lib.kodi.ui as ui\n+from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom resources.lib.services.nfsession.nfsession_requests import NFSessionRequests\nfrom resources.lib.services.nfsession.nfsession_cookie import NFSessionCookie\n@@ -144,10 +145,17 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ng.settings_monitor_suspend(False)\n# Delete cookie and credentials\n- cookies.delete(self.account_hash)\nself._get('logout')\n+ self.session.cookies.clear()\n+ cookies.delete(self.account_hash)\ncommon.purge_credentials()\n+ # Reset the ESN obtained from website/generated\n+ g.LOCAL_DB.set_value('esn', '', TABLE_SESSION)\n+\n+ # Reinitialize the MSL handler (delete msl data file, then reset everything)\n+ common.send_signal(signal=common.Signals.REINITIALIZE_MSL_HANDLER, data=True)\n+\ncommon.info('Logout successful')\nui.show_notification(common.get_local_string(30113))\nself._init_session()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Reinitialize MSL handler when logout After logout the mastertoken and useridtokens must be deleted together with the esn used
106,046
18.03.2020 18:42:19
-3,600
f0a81d15c3184e209b7f54c295a5f83f1a7afc3c
Execute the website logout first, to avoid changes in case of error
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -130,6 +130,9 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\n\"\"\"Logout of the current account and reset the session\"\"\"\ncommon.debug('Logging out of current account')\n+ # Perform the website logout\n+ self._get('logout')\n+\ng.settings_monitor_suspend(True)\n# Disable and reset auto-update / auto-sync features\n@@ -145,7 +148,6 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ng.settings_monitor_suspend(False)\n# Delete cookie and credentials\n- self._get('logout')\nself.session.cookies.clear()\ncookies.delete(self.account_hash)\ncommon.purge_credentials()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Execute the website logout first, to avoid changes in case of error
106,046
20.03.2020 19:53:50
-3,600
4fc89b2eec7a4177627b4833d0e9133185174de3
Version bump (1.1.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=\"1.0.0\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"1.1.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-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+v1.1.0 (2020-03-20)\n+-Added more supplemental info to plot info\n+-Added customizable color to suppl. plot info\n+-Added Greek language\n+-Added more results to recommendations menu\n+-Improved auto-login feature (now called \"profile auto-selection\")\n+-Improved password request in particular circumstances\n+-Improvements to recognize external calls to add-on\n+-Fixed msl issues with login with different account after a logout\n+-Fixed an issue in the strm resume workaround\n+-Fixed an issue caused broken configuration wizard on L1 android devices\n+-Fixed an issue which prevented the loading of profile list with a backslash on the names\n+-Fixed an issue which prevented the loading of suppl. info to plot info\n+-Fixed an issue caused interruption of sending video status progress after video pause or seek\n+-Updated it, de, nl translations\n+-Other minor fixes\n</news>\n</extension>\n</addon>\n" }, { "change_type": "MODIFY", "old_path": "changelog.txt", "new_path": "changelog.txt", "diff": "+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+\nv0.16.4 (2020-01-28)\n-Up Next is now supported only from version 1.1.0 and up\n-Added czech language\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (1.1.0)
106,046
21.03.2020 17:27:47
-3,600
c48f83f4a23f050eecceb213bd517e0d4f7e14c5
Use localhost instead force IPv4 loopback
[ { "change_type": "MODIFY", "old_path": "resources/lib/run_service.py", "new_path": "resources/lib/run_service.py", "diff": "@@ -59,7 +59,7 @@ class NetflixService(object):\ndef init_server(self, server):\nserver['class'].allow_reuse_address = True\nserver['instance'] = server['class'](\n- ('127.0.0.1', select_port(server['name'])))\n+ ('localhost', select_port(server['name'])))\nserver['thread'] = threading.Thread(\ntarget=server['instance'].serve_forever)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Use localhost instead force IPv4 loopback
106,046
21.03.2020 18:14:25
-3,600
d0e5e552ebf3eb5d948a14c6402dba52348ee7a1
Fixed unicode decode error
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -36,7 +36,7 @@ class AddonActionExecutor(object):\ng.ADDON.setSetting('autoselect_profile_name', self.params['profile_name'])\ng.ADDON.setSettingBool('autoselect_profile_enabled', True)\ng.settings_monitor_suspend(False)\n- ui.show_notification(common.get_local_string(30058).format(self.params['profile_name']))\n+ ui.show_notification(common.get_local_string(30058).format(g.py2_decode(self.params['profile_name'])))\ndef autoselect_profile_remove(self, pathitems): # pylint: disable=unused-argument\n\"\"\"Remove the auto-selection set\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed unicode decode error
106,046
24.03.2020 14:36:05
-3,600
e3870c638293c65c53b85372874143e8152097cd
Avoid mix the params variable Has caused continuous profile switch when navigate between directories due to same param name in listings.py get_param_watched_status_by_profile
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/listings.py", "new_path": "resources/lib/kodi/listings.py", "diff": "@@ -105,7 +105,7 @@ def _create_profile_item(profile_guid, is_active, html_parser):\nlist_item.addContextMenuItems([(common.get_local_string(30056),\n'RunPlugin({})'.format(autoselect_profile_url))])\nurl = common.build_url(pathitems=['home'],\n- params={'profile_guid': profile_guid},\n+ params={'switch_profile_guid': profile_guid},\nmode=g.MODE_DIRECTORY)\nreturn (url, list_item, True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -39,8 +39,8 @@ class DirectoryBuilder(object):\nif self.perpetual_range_start == '0':\n# For cache identifier purpose\nself.perpetual_range_start = None\n- if 'profile_guid' in params:\n- api.activate_profile(params['profile_guid'])\n+ if 'switch_profile_guid' in params:\n+ api.activate_profile(params['switch_profile_guid'])\ndef root(self, pathitems=None):\n\"\"\"Show profiles or home listing when profile auto-selection is enabled\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Avoid mix the params variable Has caused continuous profile switch when navigate between directories due to same param name in listings.py get_param_watched_status_by_profile
106,046
24.03.2020 14:41:38
-3,600
cdbe616add64c178a489633f9c110d145c1e9e22
Version bump (1.1.1)
[ { "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=\"1.1.0\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"1.1.1\" 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-v1.1.0 (2020-03-20)\n--Added more supplemental info to plot info\n--Added customizable color to suppl. plot info\n--Added Greek language\n--Added more results to recommendations menu\n--Improved auto-login feature (now called \"profile auto-selection\")\n--Improved password request in particular circumstances\n--Improvements to recognize external calls to add-on\n--Fixed msl issues with login with different account after a logout\n--Fixed an issue in the strm resume workaround\n--Fixed an issue caused broken configuration wizard on L1 android devices\n--Fixed an issue which prevented the loading of profile list with a backslash on the names\n--Fixed an issue which prevented the loading of suppl. info to plot info\n--Fixed an issue caused interruption of sending video status progress after video pause or seek\n--Updated it, de, nl translations\n--Other minor fixes\n+v1.1.1 (2020-03-24)\n+-Fixed critical bug caused continuous profile switching\n+-Fixed unicode decode error to profile auto-selection\n</news>\n</extension>\n</addon>\n" }, { "change_type": "MODIFY", "old_path": "changelog.txt", "new_path": "changelog.txt", "diff": "+v1.1.0 (2020-03-20)\n+-Added more supplemental info to plot info\n+-Added customizable color to suppl. plot info\n+-Added Greek language\n+-Added more results to recommendations menu\n+-Improved auto-login feature (now called \"profile auto-selection\")\n+-Improved password request in particular circumstances\n+-Improvements to recognize external calls to add-on\n+-Fixed msl issues with login with different account after a logout\n+-Fixed an issue in the strm resume workaround\n+-Fixed an issue caused broken configuration wizard on L1 android devices\n+-Fixed an issue which prevented the loading of profile list with a backslash on the names\n+-Fixed an issue which prevented the loading of suppl. info to plot info\n+-Fixed an issue caused interruption of sending video status progress after video pause or seek\n+-Updated it, de, nl translations\n+-Other minor fixes\n+\nv1.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" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (1.1.1)
106,046
27.03.2020 10:00:40
-3,600
d37dc34b2972b8a2e43adaf138e07fa176c478b5
Changes to Kodi python APIs for Kodi 19
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_tasks.py", "new_path": "resources/lib/kodi/library_tasks.py", "diff": "@@ -38,8 +38,7 @@ def execute_tasks(title, tasks, task_handler, **kwargs):\nprogress.create(title)\nfor task_num, task in enumerate(tasks):\ntask_title = task.get('title', 'Unknown Task')\n- progress.update(percent=int(task_num * 100 / len(tasks)),\n- line1=task_title)\n+ progress.update(int(task_num * 100 / len(tasks)), task_title)\n# xbmc.sleep(25)\nif progress.iscanceled():\nbreak\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/dialogs.py", "new_path": "resources/lib/kodi/ui/dialogs.py", "diff": "@@ -92,7 +92,7 @@ def ask_for_removal_confirmation():\ndef ask_for_confirmation(title, message):\n\"\"\"Ask the user to confirm an operation\"\"\"\n- return xbmcgui.Dialog().yesno(heading=title, line1=message)\n+ return xbmcgui.Dialog().yesno(title, message)\ndef ask_for_resume(resume_position):\n@@ -105,8 +105,7 @@ def ask_for_resume(resume_position):\ndef show_backend_not_ready():\n- return xbmcgui.Dialog().ok(common.get_local_string(30105),\n- line1=common.get_local_string(30138))\n+ return xbmcgui.Dialog().ok(common.get_local_string(30105), common.get_local_string(30138))\ndef show_ok_dialog(title, message):\n@@ -120,10 +119,9 @@ def show_yesno_dialog(title, message, yeslabel=None, nolabel=None):\ndef show_error_info(title, message, unknown_error=False, netflix_error=False):\n\"\"\"Show a dialog that displays the error message\"\"\"\nprefix = (30104, 30102, 30101)[unknown_error + netflix_error]\n- return xbmcgui.Dialog().ok(title,\n- line1=common.get_local_string(prefix),\n- line2=message,\n- line3=common.get_local_string(30103))\n+ return xbmcgui.Dialog().ok(title, (common.get_local_string(prefix) + '\\r\\n' +\n+ message + '\\r\\n\\r\\n' +\n+ common.get_local_string(30103)))\ndef show_addon_error_info(exc):\n" }, { "change_type": "MODIFY", "old_path": "test/xbmcgui.py", "new_path": "test/xbmcgui.py", "diff": "@@ -100,18 +100,20 @@ class Dialog:\nprint('\\033[37;100mNOTIFICATION:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, message))\n@staticmethod\n- def ok(heading, line1, line2=None, line3=None):\n+ # ok(heading, line1, line2=None, line3=None): # Kodi 18\n+ def ok(heading, message):\n\"\"\"A stub implementation for the xbmcgui Dialog class ok() method\"\"\"\nheading = kodi_to_ansi(heading)\n- line1 = kodi_to_ansi(line1)\n- print('\\033[37;100mOK:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, line1))\n+ message = kodi_to_ansi(message)\n+ print('\\033[37;100mOK:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, message))\n@staticmethod\n- def yesno(heading, line1, line2=None, line3=None, nolabel=None, yeslabel=None, autoclose=0):\n+ # def yesno(heading, line1, line2=None, line3=None, nolabel=None, yeslabel=None, autoclose=0): # Kodi 18\n+ def yesno(heading, message, nolabel=None, yeslabel=None, customlabel=None, autoclose=0):\n\"\"\"A stub implementation for the xbmcgui Dialog class yesno() method\"\"\"\nheading = kodi_to_ansi(heading)\n- line1 = kodi_to_ansi(line1)\n- print('\\033[37;100mYESNO:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, line1))\n+ message = kodi_to_ansi(message)\n+ print('\\033[37;100mYESNO:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, message))\nreturn True\n@staticmethod\n@@ -156,12 +158,13 @@ class DialogProgress:\nprint()\n@staticmethod\n- def create(heading, line1=None, line2=None, line3=None):\n+ # def create(heading, line1=None, line2=None, line3=None): # Kodi 18\n+ def create(heading, message=None):\n\"\"\"A stub implementation for the xbmcgui DialogProgress class create() method\"\"\"\nheading = kodi_to_ansi(heading)\n- if line1:\n- line1 = kodi_to_ansi(line1)\n- print('\\033[37;100mPROGRESS:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, line1))\n+ if message:\n+ message = kodi_to_ansi(message)\n+ print('\\033[37;100mPROGRESS:\\033[35;0m [%s] \\033[35;0m%s\\033[39;0m' % (heading, message))\nelse:\nprint('\\033[37;100mPROGRESS:\\033[39;0m [%s]' % heading)\n@@ -169,16 +172,15 @@ class DialogProgress:\ndef iscanceled():\n\"\"\"A stub implementation for the xbmcgui DialogProgress class iscanceled() method\"\"\"\n- def update(self, percent, line1=None, line2=None, line3=None):\n+ # def update(self, percent, line1=None, line2=None, line3=None): # Kodi 18\n+ def update(self, percent, message=None):\n\"\"\"A stub implementation for the xbmcgui DialogProgress class update() method\"\"\"\nif (percent - 5) < self.percent:\nreturn\nself.percent = percent\n- line1 = kodi_to_ansi(line1)\n- line2 = kodi_to_ansi(line2)\n- line3 = kodi_to_ansi(line3)\n- if line1 or line2 or line3:\n- print('\\033[37;100mPROGRESS:\\033[35;0m [%d%%] \\033[35;0m%s\\033[39;0m' % (percent, line1 or line2 or line3))\n+ message = kodi_to_ansi(message)\n+ if message:\n+ print('\\033[37;100mPROGRESS:\\033[35;0m [%d%%] \\033[35;0m%s\\033[39;0m' % (percent, message))\nelse:\nprint('\\033[1G\\033[37;100mPROGRESS:\\033[35;0m [%d%%]\\033[39;0m' % (percent), end='')\n@@ -201,7 +203,8 @@ class DialogBusy:\nclass ListItem:\n\"\"\"A reimplementation of the xbmcgui ListItem class\"\"\"\n- def __init__(self, label='', label2='', iconImage='', thumbnailImage='', path='', offscreen=False):\n+ # def __init__(self, label='', label2='', iconImage='', thumbnailImage='', path='', offscreen=False): # Kodi 18\n+ def __init__(self, label='', label2='', path='', offscreen=False):\n\"\"\"A stub constructor for the xbmcgui ListItem class\"\"\"\nself.label = kodi_to_ansi(label)\nself.label2 = kodi_to_ansi(label2)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Changes to Kodi python APIs for Kodi 19
106,046
27.03.2020 11:56:44
-3,600
3346d267f2cb76734848ec003464d6571e7d34e0
Update README.md Updated repository link
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -40,7 +40,7 @@ The trademark \"Netflix\" is registered by \"Netflix, Inc.\"\n#### Quick download links\nInstall add-on via repository - provide automatic installation of updates:\n-* [CastagnaIT Repository - repository.castagnait-1.0.0.zip](https://github.com/castagnait/repository.castagnait/raw/master/repository.castagnait-1.0.0.zip)\n+* [CastagnaIT Repository for KODI 18.x LEIA - repository.castagnait-1.0.1.zip](https://github.com/castagnait/repository.castagnait/raw/master/repository.castagnait-1.0.1.zip)\nInstall add-on manually - updates should always be installed manually:\n* [Add-on download links to current and previous releases](https://github.com/CastagnaIT/plugin.video.netflix/releases)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Update README.md Updated repository link
105,993
28.03.2020 18:54:49
-3,600
6a946b88b2de9c19d122fc1c23f12bdd45ca537e
Ensure only PRs and pushes to master are tested This prevents from doing the same tests twice for other branches in the same repository.
[ { "change_type": "MODIFY", "old_path": ".github/workflows/ci.yml", "new_path": ".github/workflows/ci.yml", "diff": "name: CI\non:\n-- pull_request\n-- push\n+ pull_request:\n+ branch:\n+ - master\n+ push:\n+ branch:\n+ - master\njobs:\ntests:\nname: Add-on testing\n" }, { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -24,10 +24,6 @@ test: check test-unit test-service test-run\ncheck: check-tox check-pylint check-translations\n-test: sanity unit\n-\n-sanity: tox pylint language\n-\ncheck-tox:\n@echo -e \"$(white)=$(blue) Starting sanity tox test$(reset)\"\n$(PYTHON) -m tox -q -e\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Ensure only PRs and pushes to master are tested This prevents from doing the same tests twice for other branches in the same repository.
106,046
29.03.2020 18:49:56
-7,200
9085c02e4578cd6db1e3181e6b8e9276e074566a
Cleanups and fixes for mylist fixed wrong cache add/remove operations to paginated my list removed unused library mylist update call
[ { "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 = OrderedDict(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@@ -226,6 +226,13 @@ class SubgenreList:\nself.lists = list(path_response['genres'].get(genre_id, {}).get('subgenres').items())\n+def merge_data_type(data, data_to_merge):\n+ for video_id, video in iteritems(data_to_merge.videos):\n+ data.videos[video_id] = video\n+ data.videoids.extend(data_to_merge.videoids)\n+ data.contained_titles.extend(data_to_merge.contained_titles)\n+\n+\ndef _check_sentinel(value):\nreturn (None\nif isinstance(value, dict) and value.get('$type') == 'sentinel'\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -19,7 +19,7 @@ from resources.lib.common import cache_utils\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nfrom .data_types import (LoLoMo, VideoList, VideoListSorted, SeasonList, EpisodeList,\n- SearchVideoList, CustomVideoList, SubgenreList)\n+ SearchVideoList, CustomVideoList, SubgenreList, merge_data_type)\nfrom .exceptions import (InvalidVideoListTypeError, APIError, MissingCredentialsError,\nMetadataNotAvailable, CacheMiss)\nfrom .paths import (VIDEO_LIST_PARTIAL_PATHS, VIDEO_LIST_BASIC_PARTIAL_PATHS,\n@@ -496,34 +496,52 @@ def rate_thumb(videoid, rating, track_id_jaw):\n@catch_api_errors\[email protected]_execution(immediate=False)\n-def update_my_list(videoid, operation):\n+def update_my_list(videoid, operation, params):\n\"\"\"Call API to update my list with either add or remove action\"\"\"\ncommon.debug('My List: {} {}', operation, videoid)\n- # We want the tvshowid for seasons and episodes (such videoids may be\n- # passed by the mylist/library auto-sync feature)\n- videoid_value = (videoid.movieid\n- if videoid.mediatype == common.VideoId.MOVIE\n- else videoid.tvshowid)\ncommon.make_call(\n'post',\n{'component': 'update_my_list',\n'data': {\n'operation': operation,\n- 'videoId': int(videoid_value)}})\n+ 'videoId': videoid.value}})\nui.show_notification(common.get_local_string(30119))\n- try:\n- # This is necessary to have the my-list menu updated when you open it\n+ _update_mylist_cache(videoid, operation, params)\n+\n+\n+def _update_mylist_cache(videoid, operation, params):\n+ \"\"\"Update the my list cache to speeding up page load\"\"\"\n+ # Avoids making a new request to the server to request the entire list updated\n+ perpetual_range_start = params.get('perpetual_range_start')\n+ mylist_identifier = 'mylist'\n+ if perpetual_range_start and perpetual_range_start != 'None':\n+ mylist_identifier += '_' + perpetual_range_start\nif operation == 'remove':\n- # Delete item manually to speedup operations on page load\n- cached_video_list_sorted = g.CACHE.get(cache_utils.CACHE_COMMON, 'mylist')\n- del cached_video_list_sorted.videos[videoid.value]\n+ try:\n+ video_list_sorted_data = g.CACHE.get(cache_utils.CACHE_COMMON, mylist_identifier)\n+ del video_list_sorted_data.videos[videoid.value]\n+ g.CACHE.add(cache_utils.CACHE_COMMON, mylist_identifier, video_list_sorted_data)\n+ except CacheMiss:\n+ pass\n+ try:\n+ my_list_videoids = g.CACHE.get(cache_utils.CACHE_COMMON, 'my_list_items')\n+ my_list_videoids.remove(videoid)\n+ g.CACHE.add(cache_utils.CACHE_COMMON, 'my_list_items', my_list_videoids)\n+ except CacheMiss:\n+ pass\nelse:\n- # Force reload items on page load\n- g.CACHE.delete(cache_utils.CACHE_COMMON, 'mylist')\n+ try:\n+ video_list_sorted_data = g.CACHE.get(cache_utils.CACHE_COMMON, mylist_identifier)\n+ merge_data_type(video_list_sorted_data, custom_video_list([videoid.value]))\n+ g.CACHE.add(cache_utils.CACHE_COMMON, mylist_identifier, video_list_sorted_data)\n+ except CacheMiss:\n+ pass\n+ try:\n+ my_list_videoids = g.CACHE.get(cache_utils.CACHE_COMMON, 'my_list_items')\n+ my_list_videoids.append(videoid)\n+ g.CACHE.add(cache_utils.CACHE_COMMON, 'my_list_items', my_list_videoids, ttl=600)\nexcept CacheMiss:\npass\n- # Invalidate my_list_items to allow reload updated my_list_items results when page refresh\n- g.CACHE.delete(cache_utils.CACHE_COMMON, 'my_list_items')\[email protected]_execution(immediate=False)\n@@ -531,7 +549,7 @@ def metadata(videoid, refresh=False):\n\"\"\"Retrieve additional metadata for the given VideoId\"\"\"\n# Delete the cache if we need to refresh the all metadata\nif refresh:\n- g.CACHE.delete(cache_utils.CACHE_METADATA, videoid)\n+ g.CACHE.delete(cache_utils.CACHE_METADATA, videoid.value)\nmetadata_data = {}, None\nif videoid.mediatype not in [common.VideoId.EPISODE, common.VideoId.SEASON]:\nmetadata_data = _metadata(videoid), None\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/context_menu.py", "new_path": "resources/lib/kodi/context_menu.py", "diff": "@@ -17,11 +17,10 @@ from resources.lib.kodi.library import is_in_library\ndef ctx_item_url(paths, mode=g.MODE_ACTION):\n- \"\"\"Return a function that builds an URL from a videoid\n- for the predefined path\"\"\"\n- def ctx_url_builder(videoid):\n+ \"\"\"Return a function that builds an URL from a videoid for the predefined path\"\"\"\n+ def ctx_url_builder(videoid, params):\n\"\"\"Build a context menu item URL\"\"\"\n- return common.build_url(paths, videoid, mode=mode)\n+ return common.build_url(paths, videoid, params, mode=mode)\nreturn ctx_url_builder\n@@ -78,7 +77,7 @@ def generate_context_menu_mainmenu(menu_id):\nreturn items\n-def generate_context_menu_items(videoid):\n+def generate_context_menu_items(videoid, perpetual_range_start=None):\n\"\"\"Generate context menu items for a listitem\"\"\"\nitems = _generate_library_ctx_items(videoid)\n@@ -98,7 +97,7 @@ def generate_context_menu_items(videoid):\nlist_action = ('remove_from_list'\nif videoid in api.mylist_items()\nelse 'add_to_list')\n- items.insert(0, _ctx_item(list_action, videoid))\n+ items.insert(0, _ctx_item(list_action, videoid, {'perpetual_range_start': perpetual_range_start}))\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@@ -144,8 +143,8 @@ def _generate_library_ctx_items(videoid):\nreturn [_ctx_item(action, videoid) for action in library_actions]\n-def _ctx_item(template, videoid):\n+def _ctx_item(template, videoid, params=None):\n\"\"\"Create a context menu item based on the given template and videoid\"\"\"\nreturn (CONTEXT_MENU_ACTIONS[template]['label'],\ncommon.run_plugin_action(\n- CONTEXT_MENU_ACTIONS[template]['url'](videoid)))\n+ CONTEXT_MENU_ACTIONS[template]['url'](videoid, params)))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -105,14 +105,13 @@ def export_new_episodes(videoid, silent=False, nfo_settings=None):\ncommon.debug('Exporting new episodes for {}', videoid)\nmethod(videoid, [export_new_item],\ntitle=common.get_local_string(30198),\n- sync_mylist=False,\nnfo_settings=nfo_settings)\nelse:\ncommon.debug('{} is not a tv show, no new episodes will be exported', videoid)\n@update_kodi_library\n-def execute_library_tasks(videoid, task_handlers, title, sync_mylist=True, nfo_settings=None):\n+def execute_library_tasks(videoid, task_handlers, title, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and show errors in foreground\"\"\"\nfor task_handler in task_handlers:\nexecute_tasks(title=title,\n@@ -121,14 +120,9 @@ def execute_library_tasks(videoid, task_handlers, title, sync_mylist=True, nfo_s\nnotify_errors=True,\nlibrary_home=library_path())\n- # Exclude update operations\n- if task_handlers != [remove_item, export_item]:\n- _sync_mylist(videoid, task_handler, sync_mylist)\n-\n@update_kodi_library\n-def execute_library_tasks_silently(videoid, task_handlers, title=None,\n- sync_mylist=False, nfo_settings=None):\n+def execute_library_tasks_silently(videoid, task_handlers, title=None, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and don't show any GUI feedback\"\"\"\n# pylint: disable=unused-argument\nfor task_handler in task_handlers:\n@@ -139,18 +133,6 @@ def execute_library_tasks_silently(videoid, task_handlers, title=None,\nimport traceback\ncommon.error(traceback.format_exc())\ncommon.error('{} of {} failed', task_handler.__name__, task['title'])\n- if sync_mylist and (task_handlers != [remove_item, export_item]):\n- _sync_mylist(videoid, task_handler, sync_mylist)\n-\n-\n-def _sync_mylist(videoid, task_handler, enabled):\n- \"\"\"Add or remove exported items to My List, if enabled in settings\"\"\"\n- operation = {\n- 'export_item': 'add',\n- 'remove_item': 'remove'}.get(task_handler.__name__)\n- if enabled and operation and g.ADDON.getSettingBool('lib_sync_mylist'):\n- common.info('Syncing my list due to change of Kodi library')\n- api.update_my_list(videoid, operation)\ndef sync_mylist_to_library():\n@@ -165,7 +147,6 @@ def sync_mylist_to_library():\nfor videoid in api.mylist_items_switch_profiles():\nexecute_library_tasks(videoid, [export_item],\ncommon.get_local_string(30018),\n- sync_mylist=False,\nnfo_settings=nfo_settings)\n@@ -176,13 +157,11 @@ def purge():\nfor videoid_value in g.SHARED_DB.get_movies_id_list():\nvideoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])\nexecute_library_tasks(videoid, [remove_item],\n- common.get_local_string(30030),\n- sync_mylist=False)\n+ common.get_local_string(30030))\nfor videoid_value in g.SHARED_DB.get_tvshows_id_list():\nvideoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\nexecute_library_tasks(videoid, [remove_item],\n- common.get_local_string(30030),\n- sync_mylist=False)\n+ common.get_local_string(30030))\n# If for some reason such as improper use of the add-on, unexpected error or other\n# has caused inconsistencies with the contents of the database or stored files,\n# make sure that everything is removed\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_autoupdate.py", "new_path": "resources/lib/kodi/library_autoupdate.py", "diff": "@@ -76,7 +76,7 @@ def auto_update_library(sync_with_mylist, silent):\ncontinue\n# The tv show no more exist in My List so remove it from library\nvideoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n- execute_lib_tasks_method(videoid, [remove_item], sync_mylist=False)\n+ execute_lib_tasks_method(videoid, [remove_item])\n# Check if movies have been removed from the My List\nfor videoid_value in exported_movies_videoids_values:\n@@ -84,7 +84,7 @@ def auto_update_library(sync_with_mylist, silent):\ncontinue\n# The movie no more exist in My List so remove it from library\nvideoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])\n- execute_lib_tasks_method(videoid, [remove_item], sync_mylist=False)\n+ execute_lib_tasks_method(videoid, [remove_item])\n# Add missing tv shows / movies of My List to library\nfor videoid in mylist_videoids:\n@@ -150,8 +150,6 @@ def _update_library(videoids_to_update, exported_tvshows_videoids_values, silent\nif videoid.mediatype == common.VideoId.SHOW:\nexport_new_episodes(videoid, silent, nfo_settings)\nif videoid.mediatype == common.VideoId.MOVIE:\n- execute_lib_tasks_method(videoid, [export_item],\n- sync_mylist=False,\n- nfo_settings=nfo_settings)\n+ execute_lib_tasks_method(videoid, [export_item], nfo_settings=nfo_settings)\n# Add some randomness between operations to limit servers load and ban risks\nxbmc.sleep(random.randint(1000, 5001))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/listings.py", "new_path": "resources/lib/kodi/listings.py", "diff": "@@ -249,10 +249,10 @@ def _create_subgenre_item(video_list_id, subgenre_data, menu_data):\n@custom_viewmode(g.VIEW_SHOW)\[email protected]_execution(immediate=False)\n-def build_video_listing(video_list, menu_data, pathitems=None, genre_id=None):\n+def build_video_listing(video_list, menu_data, pathitems=None, genre_id=None, perpetual_range_start=None):\n\"\"\"Build a video listing\"\"\"\nparams = get_param_watched_status_by_profile()\n- directory_items = [_create_video_item(videoid_value, video, video_list, menu_data, params)\n+ directory_items = [_create_video_item(videoid_value, video, video_list, menu_data, params, perpetual_range_start)\nfor videoid_value, video\nin list(video_list.videos.items())]\n# If genre_id exists add possibility to browse lolomos subgenres\n@@ -291,7 +291,7 @@ def build_video_listing(video_list, menu_data, pathitems=None, genre_id=None):\[email protected]_execution(immediate=False)\n-def _create_video_item(videoid_value, video, video_list, menu_data, params):\n+def _create_video_item(videoid_value, video, video_list, menu_data, params, perpetual_range_start):\n\"\"\"Create a tuple that can be added to a Kodi directory that represents\na video as listed in a videolist\"\"\"\nis_movie = video['summary']['type'] == 'movie'\n@@ -305,7 +305,7 @@ def _create_video_item(videoid_value, video, video_list, menu_data, params):\nif is_movie\nelse g.MODE_DIRECTORY),\nparams=params)\n- list_item.addContextMenuItems(generate_context_menu_items(videoid))\n+ list_item.addContextMenuItems(generate_context_menu_items(videoid, perpetual_range_start))\nreturn (url, list_item, not is_movie)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -103,7 +103,7 @@ class AddonActionExecutor(object):\ndef my_list(self, videoid, pathitems):\n\"\"\"Add or remove an item from my list\"\"\"\noperation = pathitems[1]\n- api.update_my_list(videoid, operation)\n+ api.update_my_list(videoid, operation, self.params)\n_sync_library(videoid, operation)\ncommon.refresh_container()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -66,7 +66,6 @@ class LibraryActionExecutor(object):\nnfo_settings.show_export_dialog(videoid.mediatype, common.get_local_string(30191))\nlibrary.execute_library_tasks_silently(\nvideoid, [library.export_item],\n- sync_mylist=self.params.get('sync_mylist', False),\nnfo_settings=nfo_settings)\[email protected]_video_id(path_offset=1)\n@@ -75,8 +74,7 @@ class LibraryActionExecutor(object):\n(without GUI feedback). This will ignore the setting for syncing my\nlist and Kodi library and do no sync, if not explicitly asked to.\"\"\"\nlibrary.execute_library_tasks_silently(\n- videoid, [library.remove_item],\n- sync_mylist=self.params.get('sync_mylist', False))\n+ videoid, [library.remove_item])\n# Not used for now\n# @common.inject_video_id(path_offset=1)\n@@ -85,8 +83,7 @@ class LibraryActionExecutor(object):\n# (without GUI feedback). This will ignore the setting for syncing my\n# list and Kodi library and do no sync, if not explicitly asked to.\"\"\"\n# library.execute_library_tasks_silently(\n- # videoid, [library.remove_item, library.export_item],\n- # sync_mylist=self.params.get('sync_mylist', False))\n+ # videoid, [library.remove_item, library.export_item])\ndef sync_mylist(self, pathitems): # pylint: disable=unused-argument\n\"\"\"\n@@ -146,8 +143,7 @@ class LibraryActionExecutor(object):\n\"\"\"Migrate exported items from old library format to the new format\"\"\"\nfor videoid in library_items.get_previously_exported_items():\nlibrary.execute_library_tasks(videoid, [library.export_item],\n- common.get_local_string(30018),\n- sync_mylist=False)\n+ common.get_local_string(30018))\[email protected]_video_id(path_offset=1)\ndef export_new_episodes(self, videoid):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Cleanups and fixes for mylist -fixed wrong cache add/remove operations to paginated my list -removed unused library mylist update call
106,046
05.04.2020 14:24:40
-7,200
58230361173e3b9fa643cf1a1a1ff1dd491faf82
Fixed regressions bugs and errors
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -11,16 +11,13 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\n-from future.utils import iteritems\n-\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\nfrom resources.lib.common import cache_utils\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\n-from .data_types import merge_data_type\n-from .exceptions import InvalidVideoListTypeError, APIError, MissingCredentialsError, MetadataNotAvailable, CacheMiss\n-from .paths import EPISODES_PARTIAL_PATHS, ART_PARTIAL_PATHS, EVENT_PATHS, build_paths\n+from .exceptions import APIError, MissingCredentialsError, MetadataNotAvailable, CacheMiss\n+from .paths import EPISODES_PARTIAL_PATHS, ART_PARTIAL_PATHS, build_paths\ndef catch_api_errors(func):\n@@ -154,45 +151,19 @@ def update_videoid_bookmark(video_id):\[email protected]_execution(immediate=False)\n-@cache_utils.cache_output(cache_utils.CACHE_COMMON)\n-def get_video_raw_data(videoid):\n+@cache_utils.cache_output(cache_utils.CACHE_COMMON, identify_append_from_kwarg_name='custom_partial_path')\n+def get_video_raw_data(videoid, custom_partial_path=None):\n\"\"\"Retrieve raw data for a single video id (episode, movie of supplemental)\"\"\"\n- if videoid.mediatype not in [common.VideoId.EPISODE, common.VideoId.MOVIE, common.VideoId.SUPPLEMENTAL]:\n- raise common.InvalidVideoId('Cannot request info for {}'.format(videoid))\n- common.debug('Requesting video info for {}', videoid)\n+ common.debug('Requesting video raw data for {}', videoid)\n+ if not custom_partial_path:\npaths = build_paths(['videos', videoid.value], EPISODES_PARTIAL_PATHS)\nif videoid.mediatype == common.VideoId.EPISODE:\npaths.extend(build_paths(['videos', videoid.tvshowid], ART_PARTIAL_PATHS + [['title']]))\n+ else:\n+ paths = build_paths(['videos', videoid.value], custom_partial_path)\nreturn common.make_call('path_request', paths)\[email protected]_execution(immediate=False)\n-def get_video_raw_data_for_events(videoid):\n- \"\"\"Retrieve raw data for a single video id needed for generate events\"\"\"\n- if videoid.mediatype not in [common.VideoId.EPISODE, common.VideoId.MOVIE, common.VideoId.SUPPLEMENTAL]:\n- raise common.InvalidVideoId('Cannot request event info for {}'.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-\n-def get_mylist_videoids_profile_switch():\n- \"\"\"Return a list of all the items currently contained in my list\"\"\"\n- common.debug('Requesting videoid list of my list with profiles switching')\n- try:\n- items = []\n- video_list = common.make_call('get_datatype_video_list_full', {'context_name': 'mylist',\n- 'switch_profiles': True})\n- if video_list:\n- # pylint: disable=unused-variable\n- items = [common.VideoId.from_videolist_item(video)\n- for video_id, video in iteritems(video_list.videos)\n- if video['queue'].get('inQueue', False)]\n- return items\n- except InvalidVideoListTypeError:\n- return []\n-\n-\n@catch_api_errors\[email protected]_execution(immediate=False)\ndef rate(videoid, rating):\n@@ -269,10 +240,9 @@ def _update_mylist_cache(videoid, operation, params):\npass\nelse:\ntry:\n- video_list_sorted_data = g.CACHE.get(cache_utils.CACHE_MYLIST, mylist_identifier)\n- merge_data_type(video_list_sorted_data,\n- common.make_call('get_datatype_video_list_byid', {'video_ids': [videoid.value]}))\n- g.CACHE.add(cache_utils.CACHE_MYLIST, mylist_identifier, video_list_sorted_data)\n+ common.make_call('add_videoids_to_video_list_cache', {'cache_bucket': cache_utils.CACHE_MYLIST,\n+ 'cache_identifier': mylist_identifier,\n+ 'video_ids': [videoid.value]})\nexcept CacheMiss:\npass\ntry:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/cache_utils.py", "new_path": "resources/lib/common/cache_utils.py", "diff": "@@ -75,11 +75,12 @@ def cache_output(bucket, fixed_identifier=None,\nif not identifier:\n# Do not cache if identifier couldn't be determined\nreturn func(*args, **kwargs)\n+ _bucket = CACHE_MYLIST if arg_value == 'mylist' else bucket\ntry:\n- return g.CACHE.get(CACHE_MYLIST if arg_value == 'mylist' else bucket, identifier)\n+ return g.CACHE.get(_bucket, identifier)\nexcept CacheMiss:\noutput = func(*args, **kwargs)\n- g.CACHE.add(bucket, identifier, output, ttl=ttl)\n+ g.CACHE.add(_bucket, identifier, output, ttl=ttl)\nreturn output\nreturn wrapper\nreturn caching_decorator\n@@ -99,7 +100,7 @@ def _get_identifier(fixed_identifier, identify_from_kwarg_name,\narg_value = unicode(args[identify_fallback_arg_index] or '')\nidentifier = arg_value\nif identifier and identify_append_from_kwarg_name and kwargs.get(identify_append_from_kwarg_name):\n- identifier += '_' + kwargs.get(identify_append_from_kwarg_name)\n+ identifier += '_' + unicode(kwargs.get(identify_append_from_kwarg_name))\n# common.debug('Get_identifier identifier value: {}', identifier if identifier else 'None')\nreturn arg_value, identifier\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/ipc.py", "new_path": "resources/lib/common/ipc.py", "diff": "@@ -80,6 +80,7 @@ def _send_signal(signal, data):\n@time_execution(immediate=False)\ndef make_call(callname, data=None):\n+ # Note: IPC over HTTP handle FULL objects serialization, AddonSignals NOT HANDLE the serialization of objects\nif g.IPC_OVER_HTTP:\nreturn make_http_call(callname, data)\nreturn make_addonsignals_call(callname, data)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -14,7 +14,6 @@ from functools import wraps\nimport xbmc\n-import resources.lib.api.api_requests as api\nimport resources.lib.common as common\nimport resources.lib.kodi.nfo as nfo\nimport resources.lib.kodi.ui as ui\n@@ -144,7 +143,11 @@ def sync_mylist_to_library():\npurge()\nnfo_settings = nfo.NFOSettings()\nnfo_settings.show_export_dialog()\n- for videoid in api.get_mylist_videoids_profile_switch():\n+\n+ mylist_video_id_list, mylist_video_id_list_type = common.make_call('get_mylist_videoids_profile_switch')\n+ for index, video_id in enumerate(mylist_video_id_list):\n+ videoid = common.VideoId(\n+ **{('movieid' if (mylist_video_id_list_type[index] == 'movie') else 'tvshowid'): video_id})\nexecute_library_tasks(videoid, [export_item],\ncommon.get_local_string(30018),\nnfo_settings=nfo_settings)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_autoupdate.py", "new_path": "resources/lib/kodi/library_autoupdate.py", "diff": "@@ -15,7 +15,6 @@ from datetime import datetime, timedelta\nimport xbmc\n-import resources.lib.api.api_requests as api\nimport resources.lib.common as common\nimport resources.lib.kodi.nfo as nfo\nimport resources.lib.kodi.ui as ui\n@@ -56,22 +55,23 @@ def auto_update_library(sync_with_mylist, silent):\nexecute_lib_tasks_method = execute_library_tasks_silently if silent else execute_library_tasks\ncommon.info(\n'Starting auto update library - check updates for tv shows (sync with My List is {})',\n- sync_with_mylist)\n+ 'ENABLED' if sync_with_mylist else 'DISABLED')\ng.SHARED_DB.set_value('library_auto_update_is_running', True)\ng.SHARED_DB.set_value('library_auto_update_start_time', datetime.now())\ntry:\nvideoids_to_update = []\n- # Get My List videoids of the chosen profile\n- mylist_videoids = api.get_mylist_videoids_profile_switch() if sync_with_mylist else []\n# Get the list of the exported items to Kodi library\nexported_tvshows_videoids_values = g.SHARED_DB.get_tvshows_id_list()\nexported_movies_videoids_values = g.SHARED_DB.get_movies_id_list()\nif sync_with_mylist:\n+ # Get My List videoids of the chosen profile\n+ mylist_video_id_list, mylist_video_id_list_type = common.make_call('get_mylist_videoids_profile_switch')\n+\n# Check if tv shows have been removed from the My List\nfor videoid_value in exported_tvshows_videoids_values:\n- if any(videoid.value == unicode(videoid_value) for videoid in mylist_videoids):\n+ if unicode(videoid_value) in mylist_video_id_list:\ncontinue\n# The tv show no more exist in My List so remove it from library\nvideoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n@@ -79,24 +79,25 @@ def auto_update_library(sync_with_mylist, silent):\n# Check if movies have been removed from the My List\nfor videoid_value in exported_movies_videoids_values:\n- if any(videoid.value == unicode(videoid_value) for videoid in mylist_videoids):\n+ if unicode(videoid_value) in mylist_video_id_list:\ncontinue\n# The movie no more exist in My List so remove it from library\nvideoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])\nexecute_lib_tasks_method(videoid, [remove_item])\n# Add missing tv shows / movies of My List to library\n- for videoid in mylist_videoids:\n- if videoid.value not in exported_tvshows_videoids_values and \\\n- videoid.value not in exported_movies_videoids_values:\n- videoids_to_update.append(videoid)\n+ for index, video_id in enumerate(mylist_video_id_list):\n+ if (int(video_id) not in exported_tvshows_videoids_values and\n+ int(video_id) not in exported_movies_videoids_values):\n+ videoids_to_update.append(\n+ common.VideoId(\n+ **{('movieid' if (mylist_video_id_list_type[index] == 'movie') else 'tvshowid'): video_id}))\n# Add the exported tv shows to be updated to the list..\n- tvshows_videoids_to_upd = [common.VideoId.from_path([common.VideoId.SHOW,\n- videoid_value]) for\n- videoid_value in\n- g.SHARED_DB.get_tvshows_id_list(VidLibProp['exclude_update'],\n- False)]\n+ tvshows_videoids_to_upd = [\n+ common.VideoId.from_path([common.VideoId.SHOW, videoid_value]) for\n+ videoid_value in g.SHARED_DB.get_tvshows_id_list(VidLibProp['exclude_update'], False)\n+ ]\n# ..and avoids any duplication caused by possible unexpected errors\nvideoids_to_update.extend(list(set(tvshows_videoids_to_upd) - set(videoids_to_update)))\n@@ -133,13 +134,12 @@ def _is_auto_update_library_running():\ndef _update_library(videoids_to_update, exported_tvshows_videoids_values, silent):\nexecute_lib_tasks_method = execute_library_tasks_silently if silent else execute_library_tasks\n# Get the list of the Tv Shows exported to exclude from updates\n- excluded_videoids_values = g.SHARED_DB.get_tvshows_id_list(VidLibProp['exclude_update'],\n- True)\n+ excluded_videoids_values = g.SHARED_DB.get_tvshows_id_list(VidLibProp['exclude_update'], True)\nfor videoid in videoids_to_update:\n# Check if current videoid is excluded from updates\n- if videoid.value in excluded_videoids_values:\n+ if int(videoid.value) in excluded_videoids_values:\ncontinue\n- if videoid.value in exported_tvshows_videoids_values:\n+ if int(videoid.value) in exported_tvshows_videoids_values:\n# It is possible that the user has chosen not to export NFO files for a tv show\nnfo_export = g.SHARED_DB.get_tvshow_property(videoid.value,\nVidLibProp['nfo_export'], False)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -69,15 +69,13 @@ class AddonActionExecutor(object):\ndef rate_thumb(self, videoid):\n\"\"\"Rate an item on Netflix. Ask for a thumb rating\"\"\"\n# Get updated user rating info for this videoid\n- video_list = common.make_call('get_datatype_video_list_byid', {'video_ids': [videoid.value],\n- 'custom_paths': VIDEO_LIST_RATING_THUMB_PATHS})\n- if video_list.videos:\n- videoid_value, video_data = list(video_list.videos.items())[0] # pylint: disable=unused-variable\n+ raw_data = api.get_video_raw_data(videoid, VIDEO_LIST_RATING_THUMB_PATHS)\n+ if raw_data.get('videos', {}).get(videoid.value):\n+ video_data = raw_data['videos'][videoid.value]\ntitle = video_data.get('title')\ntrack_id_jaw = video_data.get('trackIds', {})['trackId_jaw']\nis_thumb_rating = video_data.get('userRating', {}).get('type', '') == 'thumb'\n- user_rating = video_data.get('userRating', {}).get('userRating') \\\n- if is_thumb_rating else None\n+ user_rating = video_data.get('userRating', {}).get('userRating') if is_thumb_rating else None\nui.show_modal_dialog(False,\nui.xmldialogs.RatingThumb,\n'plugin-video-netflix-RatingThumb.xml',\n@@ -116,13 +114,13 @@ class AddonActionExecutor(object):\nmenu_data = {'path': ['is_context_menu_item', 'is_context_menu_item'], # Menu item do not exists\n'title': common.get_local_string(30179)}\nvideo_id_dict = videoid.to_dict()\n- list_data, extra_data = common.make_call('get_supplemental_list', # pylint: disable=unused-variable\n+ list_data, extra_data = common.make_call('get_video_list_supplemental', # pylint: disable=unused-variable\n{\n'menu_data': menu_data,\n'video_id_dict': video_id_dict,\n'supplemental_type': SUPPLEMENTAL_TYPE_TRAILERS\n})\n- if list_data.videos:\n+ if list_data:\nurl = common.build_url(['supplemental'],\nparams={'video_id_dict': dumps(video_id_dict),\n'supplemental_type': SUPPLEMENTAL_TYPE_TRAILERS},\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.api.paths import EVENT_PATHS\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n@@ -174,10 +175,10 @@ 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.get_video_raw_data_for_events(videoid)\n- if not api_data:\n+ raw_data = api.get_video_raw_data(videoid, EVENT_PATHS)\n+ if not raw_data:\nreturn {}\n- videoid_data = api_data['videos'][videoid.value]\n+ videoid_data = raw_data['videos'][videoid.value]\ncommon.debug('Event data: {}', videoid_data)\nevent_data = {'resume_position':\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/directorybuilder/dir_builder.py", "new_path": "resources/lib/services/directorybuilder/dir_builder.py", "diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+from future.utils import iteritems\n+\nfrom resources.lib import common\n-from resources.lib.common import VideoId\n+from resources.lib.api.data_types import merge_data_type\n+from resources.lib.common import VideoId, g\nfrom resources.lib.services.directorybuilder.dir_builder_items import (build_video_listing, build_subgenres_listing,\nbuild_season_listing, build_episode_listing,\nbuild_lolomo_listing, build_mainmenu_listing,\n@@ -35,8 +38,8 @@ class DirectoryBuilder(DirectoryRequests):\nself.get_video_list_search,\nself.get_genres,\nself.get_subgenres,\n- self.get_datatype_video_list_full,\n- self.get_datatype_video_list_byid\n+ self.get_mylist_videoids_profile_switch,\n+ self.add_videoids_to_video_list_cache\n]\nfor slot in self.slots:\ncommon.register_slot(slot)\n@@ -132,10 +135,18 @@ class DirectoryBuilder(DirectoryRequests):\[email protected]_execution(immediate=True)\[email protected]_return_call\n- def get_datatype_video_list_full(self, context_name, switch_profiles):\n- return self.req_datatype_video_list_full(context_name, switch_profiles)\n+ def get_mylist_videoids_profile_switch(self):\n+ # Special method used for library sync with my list\n+ video_list = self.req_datatype_video_list_full('mylist', True)\n+ video_id_list = [video_id for video_id, video in iteritems(video_list.videos)]\n+ video_id_list_type = [video['summary']['type'] for video_id, video in iteritems(video_list.videos)]\n+ return video_id_list, video_id_list_type\[email protected]_execution(immediate=True)\[email protected]_return_call\n- def get_datatype_video_list_byid(self, video_ids, custom_paths=None):\n- return self.req_datatype_video_list_byid(video_ids, custom_paths)\n+ def add_videoids_to_video_list_cache(self, cache_bucket, cache_identifier, video_ids):\n+ \"\"\"Add the specified video ids to a video list datatype in the cache\"\"\"\n+ # Warning this method raise CacheMiss exception if cache is missing\n+ video_list_sorted_data = g.CACHE.get(cache_bucket, cache_identifier)\n+ merge_data_type(video_list_sorted_data, self.req_datatype_video_list_byid(video_ids))\n+ g.CACHE.add(cache_bucket, cache_identifier, video_list_sorted_data)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/directorybuilder/dir_builder_requests.py", "new_path": "resources/lib/services/directorybuilder/dir_builder_requests.py", "diff": "@@ -192,8 +192,8 @@ class DirectoryRequests(object):\nraise InvalidVideoListTypeError('The chunked_video_list not contains a list of a list of videoids')\nmerged_response = {}\nfor videoids_list in chunked_video_list:\n- path_response = common.make_call('path_request',\n- build_paths(['videos', videoids_list], VIDEO_LIST_PARTIAL_PATHS))\n+ path = build_paths(['videos', videoids_list], VIDEO_LIST_PARTIAL_PATHS)\n+ path_response = self.netflix_session._path_request(path)\ncommon.merge_dicts(path_response, merged_response)\nif perpetual_range_selector:\n@@ -247,9 +247,10 @@ class DirectoryRequests(object):\npath_response = self.netflix_session._perpetual_path_request(**call_args)\nreturn {} if not path_response else VideoListSorted(path_response, context_name, None, 'az')\n- def req_datatype_video_list_byid(self, video_ids, custom_paths=None):\n+ def req_datatype_video_list_byid(self, video_ids, custom_partial_paths=None):\n\"\"\"Retrieve a video list which contains the specified by video ids and return a CustomVideoList object\"\"\"\ncommon.debug('Requesting a video list for {} videos', video_ids)\n- paths = build_paths(['videos', video_ids], custom_paths if custom_paths else VIDEO_LIST_PARTIAL_PATHS)\n+ paths = build_paths(['videos', video_ids],\n+ custom_partial_paths if custom_partial_paths else VIDEO_LIST_PARTIAL_PATHS)\npath_response = self.netflix_session._path_request(paths)\nreturn CustomVideoList(path_response)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed regressions bugs and errors
106,046
06.04.2020 09:40:41
-7,200
4ef9c33a5008ffce010acd863d118aa3fe71ddd3
Fixed UnicodeDecodeError errors on system path with special chars
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/cookies.py", "new_path": "resources/lib/common/cookies.py", "diff": "@@ -61,7 +61,7 @@ def load(account_hash):\nif not xbmcvfs.exists(xbmc.translatePath(filename)):\ncommon.debug('Cookies file does not exist')\nraise MissingCookiesError()\n- common.debug('Loading cookies from {}', filename)\n+ common.debug('Loading cookies from {}', g.py2_decode(filename))\ncookie_file = xbmcvfs.File(filename, 'rb')\ntry:\nif g.PY_IS_VER2:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "@@ -39,7 +39,7 @@ VidLibProp = {\ndef get_local_db_path(db_filename):\n# First ensure database folder exists\n- db_folder = xbmc.translatePath(os.path.join(g.DATA_PATH, 'database'))\n+ db_folder = g.py2_decode(xbmc.translatePath(os.path.join(g.DATA_PATH, 'database')))\nif not folder_exists(db_folder):\nxbmcvfs.mkdirs(db_folder)\nreturn os.path.join(db_folder, db_filename)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -204,13 +204,13 @@ class GlobalVariables(object):\nself.PY_IS_VER2 = sys.version_info.major == 2\nself.COOKIES = {}\nself.ADDON = xbmcaddon.Addon()\n- self.ADDON_ID = self.ADDON.getAddonInfo('id')\n- self.PLUGIN = self.ADDON.getAddonInfo('name')\n- self.VERSION = self.ADDON.getAddonInfo('version')\n- self.DEFAULT_FANART = self.ADDON.getAddonInfo('fanart')\n- self.ICON = self.ADDON.getAddonInfo('icon')\n- self.ADDON_DATA_PATH = self.ADDON.getAddonInfo('path') # Addon folder\n- self.DATA_PATH = self.ADDON.getAddonInfo('profile') # Addon user data folder\n+ self.ADDON_ID = self.py2_decode(self.ADDON.getAddonInfo('id'))\n+ self.PLUGIN = self.py2_decode(self.ADDON.getAddonInfo('name'))\n+ self.VERSION = self.py2_decode(self.ADDON.getAddonInfo('version'))\n+ self.DEFAULT_FANART = self.py2_decode(self.ADDON.getAddonInfo('fanart'))\n+ self.ICON = self.py2_decode(self.ADDON.getAddonInfo('icon'))\n+ self.ADDON_DATA_PATH = self.py2_decode(self.ADDON.getAddonInfo('path')) # Addon folder\n+ self.DATA_PATH = self.py2_decode(self.ADDON.getAddonInfo('profile')) # Addon user data folder\n# Add absolute paths of embedded py modules to python system directory\nmodule_paths = [\n@@ -219,7 +219,7 @@ class GlobalVariables(object):\nfor path in module_paths:\npath = xbmc.translatePath(path)\nif path not in sys.path:\n- sys.path.insert(0, path)\n+ sys.path.insert(0, g.py2_decode(path))\nself.CACHE_PATH = os.path.join(self.DATA_PATH, 'cache')\nself.COOKIE_PATH = os.path.join(self.DATA_PATH, 'COOKIE')\n@@ -233,7 +233,7 @@ class GlobalVariables(object):\nself.PLUGIN_HANDLE = 0\nself.IS_SERVICE = True\nself.BASE_URL = '{scheme}://{netloc}'.format(scheme='plugin',\n- netloc=self.ADDON.getAddonInfo('id'))\n+ netloc=self.ADDON_ID)\nself.PATH = g.py2_decode(unquote(self.URL[2][1:]))\ntry:\nself.PARAM_STRING = argv[2][1:]\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed UnicodeDecodeError errors on system path with special chars
106,046
06.04.2020 10:38:15
-7,200
93e721939e5fbcc1831b28323c8b02548261f4a3
Removed AddonIsEnabled check from UpNext menu not working anymore
[ { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<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=\"UpNextNotifier_enabled\" type=\"bool\" label=\"30129\" default=\"false\" visible=\"System.HasAddon(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" } ]
Python
MIT License
castagnait/plugin.video.netflix
Removed AddonIsEnabled check from UpNext menu not working anymore
106,046
06.04.2020 10:52:45
-7,200
be82fe93ada3a19dd6e4e60754e2adbb24cd6382
Avoid delete cache folder if no more exists
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_actions.py", "new_path": "resources/lib/upgrade_actions.py", "diff": "@@ -20,11 +20,14 @@ from resources.lib.globals import g\ndef delete_cache_folder():\n# Delete cache folder in the add-on userdata (no more needed with the new cache management)\n+ cache_path = os.path.join(g.DATA_PATH, 'cache')\n+ if not os.path.exists(g.py2_decode(xbmc.translatePath(cache_path))):\n+ return\ndebug('Deleting the cache folder from add-on userdata folder')\ntry:\n- delete_folder_contents(os.path.join(g.DATA_PATH, 'cache'), True)\n+ delete_folder_contents(cache_path, True)\nxbmc.sleep(80)\n- xbmcvfs.rmdir(os.path.join(g.DATA_PATH, 'cache'))\n+ xbmcvfs.rmdir(cache_path)\nexcept Exception: # pylint: disable=broad-except\nimport traceback\nerror(traceback.format_exc())\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Avoid delete cache folder if no more exists
106,046
06.04.2020 20:17:05
-7,200
e863d92a9b5a57354234cec17d6ee0b886be1555
Fixed wrong error check for profile avatar
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -109,8 +109,7 @@ def extract_session_data(content, validate=False):\ndef parse_profiles(profiles_list_data):\n\"\"\"Parse profile information from Netflix response\"\"\"\ntry:\n- profiles_list = OrderedDict(resolve_refs(profiles_list_data['profilesList'],\n- profiles_list_data))\n+ profiles_list = OrderedDict(resolve_refs(profiles_list_data['profilesList'], profiles_list_data))\nif not profiles_list:\nraise InvalidProfilesError('It has not been possible to obtain the list of profiles.')\n_delete_non_existing_profiles(profiles_list)\n@@ -180,12 +179,11 @@ def _delete_non_existing_profiles(profiles_list):\ndef _get_avatar(profiles_list_data, profile):\ntry:\n- profile['avatar'].extend(AVATAR_SUBPATH)\n- return common.get_path(profile['avatar'], profiles_list_data)\n- except KeyError:\n- common.warn('Cannot find avatar for profile {guid}'\n- .format(guid=profile['summary']['value']['guid']))\n- return ''\n+ return common.get_path(profile['avatar'] + AVATAR_SUBPATH, profiles_list_data)\n+ except (KeyError, TypeError):\n+ common.warn('Cannot find avatar for profile {}', profile['summary']['guid'])\n+ common.debug('Profile list data: {}', profiles_list_data)\n+ return g.ICON\[email protected]_execution(immediate=True)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed wrong error check for profile avatar
106,046
07.04.2020 09:13:08
-7,200
380022f1930cb0ef2bc738bea38a62857547b65f
Better error case check for save lolomo data
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -63,18 +63,20 @@ def activate_profile(profile_guid):\ndef save_current_lolomo_data():\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- context_names = ['continueWatching']\n+ context_name = 'continueWatching'\nlolomo_data = common.make_call('path_request',\n- [['lolomo', context_names, ['context', 'id', 'index']]])\n+ [['lolomo', [context_name], ['context', 'id', 'index']]])\nlolomo_root = lolomo_data['lolomo'][1]\ng.LOCAL_DB.set_value('lolomo_root_id', lolomo_root, TABLE_SESSION)\n# Todo: In the new profiles, there is no 'continueWatching' list and no list is returned\n# How get the lolomo of continueWatching?\n- for context_name in context_names:\n- if context_name in lolomo_data['lolomos'][lolomo_root]:\n+ if ('lolomos' in lolomo_data and\n+ lolomo_root in lolomo_data['lolomos'] and\n+ context_name in lolomo_data['lolomos'][lolomo_root]):\ncontext_index = lolomo_data['lolomos'][lolomo_root][context_name][2]\ncontext_id = lolomo_data['lolomos'][lolomo_root][context_index][1]\nelse:\n+ common.debug('Context continueWatching lolomo not found. Returned data: {}', lolomo_data)\ncontext_index = ''\ncontext_id = ''\ng.LOCAL_DB.set_value('lolomo_{}_index'.format(context_name.lower()), context_index, TABLE_SESSION)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Better error case check for save lolomo data
106,046
07.04.2020 10:01:30
-7,200
b6b2b816cc0ef7c377f0dddadc9cffe52bbd75e3
Moved kodi version to globals
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -240,27 +240,27 @@ class GetKodiVersion(object):\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-\ndef __init__(self):\n- self._build_version = xbmc.getInfoLabel('System.BuildVersion')\n-\n- @property\n- def version(self):\nimport re\n- result = re.search('\\\\d+\\\\.\\\\d+?(?=(\\\\s|-))', self._build_version)\n- return result.group(0) if result else 'Unknown'\n+ self.build_version = xbmc.getInfoLabel('System.BuildVersion')\n+ # Parse the version number\n+ result = re.search('\\\\d+\\\\.\\\\d+?(?=(\\\\s|-))', self.build_version)\n+ self.version = result.group(0) if result else ''\n+ # Parse the major version number\n+ self.major_version = self.version.split('.')[0] if self.version else ''\n+ # Parse the date of GIT build\n+ result = re.search('(Git:)(\\\\d+?(?=(-|$)))', self.build_version)\n+ self.date = int(result.group(2)) if result and len(result.groups()) >= 2 else None\n+ # Parse the stage name\n+ result = re.search('(\\\\d+\\\\.\\\\d+-)(.+)(?=\\\\s)', self.build_version)\n+ if not result:\n+ result = re.search('^(.+)(-\\\\d+\\\\.\\\\d+)', self.build_version)\n+ self.stage = result.group(1) if result else ''\n+ else:\n+ self.stage = result.group(2) if result else ''\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+ def is_major_ver(self, major_ver):\n+ return bool(major_ver in self.major_version)\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 ''\n+ def __str__(self):\n+ return self.build_version\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -258,6 +258,8 @@ class GlobalVariables(object):\nself.CACHE_MANAGEMENT = CacheManagement()\nfrom resources.lib.common.cache import Cache\nself.CACHE = Cache()\n+ from resources.lib.common.kodiops import GetKodiVersion\n+ self.KODI_VERSION = GetKodiVersion()\ndef _init_database(self, initialize):\n# Initialize local database\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/dialogs.py", "new_path": "resources/lib/kodi/ui/dialogs.py", "diff": "@@ -100,7 +100,7 @@ def ask_for_resume(resume_position):\nreturn xbmcgui.Dialog().contextmenu(\n[\ncommon.get_local_string(12022).format(common.convert_seconds_to_hms_str(resume_position)),\n- common.get_local_string(12023 if '18.' in common.GetKodiVersion().version else 12021)\n+ common.get_local_string(12023 if g.KODI_VERSION.is_major_ver('18') else 12021)\n])\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -103,7 +103,7 @@ 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() and '18' in common.GetKodiVersion().version:\n+ if 'raspberrypi' in common.get_system_platform() and g.KODI_VERSION.is_major_ver('18'):\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'})\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/stream_continuity.py", "new_path": "resources/lib/services/playback/stream_continuity.py", "diff": "@@ -49,7 +49,7 @@ class StreamContinuityManager(PlaybackActionManager):\nself.player = xbmc.Player()\nself.player_state = {}\nself.resume = {}\n- self.legacy_kodi_version = bool('18.' in common.GetKodiVersion().version)\n+ self.legacy_kodi_version = g.KODI_VERSION.is_major_ver('18')\nself.kodi_only_forced_subtitles = None\ndef _initialize(self, data):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Moved kodi version to globals
106,046
07.04.2020 10:32:03
-7,200
5665002f3444a7ecadabcdb178e4e6f4a1c52ed1
Catch unexpected errors in the events monitor
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -105,6 +105,11 @@ class EventsHandler(threading.Thread):\nself.banned_events_ids += [event.get_event_id()]\nexcept queue.Empty:\npass\n+ except Exception as exc: # pylint: disable=broad-except\n+ common.error('[Event queue monitor] An error has occurred: {}', exc)\n+ import traceback\n+ common.error(traceback.format_exc())\n+ self.clear_queue()\nmonitor.waitForAbort(1)\ndef _process_event_request(self, event):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Catch unexpected errors in the events monitor
106,046
07.04.2020 10:36:06
-7,200
69dc37bb752fc15ae317c1d88327640a6637f920
Allow request lolomo update only after one minute or seek
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -130,6 +130,7 @@ 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_data['allow_request_update_lolomo']:\nif event.event_data['is_in_mylist']:\n# If video is in my list, invalidate the continueWatching list (update lolomo context data)\napi.update_lolomo_context('continueWatching')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/progress_manager.py", "new_path": "resources/lib/services/playback/progress_manager.py", "diff": "@@ -31,6 +31,7 @@ class ProgressManager(PlaybackActionManager):\nself.last_player_state = {}\nself.is_player_in_pause = False\nself.lock_events = False\n+ self.allow_request_update_lolomo = False\nself.window_cls = Window(10000) # Kodi home window\ndef _initialize(self, data):\n@@ -46,8 +47,8 @@ class ProgressManager(PlaybackActionManager):\nreturn\nif 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._send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n+ self._send_event(EVENT_STOP, self.event_data, self.last_player_state)\nself.is_event_start_sent = False\nself.lock_events = True\nelse:\n@@ -58,15 +59,18 @@ class ProgressManager(PlaybackActionManager):\n# When the playback starts for the first time, for correctness should send elapsed_seconds value to 0\nif self.tick_elapsed < 5 and self.event_data['resume_position'] is None:\nplayer_state['elapsed_seconds'] = 0\n- _send_event(EVENT_START, self.event_data, player_state)\n+ self._send_event(EVENT_START, self.event_data, player_state)\nself.is_event_start_sent = True\nself.tick_elapsed = 0\nelse:\n# Generate events to send to Netflix service every 1 minute (60secs=1m)\nif (self.tick_elapsed - self.last_tick_count) >= 60:\n- _send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\n+ self._send_event(EVENT_KEEP_ALIVE, self.event_data, player_state)\nself._save_resume_time(player_state['elapsed_seconds'])\nself.last_tick_count = self.tick_elapsed\n+ # Allow request of lolomo update (for continueWatching and bookmark) only after the first minute\n+ # it seems that most of the time if sent earlier returns error\n+ self.allow_request_update_lolomo = True\nself.last_player_state = player_state\nself.tick_elapsed += 1 # One tick almost always represents one second\n@@ -75,7 +79,7 @@ class ProgressManager(PlaybackActionManager):\nreturn\nself._reset_tick_count()\nself.is_player_in_pause = True\n- _send_event(EVENT_ENGAGE, self.event_data, player_state)\n+ self._send_event(EVENT_ENGAGE, self.event_data, player_state)\nself._save_resume_time(player_state['elapsed_seconds'])\ndef on_playback_resume(self, player_state):\n@@ -87,15 +91,16 @@ class ProgressManager(PlaybackActionManager):\n# This might happen when ResumeManager skip is performed\nreturn\nself._reset_tick_count()\n- _send_event(EVENT_ENGAGE, self.event_data, player_state)\n+ self._send_event(EVENT_ENGAGE, self.event_data, player_state)\nself._save_resume_time(player_state['elapsed_seconds'])\n+ self.allow_request_update_lolomo = True\ndef _on_playback_stopped(self):\nif not self.is_event_start_sent or self.lock_events:\nreturn\nself._reset_tick_count()\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._send_event(EVENT_ENGAGE, self.event_data, self.last_player_state)\n+ self._send_event(EVENT_STOP, self.event_data, self.last_player_state)\ndef _save_resume_time(self, resume_time):\n\"\"\"Save resume time value in order to update the infolabel cache\"\"\"\n@@ -111,11 +116,11 @@ class ProgressManager(PlaybackActionManager):\nself.tick_elapsed = 0\nself.last_tick_count = 0\n-\n-def _send_event(event_type, event_data, player_state):\n+ def _send_event(self, event_type, event_data, player_state):\nif not player_state:\ncommon.warn('ProgressManager: the event [{}] cannot be sent, missing player_state data', event_type)\nreturn\n+ event_data['allow_request_update_lolomo'] = self.allow_request_update_lolomo\ncommon.send_signal(common.Signals.QUEUE_VIDEO_EVENT, {\n'event_type': event_type,\n'event_data': event_data,\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Allow request lolomo update only after one minute or seek
106,046
07.04.2020 14:16:56
-7,200
5eb1d280b4124a4ac1759b756ed8341f803fef42
Run EventsHandler thread only when ProgressManager is enabled
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/ipc.py", "new_path": "resources/lib/common/ipc.py", "diff": "@@ -38,6 +38,7 @@ class Signals(object): # pylint: disable=no-init\nQUEUE_VIDEO_EVENT = 'queue_video_event'\nCLEAR_USER_ID_TOKENS = 'clean_user_id_tokens'\nREINITIALIZE_MSL_HANDLER = 'reinitialize_msl_handler'\n+ SWITCH_EVENTS_HANDLER = 'switch_events_handler'\ndef register_slot(callback, signal=None, source_id=None):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -89,12 +89,14 @@ class EventsHandler(threading.Thread):\nself.cache_data_events = {}\nself.banned_events_ids = []\ncommon.register_slot(signal=common.Signals.QUEUE_VIDEO_EVENT, callback=self.callback_event_video_queue)\n+ self._stop_requested = False\ndef run(self):\n\"\"\"Monitor and process the event queue\"\"\"\ncommon.debug('[Event queue monitor] Thread started')\nmonitor = xbmc.Monitor()\n- while not monitor.abortRequested():\n+\n+ while not monitor.abortRequested() and not self._stop_requested:\ntry:\n# Take the first queued item\nevent = self.queue_events.get_nowait()\n@@ -147,6 +149,10 @@ class EventsHandler(threading.Thread):\n# return False\nreturn True\n+ def stop_join(self):\n+ self._stop_requested = True\n+ self.join()\n+\ndef callback_event_video_queue(self, data=None):\n\"\"\"Callback to add a video event\"\"\"\ntry:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -40,6 +40,7 @@ class MSLHandler(object):\ndef __init__(self):\nsuper(MSLHandler, self).__init__()\n+ self._events_handler_thread = None\nself._init_msl_handler()\ncommon.register_slot(\nsignal=common.Signals.ESN_CHANGED,\n@@ -53,6 +54,9 @@ class MSLHandler(object):\ncommon.register_slot(\nsignal=common.Signals.REINITIALIZE_MSL_HANDLER,\ncallback=self.reinitialize_msl_handler)\n+ common.register_slot(\n+ signal=common.Signals.SWITCH_EVENTS_HANDLER,\n+ callback=self.switch_events_handler)\ndef _init_msl_handler(self):\nself.msl_requests = None\n@@ -61,9 +65,8 @@ class MSLHandler(object):\ncommon.info('Loaded MSL data from disk')\nexcept Exception: # pylint: disable=broad-except\nmsl_data = None\n-\nself.msl_requests = MSLRequests(msl_data)\n- EventsHandler(self.msl_requests.chunked_request).start()\n+ self.switch_events_handler()\ndef reinitialize_msl_handler(self, data=None): # pylint: disable=unused-argument\n\"\"\"\n@@ -75,6 +78,15 @@ class MSLHandler(object):\ncommon.delete_file(MSL_DATA_FILENAME)\nself._init_msl_handler()\n+ def switch_events_handler(self, data=None):\n+ \"\"\"Switch to enable or disable the Events handler\"\"\"\n+ if self._events_handler_thread:\n+ self._events_handler_thread.stop_join()\n+ self._events_handler_thread = None\n+ if g.ADDON.getSettingBool('ProgressManager_enabled') or data:\n+ self._events_handler_thread = EventsHandler(self.msl_requests.chunked_request)\n+ self._events_handler_thread.start()\n+\n@display_error_info\[email protected]_execution(immediate=True)\ndef load_manifest(self, viewable_id):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -108,6 +108,13 @@ class SettingsMonitor(xbmc.Monitor):\ng.LOCAL_DB.set_value('content_profiles_int', collect_int, TABLE_SETTINGS_MONITOR)\ng.CACHE.clear([CACHE_MANIFESTS])\n+ # Check if Progress Manager settings is changed\n+ progress_manager_enabled = g.ADDON.getSettingBool('ProgressManager_enabled')\n+ progress_manager_enabled_old = g.LOCAL_DB.get_value('progress_manager_enabled', False, TABLE_SETTINGS_MONITOR)\n+ if progress_manager_enabled != progress_manager_enabled_old:\n+ g.LOCAL_DB.set_value('progress_manager_enabled', progress_manager_enabled, TABLE_SETTINGS_MONITOR)\n+ common.send_signal(signal=common.Signals.SWITCH_EVENTS_HANDLER, data=progress_manager_enabled)\n+\n# Avoid perform these operations when the add-on is installed from scratch and there are no credentials\nif (clean_cache or reboot_addon) and not common.check_credentials():\nreboot_addon = False\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Run EventsHandler thread only when ProgressManager is enabled
106,046
09.04.2020 11:42:21
-7,200
9528b6da34ebe455299005c1245a0609740ccdb8
Fixed possible cases of controller breakage
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/controller.py", "new_path": "resources/lib/services/playback/controller.py", "diff": "@@ -16,6 +16,7 @@ import xbmc\nimport resources.lib.common as common\nfrom resources.lib.globals import g\n+from resources.lib.kodi import ui\nfrom .action_manager import PlaybackActionManager\nfrom .progress_manager import ProgressManager\nfrom .resume_manager import ResumeManager\n@@ -171,10 +172,12 @@ def _notify_managers(manager, notification, data):\nnotify_method(data)\nelse:\nnotify_method()\n- except Exception as exc:\n- common.error('{} disabled due to exception: {}', manager.name, exc)\n+ except Exception as exc: # pylint: disable=broad-except\nmanager.enabled = False\n- raise\n+ msg = '{} disabled due to exception: {}'.format(manager.name, exc)\n+ import traceback\n+ common.error(traceback.format_exc())\n+ ui.show_notification(title=common.get_local_string(30105), msg=msg)\ndef _get_player_id():\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed possible cases of controller breakage
106,046
09.04.2020 11:33:11
-7,200
0533c4962b1a44e7cb5fdd0a6846ac209c7fca71
Enable tracking of notifications only when managers are initalizated
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/controller.py", "new_path": "resources/lib/services/playback/controller.py", "diff": "@@ -45,7 +45,6 @@ class PlaybackController(xbmc.Monitor):\n\"\"\"\nCallback for addon signal when this addon has initiated a playback\n\"\"\"\n- self.tracking = True\nself.active_player_id = None\nself.action_managers = [\nResumeManager(),\n@@ -55,6 +54,7 @@ class PlaybackController(xbmc.Monitor):\nUpNextNotifier()\n]\nself._notify_all(PlaybackActionManager.initialize, data)\n+ self.tracking = True\ndef onNotification(self, sender, method, data):\n# pylint: disable=unused-argument, invalid-name, broad-except\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Enable tracking of notifications only when managers are initalizated
106,046
09.04.2020 13:07:27
-7,200
dad572f4afe2488d49ab29ede73ae8bcc72b4fee
Changed get_video_raw_data to handle multiple videoid
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -153,16 +153,16 @@ def update_videoid_bookmark(video_id):\[email protected]_execution(immediate=False)\n-@cache_utils.cache_output(cache_utils.CACHE_COMMON, identify_append_from_kwarg_name='custom_partial_path')\n-def get_video_raw_data(videoid, custom_partial_path=None):\n- \"\"\"Retrieve raw data for a single video id (episode, movie of supplemental)\"\"\"\n- common.debug('Requesting video raw data for {}', videoid)\n+def get_video_raw_data(videoids, custom_partial_path=None): # Do not apply cache to this method\n+ \"\"\"Retrieve raw data for specified video id's\"\"\"\n+ video_ids = [videoid.value for videoid in videoids]\n+ common.debug('Requesting video raw data for {}', video_ids)\nif not custom_partial_path:\n- paths = build_paths(['videos', videoid.value], EPISODES_PARTIAL_PATHS)\n- if videoid.mediatype == common.VideoId.EPISODE:\n- paths.extend(build_paths(['videos', videoid.tvshowid], ART_PARTIAL_PATHS + [['title']]))\n+ paths = build_paths(['videos', video_ids], EPISODES_PARTIAL_PATHS)\n+ if videoids[0].mediatype == common.VideoId.EPISODE:\n+ paths.extend(build_paths(['videos', videoids[0].tvshowid], ART_PARTIAL_PATHS + [['title']]))\nelse:\n- paths = build_paths(['videos', videoid.value], custom_partial_path)\n+ paths = build_paths(['videos', video_ids], custom_partial_path)\nreturn common.make_call('path_request', paths)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Changed get_video_raw_data to handle multiple videoid
106,046
10.04.2020 09:43:58
-7,200
a1f7897b402a2ebc9648ef6bb9f9be002be79334
Reworked up next integration
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/infolabels.py", "new_path": "resources/lib/kodi/infolabels.py", "diff": "@@ -100,19 +100,6 @@ def _get_art(videoid, item, profile_language_code):\nreturn art\[email protected]_execution(immediate=False)\n-def get_info_for_playback(videoid, skip_add_from_library):\n- \"\"\"Get infolabels and art info\"\"\"\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- if not skip_add_from_library:\n- try:\n- return get_info_from_library(videoid)\n- except library.ItemNotFound:\n- common.debug('Can not get infolabels from the library, submit a request to netflix')\n- return get_info_from_netflix(videoid)\n-\n-\ndef get_resume_info_from_library(videoid):\n\"\"\"Retrieve the resume value from the Kodi library\"\"\"\ntry:\n@@ -250,19 +237,29 @@ def _best_art(arts):\nreturn next((art for art in arts if art), '')\n-def get_info_from_netflix(videoid):\n- \"\"\"Get infolabels with info from cache (if exist) or Netflix API\"\"\"\n+def get_info_from_netflix(videoids):\n+ \"\"\"Get infolabels and arts from cache (if exist) or Netflix API, for multiple videoid\"\"\"\nprofile_language_code = g.LOCAL_DB.get_profile_config('language', '')\n+ videoids_to_request = []\n+ info_data = {}\n+ for videoid in videoids:\ntry:\ninfos = get_info(videoid, None, None, profile_language_code)[0]\nart = _get_art(videoid, None, profile_language_code)\n- common.debug('Got infolabels and art from cache')\n+ info_data[videoid.value] = infos, art\n+ common.debug('Got infolabels and art from cache for videoid {}', videoid)\nexcept (AttributeError, TypeError):\n- common.debug('Infolabels or art were not in cache, retrieving from API')\n- raw_data = api.get_video_raw_data(videoid)\n+ videoids_to_request.append(videoid)\n+\n+ if videoids_to_request:\n+ # Retrieve missing data from API\n+ common.debug('Retrieving infolabels and art from API for videoids {}', videoids_to_request)\n+ raw_data = api.get_video_raw_data(videoids_to_request)\n+ for videoid in videoids_to_request:\ninfos = get_info(videoid, raw_data['videos'][videoid.value], raw_data, profile_language_code)[0]\nart = get_art(videoid, raw_data['videos'][videoid.value], profile_language_code)\n- return infos, art\n+ info_data[videoid.value] = infos, art\n+ return info_data\ndef get_info_from_library(videoid):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -69,7 +69,7 @@ class AddonActionExecutor(object):\ndef rate_thumb(self, videoid):\n\"\"\"Rate an item on Netflix. Ask for a thumb rating\"\"\"\n# Get updated user rating info for this videoid\n- raw_data = api.get_video_raw_data(videoid, VIDEO_LIST_RATING_THUMB_PATHS)\n+ raw_data = api.get_video_raw_data([videoid], VIDEO_LIST_RATING_THUMB_PATHS)\nif raw_data.get('videos', {}).get(videoid.value):\nvideo_data = raw_data['videos'][videoid.value]\ntitle = video_data.get('title')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import xbmc\nimport xbmcplugin\nimport xbmcgui\n@@ -20,9 +19,7 @@ from resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.api.api_requests as api\nimport resources.lib.kodi.infolabels as infolabels\n-import resources.lib.kodi.library as library\nimport resources.lib.kodi.ui as ui\n-from resources.lib.services.playback import get_timeline_markers\nSERVICE_URL_FORMAT = 'http://localhost:{port}'\nMANIFEST_PATH_FORMAT = '/manifest?id={videoid}'\n@@ -53,8 +50,20 @@ class InputstreamError(Exception):\[email protected]_execution(immediate=False)\ndef play(videoid):\n\"\"\"Play an episode or movie as specified by the path\"\"\"\n- common.info('Playing {}', videoid)\n- is_up_next_enabled = g.ADDON.getSettingBool('UpNextNotifier_enabled')\n+ is_upnext_enabled = g.ADDON.getSettingBool('UpNextNotifier_enabled')\n+ # For db settings 'upnext_play_callback_received' and 'upnext_play_callback_file_type' see controller.py\n+ is_upnext_callback_received = g.LOCAL_DB.get_value('upnext_play_callback_received', False)\n+ is_upnext_callback_file_type_strm = g.LOCAL_DB.get_value('upnext_play_callback_file_type', '') == 'strm'\n+ # This is the only way found to know if the played item come from the add-on itself or from Kodi library\n+ # also when Up Next Add-on is used\n+ is_played_from_addon = not g.IS_ADDON_EXTERNAL_CALL or (g.IS_ADDON_EXTERNAL_CALL and\n+ is_upnext_callback_received and\n+ not is_upnext_callback_file_type_strm)\n+ common.info('Playing {} from {} (Is Up Next Add-on call: {})',\n+ videoid,\n+ 'add-on' if is_played_from_addon else 'external call',\n+ is_upnext_callback_received)\n+\nmetadata = [{}, {}]\ntry:\nmetadata = api.get_metadata(videoid)\n@@ -71,11 +80,23 @@ def play(videoid):\nreturn\nlist_item = get_inputstream_listitem(videoid)\n-\nresume_position = None\n+ info_data = None\nevent_data = {}\n-\n- if g.IS_ADDON_EXTERNAL_CALL:\n+ videoid_next_episode = None\n+\n+ if not is_played_from_addon or is_upnext_enabled:\n+ if is_upnext_enabled:\n+ # When UpNext is enabled, get the next episode to play\n+ videoid_next_episode = _upnext_get_next_episode_videoid(videoid, metadata)\n+ info_data = infolabels.get_info_from_netflix(\n+ [videoid, videoid_next_episode] if videoid_next_episode else [videoid])\n+ info, arts = info_data[videoid.value]\n+ # When a item is played from Kodi library or Up Next add-on is needed set info and art to list_item\n+ list_item.setInfo('video', info)\n+ list_item.setArt(arts)\n+\n+ if not is_played_from_addon:\n# Workaround for resuming strm files from library\nresume_position = (infolabels.get_resume_info_from_library(videoid).get('position')\nif g.ADDON.getSettingBool('ResumeManager_enabled') else None)\n@@ -87,21 +108,20 @@ def play(videoid):\nreturn\nif index_selected == 1:\nresume_position = None\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 with items played inside the addon then not Kodi library, need impl. JSON-RPC lib update code\n+\n+ if (g.ADDON.getSettingBool('ProgressManager_enabled') and\n+ videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE] and\n+ is_played_from_addon):\n+ # Enable the progress manager only when:\n+ # - It is not an add-on external call\n+ # - It is an external call, but the played item is not a STRM file\n+ # Todo:\n+ # in theory to enable in Kodi library need implement the update watched status code for items of Kodi library\n+ # by using JSON RPC Files.SetFileDetails https://github.com/xbmc/xbmc/pull/17202\n+ # that can be used only on Kodi 19.x\nevent_data = _get_event_data(videoid)\nevent_data['videoid'] = videoid.to_dict()\n- event_data['is_played_by_library'] = g.IS_ADDON_EXTERNAL_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\n+ event_data['is_played_by_library'] = not is_played_from_addon\nif 'raspberrypi' in common.get_system_platform() and g.KODI_VERSION.is_major_ver('18'):\n# OMX Player is not compatible with netflix video streams\n@@ -112,27 +132,26 @@ def play(videoid):\nxbmcplugin.setResolvedUrl(handle=g.PLUGIN_HANDLE, succeeded=True, listitem=list_item)\n- upnext_info = get_upnext_info(videoid, metadata) if is_up_next_enabled else None\n-\ng.LOCAL_DB.set_value('last_videoid_played', videoid.to_dict(), table=TABLE_SESSION)\ncommon.debug('Sending initialization signal')\ncommon.send_signal(common.Signals.PLAYBACK_INITIATED, {\n'videoid': videoid.to_dict(),\n- 'timeline_markers': get_timeline_markers(metadata[0]),\n- 'upnext_info': upnext_info,\n+ 'videoid_next_episode': videoid_next_episode.to_dict() if videoid_next_episode else None,\n+ 'metadata': metadata,\n+ 'info_data': info_data,\n+ 'is_played_from_addon': is_played_from_addon,\n'resume_position': resume_position,\n- 'event_data': event_data}, non_blocking=True)\n+ 'event_data': event_data,\n+ 'is_upnext_callback_received': is_upnext_callback_received}, non_blocking=True)\ndef get_inputstream_listitem(videoid):\n- \"\"\"Return a listitem that has all inputstream relevant properties set\n- for playback of the given video_id\"\"\"\n+ \"\"\"Return a listitem that has all inputstream relevant properties set for playback of the given video_id\"\"\"\nservice_url = SERVICE_URL_FORMAT.format(\nport=g.LOCAL_DB.get_value('msl_service_port', 8000))\nmanifest_path = MANIFEST_PATH_FORMAT.format(videoid=videoid.value)\n- list_item = xbmcgui.ListItem(path=service_url + manifest_path,\n- offscreen=True)\n+ list_item = xbmcgui.ListItem(path=service_url + manifest_path, offscreen=True)\nlist_item.setContentLookup(False)\nlist_item.setMimeType('application/dash+xml')\nlist_item.setProperty('isFolder', 'false')\n@@ -175,7 +194,7 @@ 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- raw_data = api.get_video_raw_data(videoid, EVENT_PATHS)\n+ raw_data = api.get_video_raw_data([videoid], EVENT_PATHS)\nif not raw_data:\nreturn {}\nvideoid_data = raw_data['videos'][videoid.value]\n@@ -194,43 +213,19 @@ def _get_event_data(videoid):\nreturn event_data\[email protected]_execution(immediate=False)\n-def get_upnext_info(videoid, metadata):\n- \"\"\"Determine next episode and send an AddonSignal to UpNext addon\"\"\"\n+def _upnext_get_next_episode_videoid(videoid, metadata):\n+ \"\"\"Determine the next episode and get the videoid\"\"\"\ntry:\n- next_episode_id = _find_next_episode(videoid, metadata)\n+ videoid_next_episode = _find_next_episode(videoid, metadata)\n+ common.debug('Next episode is {}', videoid_next_episode)\n+ return videoid_next_episode\nexcept (TypeError, KeyError):\n# import traceback\n# common.debug(traceback.format_exc())\ncommon.debug('There is no next episode, not setting up Up Next')\n- return {}\n-\n- common.debug('Next episode is {}', next_episode_id)\n- current_episode = infolabels.get_info_for_playback(next_episode_id, True)\n- next_episode = infolabels.get_info_for_playback(next_episode_id, True)\n- next_info = {\n- 'current_episode': _upnext_info(videoid, *current_episode),\n- 'next_episode': _upnext_info(next_episode_id, *next_episode)\n- }\n-\n- if (xbmc.getInfoLabel('Container.PluginName') != g.ADDON.getAddonInfo('id') and\n- library.is_in_library(next_episode_id)):\n- filepath = g.SHARED_DB.get_episode_filepath(\n- next_episode_id.tvshowid,\n- next_episode_id.seasonid,\n- next_episode_id.episodeid)\n- # next_info['play_info'] = {'play_path': g.py2_decode(xbmc.translatePath(filepath))}\n- next_info['play_url'] = g.py2_decode(xbmc.translatePath(filepath))\n- else:\n- # next_info['play_info'] = {'play_path': common.build_url(videoid=next_episode_id,\n- # mode=g.MODE_PLAY)}\n- next_info['play_url'] = common.build_url(videoid=next_episode_id, mode=g.MODE_PLAY)\n- if 'creditsOffset' in metadata[0]:\n- next_info['notification_offset'] = metadata[0]['creditsOffset']\n- return next_info\n+ return None\[email protected]_execution(immediate=False)\ndef _find_next_episode(videoid, metadata):\ntry:\n# Find next episode in current season\n@@ -247,30 +242,3 @@ def _find_next_episode(videoid, metadata):\nreturn common.VideoId(tvshowid=videoid.tvshowid,\nseasonid=next_season['id'],\nepisodeid=episode['id'])\n-\n-\n-def _upnext_info(videoid, infos, art):\n- \"\"\"Create a data dict for upnext signal\"\"\"\n- # Double check to 'rating' key, sometime can be an empty string, not accepted by Up Next add-on\n- rating = infos.get('rating', None)\n- return {\n- 'episodeid': videoid.episodeid,\n- 'tvshowid': videoid.tvshowid,\n- 'title': infos['title'],\n- 'art': {\n- 'tvshow.poster': art.get('poster', ''),\n- 'thumb': art.get('thumb', ''),\n- 'tvshow.fanart': art.get('fanart', ''),\n- 'tvshow.landscape': art.get('landscape', ''),\n- 'tvshow.clearart': art.get('clearart', ''),\n- 'tvshow.clearlogo': art.get('clearlogo', '')\n- },\n- 'plot': infos['plot'],\n- 'showtitle': infos['tvshowtitle'],\n- 'playcount': infos.get('playcount', 0),\n- 'runtime': infos['duration'],\n- 'season': infos['season'],\n- 'episode': infos['episode'],\n- 'rating': rating if rating else None,\n- 'firstaired': infos.get('year', infos.get('firstaired', ''))\n- }\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -43,9 +43,6 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\n]\nfor slot in self.slots:\ncommon.register_slot(slot)\n- # UpNext Add-on - play call back method\n- # common.register_slot(play_callback, signal=g.ADDON_ID + '_play_action',\n- # source_id='upnextprovider')\nself.prefetch_login()\[email protected]_return_call\n@@ -287,10 +284,3 @@ def _set_range_selector(paths, range_start, range_end):\nexcept ValueError:\npass\nreturn ranged_paths\n-\n-\n-# def play_callback(data):\n-# \"\"\"Callback function used for upnext integration\"\"\"\n-# common.info('Received signal from Up Next. Playing next episode...')\n-# common.stop_playback()\n-# common.play_media(data['play_path'])\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/controller.py", "new_path": "resources/lib/services/playback/controller.py", "diff": "@@ -11,7 +11,6 @@ from __future__ import absolute_import, division, unicode_literals\nimport time\n-import AddonSignals\nimport xbmc\nimport resources.lib.common as common\n@@ -27,24 +26,25 @@ from .upnext import UpNextNotifier\nclass PlaybackController(xbmc.Monitor):\n\"\"\"\n- Tracks status and progress of video playbacks initiated by the addon and\n- saves bookmarks and watched state for the associated items into the Kodi\n- library.\n+ Tracks status and progress of video playbacks initiated by the add-on\n\"\"\"\ndef __init__(self):\nxbmc.Monitor.__init__(self)\nself.tracking = False\nself.active_player_id = None\nself.action_managers = None\n-\n- AddonSignals.registerSlot(\n- g.ADDON.getAddonInfo('id'), common.Signals.PLAYBACK_INITIATED, self.initialize_playback)\n+ common.register_slot(self.initialize_playback, common.Signals.PLAYBACK_INITIATED)\n+ # UpNext Add-on - play call back method\n+ common.register_slot(self._play_callback, signal=g.ADDON_ID + '_play_action', source_id='upnextprovider')\n+ # Safe measure for when Kodi interrupt the play action due to an error/problem or Kodi crash\n+ _reset_upnext_callback_state()\ndef initialize_playback(self, data):\n- # pylint: disable=broad-except\n\"\"\"\n- Callback for addon signal when this addon has initiated a playback\n+ Callback for AddonSignal when this add-on has initiated a playback\n\"\"\"\n+ if data['is_upnext_callback_received']:\n+ _reset_upnext_callback_state()\nself.active_player_id = None\nself.action_managers = [\nResumeManager(),\n@@ -56,18 +56,16 @@ class PlaybackController(xbmc.Monitor):\nself._notify_all(PlaybackActionManager.initialize, data)\nself.tracking = True\n- def onNotification(self, sender, method, data):\n- # pylint: disable=unused-argument, invalid-name, broad-except\n+ def onNotification(self, sender, method, data): # pylint: disable=unused-argument\n\"\"\"\n- Callback for Kodi notifications that handles and dispatches playback\n- started and playback stopped events.\n+ Callback for Kodi notifications that handles and dispatches playback events\n\"\"\"\nif not self.tracking:\nreturn\ntry:\nif method == 'Player.OnAVStart':\n# WARNING: Do not get playerid from 'data',\n- # Because when UpNext addon play a video while we are inside Netflix addon and\n+ # Because when Up Next add-on play a video while we are inside Netflix add-on and\n# not externally like Kodi library, the playerid become -1 this id does not exist\nself._on_playback_started()\nelif method == 'Player.OnSeek':\n@@ -77,8 +75,10 @@ class PlaybackController(xbmc.Monitor):\nelif method == 'Player.OnResume':\nself._on_playback_resume()\nelif method == 'Player.OnStop':\n+ # When Up Next add-on starts the next video, the 'Player.OnStop' notification WILL BE NOT PERFORMED\n+ # then is manually generated by _play_callback method\nself._on_playback_stopped()\n- except Exception:\n+ except Exception: # pylint: disable=broad-except\nimport traceback\ncommon.error(traceback.format_exc())\n@@ -128,7 +128,6 @@ class PlaybackController(xbmc.Monitor):\nself.action_managers = None\ndef _notify_all(self, notification, data=None):\n- # pylint: disable=broad-except\ncommon.debug('Notifying all managers of {} (data={})', notification.__name__, data)\nfor manager in self.action_managers:\n_notify_managers(manager, notification, data)\n@@ -164,6 +163,24 @@ class PlaybackController(xbmc.Monitor):\nreturn player_state\n+ def _play_callback(self, data):\n+ \"\"\"Callback function used for Up Next add-on integration\"\"\"\n+ common.info('Received play signal from UpNext add-on. Playing next episode...')\n+ # This information are necessary to be able to understand if when play the next episode is done by\n+ # the add-on itself or from external call (Kodi library)\n+ g.LOCAL_DB.set_value('upnext_play_callback_received', True)\n+ g.LOCAL_DB.set_value('upnext_play_callback_file_type', 'strm' if '.strm' in data['play_path'] else 'plugin')\n+ # Manually generates the OnStop notification\n+ self.onNotification('_play_callback', 'Player.OnStop', None)\n+ # Todo: Seem a bug of Kodi, when play next video and stop the video,\n+ # the previous videos marked as watched lost his checks\n+ # but if you return to previous folder and open again the video list, the lost checks are restored.\n+ # This happen when play videos inside add-on with \"Sync of watched status with Netflix\" feature disabled.\n+ common.play_media(data['play_path'])\n+ # Alternative way\n+ # common.stop_playback()\n+ # common.json_rpc('Player.Open', {'item': {'file': data['play_path']}})\n+\ndef _notify_managers(manager, notification, data):\nnotify_method = getattr(manager, notification.__name__)\n@@ -193,3 +210,9 @@ def _get_player_id():\nexcept IOError:\ncommon.error('Player ID not obtained, fallback to ID 1')\nreturn 1\n+\n+\n+def _reset_upnext_callback_state():\n+ if g.LOCAL_DB.get_value('upnext_play_callback_received', False):\n+ g.LOCAL_DB.set_value('upnext_play_callback_received', False)\n+ g.LOCAL_DB.set_value('upnext_play_callback_file_type', '')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/section_skipping.py", "new_path": "resources/lib/services/playback/section_skipping.py", "diff": "@@ -11,18 +11,18 @@ from __future__ import absolute_import, division, unicode_literals\nimport xbmc\n-from resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n+from resources.lib.globals import g\nfrom .action_manager import PlaybackActionManager\n-from .markers import SKIPPABLE_SECTIONS\n+from .markers import SKIPPABLE_SECTIONS, get_timeline_markers\nclass SectionSkipper(PlaybackActionManager):\n\"\"\"\nChecks if a skippable section has been reached and takes appropriate action\n\"\"\"\n- def __init__(self): # pylint: disable=super-on-old-class\n+ def __init__(self):\nsuper(SectionSkipper, self).__init__()\nself.markers = {}\nself.auto_skip = False\n@@ -34,7 +34,7 @@ class SectionSkipper(PlaybackActionManager):\nself.pause_on_skip))\ndef _initialize(self, data):\n- self.markers = data['timeline_markers']\n+ self.markers = get_timeline_markers(data['metadata'][0])\nself.auto_skip = g.ADDON.getSettingBool('auto_skip_credits')\nself.pause_on_skip = g.ADDON.getSettingBool('pause_on_skip')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/upnext.py", "new_path": "resources/lib/services/playback/upnext.py", "diff": "\"\"\"\nCopyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\nCopyright (C) 2018 Caphm (original implementation module)\n- Relay playback info to UP NEXT add-on\n+ Relay playback info to Up Next add-on\nSPDX-License-Identifier: MIT\nSee LICENSES/MIT.md for more information.\n\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import resources.lib.common as common\n+import xbmc\n+import resources.lib.common as common\n+from resources.lib.globals import g\nfrom .action_manager import PlaybackActionManager\nclass UpNextNotifier(PlaybackActionManager):\n\"\"\"\n- Triggers the AddonSignal for Up Next addon integration.\n- Needed because the signal must be sent after playback started.\n+ Prepare the data and trigger the AddonSignal for Up Next add-on integration.\n+ The signal must be sent after playback started.\n\"\"\"\n- def __init__(self): # pylint: disable=super-on-old-class\n+ def __init__(self):\nsuper(UpNextNotifier, self).__init__()\nself.upnext_info = None\n@@ -27,15 +29,68 @@ class UpNextNotifier(PlaybackActionManager):\nreturn 'enabled={}'.format(self.enabled)\ndef _initialize(self, data):\n- self.upnext_info = data['upnext_info']\n- self.enabled = bool(self.upnext_info)\n+ if not data['info_data'] or not data['videoid_next_episode']:\n+ return\n+ videoid = common.VideoId.from_dict(data['videoid'])\n+ videoid_next_episode = common.VideoId.from_dict(data['videoid_next_episode'])\n+ self.upnext_info = get_upnext_info(videoid, videoid_next_episode, data['info_data'], data['metadata'],\n+ data['is_played_from_addon'])\n- def _on_playback_started(self, player_state):\n- # pylint: disable=unused-argument\n- common.debug('Sending initialization signal to Up Next')\n- common.send_signal(common.Signals.UPNEXT_ADDON_INIT,\n- self.upnext_info,\n- non_blocking=True)\n+ def _on_playback_started(self, player_state): # pylint: disable=unused-argument\n+ common.debug('Sending initialization signal to Up Next Add-on')\n+ common.send_signal(common.Signals.UPNEXT_ADDON_INIT, self.upnext_info, non_blocking=True)\ndef _on_tick(self, player_state):\npass\n+\n+\n+def get_upnext_info(videoid, videoid_next_episode, info_data, metadata, is_played_from_addon):\n+ \"\"\"Get the data to send to Up Next add-on\"\"\"\n+ upnext_info = {\n+ 'current_episode': _upnext_info(videoid, *info_data[videoid.value]),\n+ 'next_episode': _upnext_info(videoid_next_episode, *info_data[videoid_next_episode.value])\n+ }\n+\n+ if is_played_from_addon:\n+ url = common.build_url(videoid=videoid_next_episode,\n+ mode=g.MODE_PLAY,\n+ params={'profile_guid': g.LOCAL_DB.get_active_profile_guid()})\n+ else:\n+ # Played from Kodi library get the strm file path\n+ file_path = g.SHARED_DB.get_episode_filepath(\n+ videoid_next_episode.tvshowid,\n+ videoid_next_episode.seasonid,\n+ videoid_next_episode.episodeid)\n+ url = g.py2_decode(xbmc.translatePath(file_path))\n+ upnext_info['play_info'] = {'play_path': url}\n+\n+ if 'creditsOffset' in metadata[0]:\n+ upnext_info['notification_offset'] = metadata[0]['creditsOffset']\n+ return upnext_info\n+\n+\n+def _upnext_info(videoid, infos, art):\n+ \"\"\"Create a data dict for Up Next signal\"\"\"\n+ # Double check to 'rating' key, sometime can be an empty string, not accepted by Up Next add-on\n+ rating = infos.get('rating', None)\n+ return {\n+ 'episodeid': videoid.episodeid,\n+ 'tvshowid': videoid.tvshowid,\n+ 'title': infos['title'],\n+ 'art': {\n+ 'tvshow.poster': art.get('poster', ''),\n+ 'thumb': art.get('thumb', ''),\n+ 'tvshow.fanart': art.get('fanart', ''),\n+ 'tvshow.landscape': art.get('landscape', ''),\n+ 'tvshow.clearart': art.get('clearart', ''),\n+ 'tvshow.clearlogo': art.get('clearlogo', '')\n+ },\n+ 'plot': infos['plot'],\n+ 'showtitle': infos['tvshowtitle'],\n+ 'playcount': infos.get('playcount', 0),\n+ 'runtime': infos['duration'],\n+ 'season': infos['season'],\n+ 'episode': infos['episode'],\n+ 'rating': rating if rating else None,\n+ 'firstaired': infos.get('year', infos.get('firstaired', ''))\n+ }\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Reworked up next integration
106,046
10.04.2020 08:52:08
-7,200
1cb5170c4162795ca596521442c85af0d4a3d490
Added missing repr
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/progress_manager.py", "new_path": "resources/lib/services/playback/progress_manager.py", "diff": "@@ -126,3 +126,6 @@ class ProgressManager(PlaybackActionManager):\n'event_data': event_data,\n'player_state': player_state\n}, non_blocking=True)\n+\n+ def __repr__(self):\n+ return 'enabled={}'.format(self.enabled)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added missing repr
106,046
10.04.2020 13:21:30
-7,200
4abc15f6933880ab8fb8ba0b97f24d4932f444f1
Handle possible errors in deserializing
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/cache_utils.py", "new_path": "resources/lib/common/cache_utils.py", "diff": "@@ -11,6 +11,7 @@ from __future__ import absolute_import, division, unicode_literals\nfrom functools import wraps\n+import resources.lib.common as common\nfrom resources.lib.api.exceptions import CacheMiss\nfrom resources.lib.globals import g\n@@ -117,9 +118,15 @@ def serialize_data(value):\ndef deserialize_data(value):\n+ try:\nif g.PY_IS_VER2:\n# On python 2 pickle.loads wants str\nfrom base64 import standard_b64decode\nreturn pickle.loads(standard_b64decode(value))\n# On python 3 pickle.loads wants byte\nreturn pickle.loads(value)\n+ except (pickle.UnpicklingError, TypeError, EOFError):\n+ # TypeError/EOFError happen when standard_b64decode fails\n+ # This should happen only if manually mixing the database data\n+ common.error('It was not possible to deserialize the cache data, try purge cache from expert settings menu')\n+ raise CacheMiss()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Handle possible errors in deserializing
106,046
11.04.2020 08:57:43
-7,200
ba5504376f04b3ab60a8bf4f39b6ff54f8fb481c
Add missing ImportError
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/data_conversion.py", "new_path": "resources/lib/common/data_conversion.py", "diff": "@@ -82,7 +82,7 @@ def _conv_string_to_json(value):\ndef _conv_string_to_datetime(value):\ntry:\nreturn datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S.%f')\n- except TypeError:\n+ except (TypeError, ImportError):\n# Python bug https://bugs.python.org/issue27400\nimport time\n# Workaround for http://bugs.python.org/issue8098 only to py2\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add missing ImportError
106,046
11.04.2020 10:34:21
-7,200
1019065f448d569bd458f9bf89946cfd6d93dd46
Guarantee a minimum ttl for manifest
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -125,6 +125,12 @@ class MSLHandler(object):\ntry:\n# The manifest must be requested once and maintained for its entire duration\nmanifest = g.CACHE.get(CACHE_MANIFESTS, cache_identifier)\n+ expiration = int(manifest['expiration'] / 1000)\n+ if (expiration - time.time()) < 14400:\n+ # Some devices remain active even longer than 48 hours, if the manifest is at the limit of the deadline\n+ # when requested by stream_continuity.py / events_handler.py will cause problems\n+ # if it is already expired, so we guarantee a minimum of safety ttl of 4h (14400s = 4 hours)\n+ raise CacheMiss()\nif common.is_debug_verbose():\ncommon.debug('Manifest for {} obtained from the cache', viewable_id)\n# Save the manifest to disk as reference\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Guarantee a minimum ttl for manifest
106,046
11.04.2020 11:37:57
-7,200
e72b823f0f4fe01f291c80b19c39ba7aaccf90de
Add support to Python 3.8 to CI
[ { "change_type": "MODIFY", "old_path": ".github/workflows/ci.yml", "new_path": ".github/workflows/ci.yml", "diff": "@@ -16,9 +16,7 @@ jobs:\nstrategy:\nfail-fast: false\nmatrix:\n- # FIXME: E1101: Module 'time' has no 'clock' member on Python 3.8\n- #python-version: [2.7, 3.5, 3.6, 3.7, 3.8]\n- python-version: [2.7, 3.5, 3.6, 3.7]\n+ python-version: [2.7, 3.5, 3.6, 3.7, 3.8]\nsteps:\n- name: Check out ${{ github.sha }} from repository ${{ github.repository }}\nuses: actions/checkout@v2\n" }, { "change_type": "MODIFY", "old_path": "tox.ini", "new_path": "tox.ini", "diff": "[tox]\n-envlist = py27,py35,py36,py37,flake8\n+envlist = py27,py35,py36,py37,py38,flake8\nskipsdist = True\nskip_missing_interpreters = True\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add support to Python 3.8 to CI
106,046
11.04.2020 12:20:50
-7,200
c95ffe52055997d1862fbb623efff1c07b473e51
Fix time.clock function deprecated on Python 3.8
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/logging.py", "new_path": "resources/lib/common/logging.py", "diff": "See LICENSES/MIT.md for more information.\n\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-from functools import wraps\n-from time import clock\n+import time\n+from functools import wraps\nfrom future.utils import iteritems\nimport xbmc\n@@ -20,6 +20,16 @@ from resources.lib.globals import g\n__LOG_LEVEL__ = None\n+def perf_clock():\n+ if hasattr(time, 'clock'):\n+ # time.clock() was deprecated in Python 3.3 and removed in Python 3.8\n+ return time.clock() # pylint: disable=no-member\n+ if hasattr(time, 'perf_counter'):\n+ # * 1e-6 convert [us] to [s]\n+ return time.perf_counter() * 1e-6 # pylint: disable=no-member\n+ return time.time()\n+\n+\ndef get_log_level():\n\"\"\"\nLazily read the log level settings\n@@ -133,11 +143,11 @@ def time_execution(immediate):\nreturn func(*args, **kwargs)\ng.add_time_trace_level()\n- start = clock()\n+ start = perf_clock()\ntry:\nreturn func(*args, **kwargs)\nfinally:\n- execution_time = int((clock() - start) * 1000)\n+ execution_time = int((perf_clock() - start) * 1000)\nif immediate:\ndebug('Call to {} took {}ms'\n.format(func.__name__, execution_time))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_requests.py", "new_path": "resources/lib/services/msl/msl_requests.py", "diff": "@@ -177,9 +177,9 @@ class MSLRequests(MSLRequestBuilder):\ndef _post(self, endpoint, request_data):\n\"\"\"Execute a post request\"\"\"\ncommon.debug('Executing POST request to {}', endpoint)\n- start = time.clock()\n+ start = common.perf_clock()\nresponse = self.session.post(endpoint, request_data)\n- common.debug('Request took {}s', time.clock() - start)\n+ common.debug('Request took {}s', common.perf_clock() - start)\ncommon.debug('Request returned response with status {}', response.status_code)\nresponse.raise_for_status()\nreturn response\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import time\nimport json\nimport requests\n@@ -88,14 +87,14 @@ class NFSessionRequests(NFSessionBase):\nverb='GET' if method == self.session.get else 'POST', url=url)\ndata, headers, params = self._prepare_request_properties(component,\nkwargs)\n- start = time.clock()\n+ start = common.perf_clock()\nresponse = method(\nurl=url,\nverify=self.verify_ssl,\nheaders=headers,\nparams=params,\ndata=data)\n- common.debug('Request took {}s', time.clock() - start)\n+ common.debug('Request took {}s', common.perf_clock() - start)\ncommon.debug('Request returned statuscode {}', response.status_code)\nif response.status_code in [404, 401] and not session_refreshed:\n# 404 - It may happen when Netflix update the build_identifier version and causes the api address to change\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix time.clock function deprecated on Python 3.8 Co-authored-by: Mykola Dvornik <[email protected]>
106,046
11.04.2020 15:34:12
-7,200
0d17396faadebe73dab22cc8f4a030586e1b00f5
Fixed ProfilesMissing error when addon installed from scratch
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/cache/cache_management.py", "new_path": "resources/lib/services/cache/cache_management.py", "diff": "@@ -18,7 +18,7 @@ from time import time\nfrom resources.lib import common\nfrom resources.lib.api.exceptions import UnknownCacheBucketError, CacheMiss\nfrom resources.lib.common import g\n-from resources.lib.database.db_exceptions import SQLiteConnectionError, SQLiteError\n+from resources.lib.database.db_exceptions import SQLiteConnectionError, SQLiteError, ProfilesMissing\nfrom resources.lib.common.cache_utils import BUCKET_NAMES, BUCKETS\nCONN_ISOLATION_LEVEL = None # Autocommit mode\n@@ -122,8 +122,8 @@ class CacheManagement(object):\ndef get(self, bucket, identifier):\n\"\"\"Get a item from cache bucket\"\"\"\n- identifier = self._add_prefix(identifier)\ntry:\n+ identifier = self._add_prefix(identifier)\ncache_entry = self._get_cache_bucket(bucket['name'])[identifier]\nif cache_entry['expires'] < int(time()):\n# Cache expired\n@@ -133,6 +133,9 @@ class CacheManagement(object):\nif bucket['is_persistent']:\nreturn self._get_db(bucket['name'], identifier)\nraise CacheMiss()\n+ except ProfilesMissing:\n+ # Raised by _add_prefix there is no active profile guid when add-on is installed from scratch\n+ raise CacheMiss()\n@handle_connection\ndef _get_db(self, bucket_name, identifier):\n@@ -161,6 +164,7 @@ class CacheManagement(object):\n:param ttl: override default expiration (in seconds)\n:param expires: override default expiration (in timestamp) if specified override also the 'ttl' value\n\"\"\"\n+ try:\nidentifier = self._add_prefix(identifier)\nif not expires:\nif not ttl and bucket['default_ttl']:\n@@ -172,6 +176,9 @@ class CacheManagement(object):\nif bucket['is_persistent']:\n# Save the item data to the cache database\nself._add_db(bucket['name'], identifier, data, expires)\n+ except ProfilesMissing:\n+ # Raised by _add_prefix there is no active profile guid when add-on is installed from scratch\n+ pass\n@handle_connection\ndef _add_db(self, bucket_name, identifier, data, expires):\n@@ -187,6 +194,7 @@ class CacheManagement(object):\ndef delete(self, bucket, identifier):\n\"\"\"Delete an item from cache bucket\"\"\"\n# Delete the item data from in memory-cache\n+ try:\nidentifier = self._add_prefix(identifier)\nbucket_data = self._get_cache_bucket(bucket['name'])\nif identifier in bucket_data:\n@@ -194,6 +202,9 @@ class CacheManagement(object):\nif bucket['is_persistent']:\n# Delete the item data from cache database\nself._delete_db(bucket['name'], identifier)\n+ except ProfilesMissing:\n+ # Raised by _add_prefix there is no active profile guid when add-on is installed from scratch\n+ pass\n@handle_connection\ndef _delete_db(self, bucket_name, identifier):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed ProfilesMissing error when addon installed from scratch
106,046
11.04.2020 18:47:43
-7,200
2c10c6413e56e2435b813f937c8a118bd995f88d
Temporary disabled parental control needs to be rewritten due to netflix changes
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -14,7 +14,6 @@ import xbmc\nimport resources.lib.api.api_requests as api\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n-from resources.lib.api.exceptions import MissingCredentialsError, WebsiteParsingError\nfrom resources.lib.api.paths import VIDEO_LIST_RATING_THUMB_PATHS, SUPPLEMENTAL_TYPE_TRAILERS\nfrom resources.lib.globals import g\n@@ -49,20 +48,21 @@ class AddonActionExecutor(object):\ndef parental_control(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Open parental control settings dialog\"\"\"\n- password = ui.ask_for_password()\n- if not password:\n- return\n- try:\n- parental_control_data = api.get_parental_control_data(password)\n- ui.show_modal_dialog(False,\n- ui.xmldialogs.ParentalControl,\n- 'plugin-video-netflix-ParentalControl.xml',\n- g.ADDON.getAddonInfo('path'),\n- **parental_control_data)\n- except MissingCredentialsError:\n- ui.show_ok_dialog('Netflix', common.get_local_string(30009))\n- except WebsiteParsingError as exc:\n- ui.show_addon_error_info(exc)\n+ ui.show_ok_dialog('Netflix', 'This feature will be available in future versions of the add-on')\n+ # password = ui.ask_for_password()\n+ # if not password:\n+ # return\n+ # try:\n+ # parental_control_data = api.get_parental_control_data(password)\n+ # ui.show_modal_dialog(False,\n+ # ui.xmldialogs.ParentalControl,\n+ # 'plugin-video-netflix-ParentalControl.xml',\n+ # g.ADDON.getAddonInfo('path'),\n+ # **parental_control_data)\n+ # except MissingCredentialsError:\n+ # ui.show_ok_dialog('Netflix', common.get_local_string(30009))\n+ # except WebsiteParsingError as exc:\n+ # ui.show_addon_error_info(exc)\[email protected]_video_id(path_offset=1)\[email protected]_execution(immediate=False)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Temporary disabled parental control needs to be rewritten due to netflix changes
106,046
11.04.2020 18:33:19
-7,200
9569f8c4e4e484d78fe188a0584ca31f2cd40b76
Avoid run upgrade changes after a rollback
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "@@ -20,16 +20,18 @@ def check_addon_upgrade():\n:return True if this is the first run of the add-on after an installation from scratch\n\"\"\"\n+ from resources.lib.common import is_less_version\n# Upgrades that require user interaction or to be performed outside of the service\naddon_previous_ver = g.LOCAL_DB.get_value('addon_previous_version', None)\naddon_current_ver = g.VERSION\n- if addon_current_ver != addon_previous_ver:\n+ if addon_previous_ver is None or is_less_version(addon_previous_ver, addon_current_ver):\n_perform_addon_changes(addon_previous_ver, addon_current_ver)\nreturn addon_previous_ver is None\ndef check_service_upgrade():\n\"\"\"Check service upgrade and perform necessary update operations\"\"\"\n+ from resources.lib.common import is_less_version\n# Upgrades to be performed before starting the service\n# Upgrade the local database\ncurrent_local_db_version = g.LOCAL_DB.get_value('local_db_version', None)\n@@ -46,15 +48,14 @@ def check_service_upgrade():\n# Perform service changes\nservice_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\nservice_current_ver = g.VERSION\n- if service_current_ver != service_previous_ver:\n+ if service_previous_ver is None or is_less_version(service_previous_ver, service_current_ver):\n_perform_service_changes(service_previous_ver, service_current_ver)\ndef _perform_addon_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\n- from resources.lib.common import (debug, is_less_version)\n- debug('Initialize addon upgrade operations, from version {} to {})',\n- previous_ver, current_ver)\n+ from resources.lib.common import debug, is_less_version\n+ debug('Initialize addon upgrade operations, from version {} to {})', previous_ver, current_ver)\nif previous_ver and is_less_version(previous_ver, '0.15.9'):\nimport resources.lib.kodi.ui as ui\nmsg = ('This update resets the settings to auto-update library.\\r\\n'\n@@ -68,9 +69,8 @@ def _perform_addon_changes(previous_ver, current_ver):\ndef _perform_service_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\n- from resources.lib.common import debug\n- debug('Initialize service upgrade operations, from version {} to {})',\n- previous_ver, current_ver)\n+ from resources.lib.common import debug, is_less_version\n+ debug('Initialize service upgrade operations, from version {} to {})', previous_ver, current_ver)\nfrom resources.lib.upgrade_actions import delete_cache_folder\ndelete_cache_folder()\n# Always leave this to last - After the operations set current version\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Avoid run upgrade changes after a rollback
106,046
11.04.2020 18:35:34
-7,200
bd3ef45fe79caa767b84037a7080aaef2fe7e8c2
Implemented disable option to library auto-update mode Allow to disable all functionality with the Kodi library, including menus
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/context_menu.py", "new_path": "resources/lib/kodi/context_menu.py", "diff": "@@ -31,7 +31,9 @@ def generate_context_menu_items(videoid, is_in_mylist, perpetual_range_start=Non\nif videoid.mediatype not in [common.VideoId.SUPPLEMENTAL, common.VideoId.EPISODE]:\n# Library operations for supplemental (trailers etc) and single episodes are not allowed\n- items = _generate_library_ctx_items(videoid)\n+ lib_auto_upd_mode = g.ADDON.getSettingInt('lib_auto_upd_mode')\n+ if lib_auto_upd_mode != 0:\n+ items = _generate_library_ctx_items(videoid, lib_auto_upd_mode)\n# Old rating system\n# if videoid.mediatype != common.VideoId.SEASON and \\\n@@ -57,11 +59,11 @@ def generate_context_menu_items(videoid, is_in_mylist, perpetual_range_start=Non\nreturn items\n-def _generate_library_ctx_items(videoid):\n+def _generate_library_ctx_items(videoid, lib_auto_upd_mode):\nlibrary_actions = []\nallow_lib_operations = True\nlib_is_sync_with_mylist = (g.ADDON.getSettingBool('lib_sync_mylist') and\n- g.ADDON.getSettingInt('lib_auto_upd_mode') != 0)\n+ lib_auto_upd_mode == 2)\nif lib_is_sync_with_mylist:\n# If the synchronization of Netflix \"My List\" with the Kodi library is enabled\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -27,7 +27,7 @@ class LibraryUpdateService(xbmc.Monitor):\ndef __init__(self):\ntry:\n- self.enabled = g.ADDON.getSettingInt('lib_auto_upd_mode') == 1\n+ self.enabled = g.ADDON.getSettingInt('lib_auto_upd_mode') == 2\nexcept Exception: # pylint: disable=broad-except\n# If settings.xml was not created yet, as at first service run\n# g.ADDON.getSettingInt('lib_auto_upd_mode') will thrown a TypeError\n@@ -83,7 +83,7 @@ class LibraryUpdateService(xbmc.Monitor):\n# Wait for slow system (like Raspberry Pi) to write the settings\nxbmc.sleep(500)\n# Check if the status is changed\n- self.enabled = g.ADDON.getSettingInt('lib_auto_upd_mode') == 1\n+ self.enabled = g.ADDON.getSettingInt('lib_auto_upd_mode') == 2\n# Then compute the next schedule\nif self.enabled:\nself.next_schedule = _compute_next_schedule()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -136,7 +136,7 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ng.settings_monitor_suspend(True)\n# Disable and reset auto-update / auto-sync features\n- g.ADDON.setSettingInt('lib_auto_upd_mode', 0)\n+ g.ADDON.setSettingInt('lib_auto_upd_mode', 1)\ng.ADDON.setSettingBool('lib_sync_mylist', False)\ng.SHARED_DB.delete_key('sync_mylist_profile_guid')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "@@ -71,8 +71,13 @@ def _perform_service_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\nfrom resources.lib.common import debug, is_less_version\ndebug('Initialize service upgrade operations, from version {} to {})', previous_ver, current_ver)\n+ if previous_ver and is_less_version(previous_ver, '1.2.0'):\n+ # In the version 1.2.0 has been implemented a new cache management\nfrom resources.lib.upgrade_actions import delete_cache_folder\ndelete_cache_folder()\n+ # In the version 1.2.0 has been implemented in auto-update mode setting the option to disable the feature\n+ lib_auto_upd_mode = g.ADDON.getSettingInt('lib_auto_upd_mode')\n+ g.ADDON.setSettingInt('lib_auto_upd_mode', lib_auto_upd_mode + 1)\n# Always leave this to last - After the operations set current version\ng.LOCAL_DB.set_value('service_previous_version', current_ver)\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "</category>\n<category label=\"30025\"><!--Library-->\n<setting label=\"30065\" type=\"lsep\"/><!--Auto-Update-->\n- <setting id=\"lib_auto_upd_mode\" type=\"enum\" label=\"30224\" lvalues=\"30225|30226\" default=\"0\"/>\n- <setting id=\"lib_auto_upd_check_now\" type=\"action\" label=\"30230\" action=\"RunPlugin(plugin://plugin.video.netflix/library/auto_upd_run_now/)\" subsetting=\"true\"/>\n- <setting id=\"lib_auto_upd_freq\" type=\"enum\" label=\"30064\" lvalues=\"30067|30068|30069|30070\" default=\"0\" visible=\"gt(-2,0)\" subsetting=\"true\"/>\n- <setting id=\"lib_auto_upd_start\" type=\"time\" label=\"30071\" visible=\"gt(-3,0)\" default=\"00:00\" subsetting=\"true\"/>\n- <setting id=\"lib_auto_upd_wait_idle\" type=\"bool\" label=\"30072\" visible=\"gt(-4,0)\" default=\"false\" subsetting=\"true\"/>\n- <setting id=\"lib_auto_upd_disable_notification\" type=\"bool\" label=\"30219\" default=\"false\" visible=\"gt(-5,0)\" subsetting=\"true\"/>\n+ <setting id=\"lib_auto_upd_mode\" type=\"enum\" label=\"30224\" lvalues=\"13106|30225|30226\" default=\"1\"/>\n+ <setting id=\"lib_auto_upd_check_now\" type=\"action\" label=\"30230\" action=\"RunPlugin(plugin://plugin.video.netflix/library/auto_upd_run_now/)\" visible=\"gt(-1,0)\" subsetting=\"true\"/>\n+ <setting id=\"lib_auto_upd_freq\" type=\"enum\" label=\"30064\" lvalues=\"30067|30068|30069|30070\" default=\"0\" visible=\"gt(-2,1)\" subsetting=\"true\"/>\n+ <setting id=\"lib_auto_upd_start\" type=\"time\" label=\"30071\" visible=\"gt(-3,1)\" default=\"00:00\" subsetting=\"true\"/>\n+ <setting id=\"lib_auto_upd_wait_idle\" type=\"bool\" label=\"30072\" visible=\"gt(-4,1)\" default=\"false\" subsetting=\"true\"/>\n+ <setting id=\"lib_auto_upd_disable_notification\" type=\"bool\" label=\"30219\" default=\"false\" visible=\"gt(-5,1)\" subsetting=\"true\"/>\n<setting label=\"30227\" type=\"lsep\"/><!--Synchronize Kodi library with My List-->\n- <setting id=\"lib_sync_mylist\" type=\"bool\" label=\"30114\" default=\"false\" enable=\"gt(-7,0)\"/>\n- <setting id=\"lib_sync_mylist_sel_profile\" type=\"action\" label=\"30228\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist_sel_profile/)\" enable=\"eq(-1,true) + gt(-8,0)\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n- <setting id=\"lib_sync_mylist_shw_profile\" type=\"action\" label=\"30229\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist_shw_profile/)\" enable=\"eq(-2,true) + gt(-9,0)\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n- <setting id=\"lib_sync_mylist_now\" type=\"action\" label=\"30121\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist/)\" enable=\"eq(-3,true) + gt(-10,0)\" visible=\"eq(-3,true)\" subsetting=\"true\"/>\n+ <setting id=\"lib_sync_mylist\" type=\"bool\" label=\"30114\" default=\"false\" enable=\"gt(-7,1)\"/>\n+ <setting id=\"lib_sync_mylist_sel_profile\" type=\"action\" label=\"30228\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist_sel_profile/)\" enable=\"eq(-1,true) + gt(-8,1)\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n+ <setting id=\"lib_sync_mylist_shw_profile\" type=\"action\" label=\"30229\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist_shw_profile/)\" enable=\"eq(-2,true) + gt(-9,1)\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n+ <setting id=\"lib_sync_mylist_now\" type=\"action\" label=\"30121\" action=\"RunPlugin(plugin://plugin.video.netflix/library/sync_mylist/)\" enable=\"eq(-3,true) + gt(-10,1)\" visible=\"eq(-3,true)\" subsetting=\"true\"/>\n<setting label=\"30184\" type=\"lsep\"/><!--NFO Files-->\n<setting id=\"enable_nfo_export\" type=\"bool\" label=\"30185\" default=\"false\"/>\n<setting id=\"export_movie_nfo\" type=\"enum\" label=\"30186\" lvalues=\"21337|20422|30188\" visible=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented disable option to library auto-update mode Allow to disable all functionality with the Kodi library, including menus
106,046
11.04.2020 19:56:28
-7,200
9bba8ed829a8744ba9faa09e9d9542f04926c288
Use a common description for color settings
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.de_de/strings.po", "new_path": "resources/language/resource.language.de_de/strings.po", "diff": "@@ -845,7 +845,7 @@ msgid \"Force the update of my list\"\nmsgstr \"Aktualisierung meiner Liste erzwingen\"\nmsgctxt \"#30215\"\n-msgid \"Highlight titles included in my list with a color\"\n+msgid \"Color of the titles included in My list\"\nmsgstr \"Titel aus meiner Liste farblich hervorheben\"\nmsgctxt \"#30216\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -847,7 +847,7 @@ msgid \"Force the update of my list\"\nmsgstr \"\"\nmsgctxt \"#30215\"\n-msgid \"Highlight titles included in my list with a color\"\n+msgid \"Color of the titles included in My list\"\nmsgstr \"\"\nmsgctxt \"#30216\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.it_it/strings.po", "new_path": "resources/language/resource.language.it_it/strings.po", "diff": "@@ -845,7 +845,7 @@ msgid \"Force the update of my list\"\nmsgstr \"Forza l'aggiornamento della mia lista\"\nmsgctxt \"#30215\"\n-msgid \"Highlight titles included in my list with a color\"\n+msgid \"Color of the titles included in My list\"\nmsgstr \"Evidenzia con un colore i titoli inclusi nella mia lista\"\nmsgctxt \"#30216\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.nl_nl/strings.po", "new_path": "resources/language/resource.language.nl_nl/strings.po", "diff": "@@ -845,7 +845,7 @@ msgid \"Force the update of my list\"\nmsgstr \"Forceer de vernieuwing van Mijn lijst\"\nmsgctxt \"#30215\"\n-msgid \"Highlight titles included in my list with a color\"\n+msgid \"Color of the titles included in My list\"\nmsgstr \"Benadruk titels uit Mijn lijst met een kleur\"\nmsgctxt \"#30216\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Use a common description for color settings
106,046
12.04.2020 09:42:12
-7,200
40eaddc1b3e4f677e36deab5e0ef1a29edc39d8c
Use common selective imports
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_actions.py", "new_path": "resources/lib/upgrade_actions.py", "diff": "@@ -14,7 +14,8 @@ import os\nimport xbmc\nimport xbmcvfs\n-from resources.lib.common import delete_folder_contents, debug, error\n+from resources.lib.common.fileops import delete_folder_contents\n+from resources.lib.common.logging import debug, error\nfrom resources.lib.globals import g\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-# import resources.lib.upgrade_actions as upgrade_actions\n-from resources.lib.globals import g\n+from resources.lib.common.logging import debug\n+from resources.lib.common.misc_utils import is_less_version, is_minimum_version\nfrom resources.lib.database.db_update import run_local_db_updates, run_shared_db_updates\n+from resources.lib.globals import g\ndef check_addon_upgrade():\n@@ -20,7 +21,6 @@ def check_addon_upgrade():\n:return True if this is the first run of the add-on after an installation from scratch\n\"\"\"\n- from resources.lib.common import is_less_version\n# Upgrades that require user interaction or to be performed outside of the service\naddon_previous_ver = g.LOCAL_DB.get_value('addon_previous_version', None)\naddon_current_ver = g.VERSION\n@@ -31,7 +31,6 @@ def check_addon_upgrade():\ndef check_service_upgrade():\n\"\"\"Check service upgrade and perform necessary update operations\"\"\"\n- from resources.lib.common import is_less_version\n# Upgrades to be performed before starting the service\n# Upgrade the local database\ncurrent_local_db_version = g.LOCAL_DB.get_value('local_db_version', None)\n@@ -54,7 +53,6 @@ def check_service_upgrade():\ndef _perform_addon_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\n- from resources.lib.common import debug, is_less_version\ndebug('Initialize addon upgrade operations, from version {} to {})', previous_ver, current_ver)\nif previous_ver and is_less_version(previous_ver, '0.15.9'):\nimport resources.lib.kodi.ui as ui\n@@ -69,7 +67,6 @@ def _perform_addon_changes(previous_ver, current_ver):\ndef _perform_service_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\n- from resources.lib.common import debug, is_less_version\ndebug('Initialize service upgrade operations, from version {} to {})', previous_ver, current_ver)\nif previous_ver and is_less_version(previous_ver, '1.2.0'):\n# In the version 1.2.0 has been implemented a new cache management\n@@ -85,7 +82,6 @@ def _perform_service_changes(previous_ver, current_ver):\ndef _perform_local_db_changes(current_version, upgrade_to_version):\n\"\"\"Perform database actions for a db version change\"\"\"\nif current_version is not None:\n- from resources.lib.common import debug\ndebug('Initialization of local database updates from version {} to {})', current_version, upgrade_to_version)\nrun_local_db_updates(current_version, upgrade_to_version)\ng.LOCAL_DB.set_value('local_db_version', upgrade_to_version)\n@@ -96,7 +92,6 @@ def _perform_shared_db_changes(current_version, upgrade_to_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\nservice_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\nif service_previous_ver is not None and\\\ncurrent_version is None and\\\n@@ -105,7 +100,6 @@ def _perform_shared_db_changes(current_version, upgrade_to_version):\n# End fix\nif current_version is not None:\n- from resources.lib.common import debug\ndebug('Initialization of shared databases updates from version {} to {})', current_version, upgrade_to_version)\nrun_shared_db_updates(current_version, upgrade_to_version)\ng.LOCAL_DB.set_value('shared_db_version', upgrade_to_version)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Use common selective imports
106,046
12.04.2020 14:14:28
-7,200
81de221a4781cd1fa5842228f4ed266843371369
Removed unmaintained Swedish-Sweden translation
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<screenshot>resources/media/screenshot-04.jpg</screenshot>\n<screenshot>resources/media/screenshot-05.jpg</screenshot>\n</assets>\n- <language>en cs de es hr hu it ja ko nl pl pt sv tr</language>\n+ <language>en cs de es hr hu it ja ko nl pl pt tr</language>\n<platform>all</platform>\n<license>MIT</license>\n<website>https://www.netflix.com</website>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Removed unmaintained Swedish-Sweden translation
106,046
13.04.2020 10:23:20
-7,200
69db617466d93b423e24920bf809511b01175ac7
Handle possible MySQL errors on initialization
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_base_mysql.py", "new_path": "resources/lib/database/db_base_mysql.py", "diff": "@@ -83,7 +83,10 @@ class MySQLDatabase(db_base.BaseDatabase):\nreturn\nexcept mysql.connector.Error as e:\ncommon.error('MySql error {}:', e)\n- raise MySQLConnectionError\n+ if e.errno == 1115: # Unknown character set: 'utf8mb4'\n+ # Means an outdated MySQL/MariaDB version in use, needed MySQL => 5.5.3 or MariaDB => 5.5\n+ raise MySQLError('Your MySQL/MariaDB version is outdated, consider an upgrade')\n+ raise MySQLError(str(e))\ncommon.error('MySql error {}:', exc)\nraise MySQLConnectionError\nfinally:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -270,15 +270,18 @@ class GlobalVariables(object):\nuse_mysql = g.ADDON.getSettingBool('use_mysql')\nif initialize or use_mysql:\nimport resources.lib.database.db_shared as db_shared\n- from resources.lib.database.db_exceptions import MySQLConnectionError\n+ from resources.lib.database.db_exceptions import MySQLConnectionError, MySQLError\ntry:\nshared_db_class = db_shared.get_shareddb_class(use_mysql=use_mysql)\nself.SHARED_DB = shared_db_class()\n- except MySQLConnectionError:\n+ except (MySQLConnectionError, MySQLError) as exc:\n+ import resources.lib.kodi.ui as ui\n+ if isinstance(exc, MySQLError):\n+ # There is a problem with the database\n+ ui.show_addon_error_info(exc)\n# The MySQL database cannot be reached, fallback to local SQLite database\n# When this code is called from addon, is needed apply the change also in the\n# service, so disabling it run the SettingsMonitor\n- import resources.lib.kodi.ui as ui\nself.ADDON.setSettingBool('use_mysql', False)\nui.show_notification(self.ADDON.getLocalizedString(30206), time=10000)\nshared_db_class = db_shared.get_shareddb_class()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Handle possible MySQL errors on initialization
106,046
14.04.2020 16:01:49
-7,200
f7a82d008293fd987684b5411235f5ac423ac11d
Improved skip button now the button adapts in width to the text, there should no longer be cases of scrolling text other little refinements
[ { "change_type": "MODIFY", "old_path": "resources/skins/default/1080i/plugin-video-netflix-Skip.xml", "new_path": "resources/skins/default/1080i/plugin-video-netflix-Skip.xml", "diff": "<defaultcontrol always=\"true\">6012</defaultcontrol>\n<zorder>0</zorder>\n<controls>\n- <control type=\"group\">\n+ <control type=\"grouplist\">\n+ <align>right</align>\n+ <orientation>horizontal</orientation>\n<right>30</right>\n- <bottom>60</bottom>\n+ <bottom>30</bottom>\n<height>80</height>\n- <width>250</width>\n- <control type=\"group\">\n+ <width>600</width>\n<control type=\"button\" id=\"6012\">\n<description>Skip intro</description>\n- <width>250</width>\n+ <width max=\"600\">auto</width>\n<height>80</height>\n- <font>font12</font>\n+ <font>\n+ <name>font12</name>\n+ <size>12</size>\n+ <style>bold</style>\n+ </font>\n<label></label>\n<textcolor>FFededed</textcolor>\n<focusedcolor>FFededed</focusedcolor>\n<selectedcolor>FFededed</selectedcolor>\n<shadowcolor>66000000</shadowcolor>\n- <textoffsetx>20</textoffsetx>\n+ <textoffsetx>30</textoffsetx>\n<aligny>center</aligny>\n<align>center</align>\n- <texturefocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturefocus>\n- <texturenofocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturenofocus>\n+ <texturefocus border=\"10\" colordiffuse=\"B3000000\">smallbutton.png</texturefocus> <!-- Color ARGB: B3=70% transparency -->\n+ <texturenofocus border=\"10\" colordiffuse=\"B3000000\">smallbutton.png</texturenofocus>\n<animation effect=\"fade\" start=\"0\" end=\"100\" time=\"200\">WindowOpen</animation>\n<animation effect=\"fade\" start=\"100\" end=\"0\" time=\"200\">WindowClose</animation>\n</control>\n</control>\n- </control>\n</controls>\n</window>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Improved skip button now the button adapts in width to the text, there should no longer be cases of scrolling text other little refinements
106,046
15.04.2020 09:35:08
-7,200
8a62c3223e480a6d2681abf923728f7011a19dc6
Remove codename suffix from versions
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -206,7 +206,8 @@ class GlobalVariables(object):\nself.ADDON = xbmcaddon.Addon()\nself.ADDON_ID = self.py2_decode(self.ADDON.getAddonInfo('id'))\nself.PLUGIN = self.py2_decode(self.ADDON.getAddonInfo('name'))\n- self.VERSION = self.py2_decode(self.ADDON.getAddonInfo('version'))\n+ self.VERSION_RAW = self.py2_decode(self.ADDON.getAddonInfo('version'))\n+ self.VERSION = self.remove_ver_suffix(self.VERSION_RAW)\nself.DEFAULT_FANART = self.py2_decode(self.ADDON.getAddonInfo('fanart'))\nself.ICON = self.py2_decode(self.ADDON.getAddonInfo('icon'))\nself.ADDON_DATA_PATH = self.py2_decode(self.ADDON.getAddonInfo('path')) # Addon folder\n@@ -377,6 +378,13 @@ class GlobalVariables(object):\nreturn value.encode('utf-8')\nreturn value\n+ @staticmethod\n+ def remove_ver_suffix(version):\n+ \"\"\"Remove the codename suffix from version value\"\"\"\n+ import re\n+ pattern = re.compile(r'\\+\\w+\\.\\d$') # Example: +matrix.1\n+ return re.sub(pattern, '', version)\n+\n# pylint: disable=invalid-name\n# This will have no effect most of the time, as it doesn't seem to be executed\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -164,7 +164,7 @@ def run(argv):\ng.init_globals(argv)\nreset_log_level_global_var()\n- info('Started (Version {})'.format(g.VERSION))\n+ info('Started (Version {})'.format(g.VERSION_RAW))\ninfo('URL is {}'.format(g.URL))\nsuccess = True\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -18,7 +18,7 @@ import resources.lib.common as common\ndef convert_to_dash(manifest):\n\"\"\"Convert a Netflix style manifest to MPEG-DASH manifest\"\"\"\nfrom xbmcaddon import Addon\n- isa_version = Addon('inputstream.adaptive').getAddonInfo('version')\n+ isa_version = g.remove_ver_suffix(g.py2_decode(Addon('inputstream.adaptive').getAddonInfo('version')))\nhas_drm_streams = manifest['hasDrmStreams']\nprotection_info = _get_protection_info(manifest) if has_drm_streams else None\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/profiles.py", "new_path": "resources/lib/services/msl/profiles.py", "diff": "\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n-import xbmcaddon\n-\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n@@ -93,10 +91,11 @@ def enabled_profiles():\ndef _subtitle_profiles():\n- isversion = xbmcaddon.Addon('inputstream.adaptive').getAddonInfo('version')\n+ from xbmcaddon import Addon\n+ isa_version = g.remove_ver_suffix(g.py2_decode(Addon('inputstream.adaptive').getAddonInfo('version')))\nsubtitle_profile = ['webvtt-lssdh-ios8']\nif g.ADDON.getSettingBool('disable_webvtt_subtitle') \\\n- or not common.is_minimum_version(isversion, '2.3.8'):\n+ or not common.is_minimum_version(isa_version, '2.3.8'):\nsubtitle_profile = ['simplesdh']\nreturn subtitle_profile\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Remove codename suffix from versions
106,046
15.04.2020 09:39:44
-7,200
290695ce2eb07173d5c71db5f119ce24697530e1
Set a good variable name
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -194,9 +194,8 @@ def convert_seconds_to_hms_str(time):\ndef remove_html_tags(raw_html):\nimport re\n- h = re.compile('<.*?>')\n- text = re.sub(h, '', raw_html)\n- return text\n+ pattern = re.compile('<.*?>')\n+ return re.sub(pattern, '', raw_html)\ndef censure(value, length=3):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Set a good variable name
106,046
16.04.2020 11:54:39
-7,200
60b2ba7edb7490fede77b8c647d77f80bed6e454
Fixed wrong property and other changes my bad missread kodi instructions for font
[ { "change_type": "MODIFY", "old_path": "resources/skins/default/1080i/plugin-video-netflix-Skip.xml", "new_path": "resources/skins/default/1080i/plugin-video-netflix-Skip.xml", "diff": "<orientation>horizontal</orientation>\n<right>30</right>\n<bottom>30</bottom>\n- <height>80</height>\n+ <height>60</height>\n<width>600</width>\n<control type=\"button\" id=\"6012\">\n<description>Skip intro</description>\n<width max=\"600\">auto</width>\n- <height>80</height>\n- <font>\n- <name>font12</name>\n- <size>12</size>\n- <style>bold</style>\n- </font>\n+ <height>60</height>\n+ <font>font20_title</font>\n<label></label>\n<textcolor>FFededed</textcolor>\n<focusedcolor>FFededed</focusedcolor>\n<textoffsetx>30</textoffsetx>\n<aligny>center</aligny>\n<align>center</align>\n- <texturefocus border=\"10\" colordiffuse=\"B3000000\">smallbutton.png</texturefocus> <!-- Color ARGB: B3=70% transparency -->\n- <texturenofocus border=\"10\" colordiffuse=\"B3000000\">smallbutton.png</texturenofocus>\n+ <texturefocus border=\"10\" colordiffuse=\"B3161618\">smallbutton.png</texturefocus> <!-- Color ARGB: B3=70% transparency -->\n+ <texturenofocus border=\"10\" colordiffuse=\"B3161618\">smallbutton.png</texturenofocus>\n<animation effect=\"fade\" start=\"0\" end=\"100\" time=\"200\">WindowOpen</animation>\n<animation effect=\"fade\" start=\"100\" end=\"0\" time=\"200\">WindowClose</animation>\n</control>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed wrong property and other changes my bad missread kodi instructions for font
106,046
16.04.2020 11:59:28
-7,200
174a4669c1b5a415a080ca614c65f65412a1113a
Handle cases of error in servers initialization of service Before was cause of possible break of service and the user had no way of knowing what was going on
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -403,7 +403,7 @@ msgid \"Netflix returned the following error:\"\nmsgstr \"\"\nmsgctxt \"#30103\"\n-msgid \"Error details have been written to the Kodi logfile. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it via GitHub. Please provide a full debug log with your error report (enable \\\"Debug Logging\\\" in Kodi settings).\"\n+msgid \"Error details have been written to the Kodi log file. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, make a report by following the ReadMe instructions on GitHub.\"\nmsgstr \"\"\nmsgctxt \"#30104\"\n@@ -945,3 +945,7 @@ msgstr \"\"\nmsgctxt \"#30239\"\nmsgid \"Color of supplemental plot info\"\nmsgstr \"\"\n+\n+msgctxt \"#30240\"\n+msgid \"The background services cannot be started due to this problem:\\r\\n{}\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -16,10 +16,15 @@ 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, get_local_string)\nfrom resources.lib.upgrade_controller import check_addon_upgrade\n+def _handle_endofdirectory(succeeded=False):\n+ from xbmcplugin import endOfDirectory\n+ endOfDirectory(handle=g.PLUGIN_HANDLE, succeeded=succeeded)\n+\n+\ndef lazy_login(func):\n\"\"\"\nDecorator to ensure that a valid login is present when calling a method\n@@ -67,6 +72,23 @@ def route(pathitems):\n_execute(nav_handler, pathitems[1:], g.REQUEST_PARAMS)\n+def _get_nav_handler(root_handler):\n+ nav_handler = None\n+ if root_handler == g.MODE_DIRECTORY:\n+ from resources.lib.navigation.directory import DirectoryBuilder\n+ nav_handler = DirectoryBuilder\n+ if root_handler == g.MODE_ACTION:\n+ from resources.lib.navigation.actions import AddonActionExecutor\n+ nav_handler = AddonActionExecutor\n+ if root_handler == g.MODE_LIBRARY:\n+ from resources.lib.navigation.library import LibraryActionExecutor\n+ nav_handler = LibraryActionExecutor\n+ if root_handler == g.MODE_HUB:\n+ from resources.lib.navigation.hub import HubBrowser\n+ nav_handler = HubBrowser\n+ return nav_handler\n+\n+\ndef _execute(executor_type, pathitems, params):\n\"\"\"Execute an action as specified by the path\"\"\"\ntry:\n@@ -78,6 +100,15 @@ def _execute(executor_type, pathitems, params):\nexecutor(pathitems=pathitems)\n+def _get_service_status(window_cls, prop_nf_service_status):\n+ from json import loads\n+ try:\n+ status = window_cls.getProperty(prop_nf_service_status)\n+ return loads(status) if status else {}\n+ except Exception: # pylint: disable=broad-except\n+ return {}\n+\n+\ndef _check_addon_external_call(window_cls, prop_nf_service_status):\n\"\"\"Check system to verify if the calls to the add-on are originated externally\"\"\"\n# The calls that are made from outside do not respect and do not check whether the services required\n@@ -107,7 +138,7 @@ def _check_addon_external_call(window_cls, prop_nf_service_status):\nif is_other_plugin_name or not getCondVisibility(\"Window.IsMedia\"):\nmonitor = Monitor()\nsec_elapsed = 0\n- while not window_cls.getProperty(prop_nf_service_status) == 'running':\n+ while not _get_service_status(window_cls, prop_nf_service_status).get('status') == 'running':\nif sec_elapsed >= limit_sec or monitor.abortRequested() or monitor.waitForAbort(0.5):\nbreak\nsec_elapsed += 0.5\n@@ -117,23 +148,6 @@ def _check_addon_external_call(window_cls, prop_nf_service_status):\nreturn False\n-def _get_nav_handler(root_handler):\n- nav_handler = None\n- if root_handler == g.MODE_DIRECTORY:\n- from resources.lib.navigation.directory import DirectoryBuilder\n- nav_handler = DirectoryBuilder\n- if root_handler == g.MODE_ACTION:\n- from resources.lib.navigation.actions import AddonActionExecutor\n- nav_handler = AddonActionExecutor\n- if root_handler == g.MODE_LIBRARY:\n- from resources.lib.navigation.library import LibraryActionExecutor\n- nav_handler = LibraryActionExecutor\n- if root_handler == g.MODE_HUB:\n- from resources.lib.navigation.hub import HubBrowser\n- nav_handler = HubBrowser\n- return nav_handler\n-\n-\ndef _check_valid_credentials():\n\"\"\"Check that credentials are valid otherwise request user credentials\"\"\"\n# This function check only if credentials exist, instead lazy_login\n@@ -151,11 +165,6 @@ def _check_valid_credentials():\nreturn True\n-def _handle_endofdirectory(succeeded=False):\n- from xbmcplugin import endOfDirectory\n- endOfDirectory(handle=g.PLUGIN_HANDLE, succeeded=succeeded)\n-\n-\ndef run(argv):\n# pylint: disable=broad-except,ungrouped-imports\n# Initialize globals right away to avoid stale values from the last addon invocation.\n@@ -173,9 +182,17 @@ def run(argv):\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_external_call = _check_addon_external_call(window_cls, prop_nf_service_status)\n+ service_status = _get_service_status(window_cls, prop_nf_service_status)\n- if window_cls.getProperty(prop_nf_service_status) != 'running':\n+ if service_status.get('status') != 'running':\nif not is_external_call:\n+ if service_status.get('status') == 'error':\n+ # The services are not started due to an error exception\n+ from resources.lib.kodi.ui import show_error_info\n+ show_error_info(get_local_string(30105), get_local_string(30240).format(service_status.get('message')),\n+ False, False)\n+ else:\n+ # The services are not started yet\nfrom resources.lib.kodi.ui import show_backend_not_ready\nshow_backend_not_ready()\nsuccess = False\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_service.py", "new_path": "resources/lib/run_service.py", "diff": "from __future__ import absolute_import, division, unicode_literals\nimport threading\n+from socket import gaierror\nfrom xbmcgui import Window\n@@ -52,21 +53,38 @@ class NetflixService(object):\n'thread': None\n}\n]\n+ HOST_ADDRESS = '127.0.0.1'\ndef __init__(self):\nself.window_cls = Window(10000) # Kodi home window\n# If you use multiple Kodi profiles you need to distinguish the property of current profile\nself.prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name())\n- for server in self.SERVERS:\n- self.init_server(server)\nself.controller = None\nself.library_updater = None\nself.settings_monitor = None\n- def init_server(self, server):\n+ def init_servers(self):\n+ \"\"\"Initialize the http servers\"\"\"\n+ try:\n+ for server in self.SERVERS:\n+ self._init_server(server)\n+ return True\n+ except Exception as exc: # pylint: disable=broad-except\n+ error('Background services do not start due to the following error')\n+ import traceback\n+ error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n+ if isinstance(exc, gaierror):\n+ message = ('Something is wrong in your network localhost configuration.\\r\\n'\n+ 'It is possible that the hostname {} can not be resolved.').format(self.HOST_ADDRESS)\n+ else:\n+ message = unicode(exc)\n+ self._set_service_status('error', message)\n+ return False\n+\n+ def _init_server(self, server):\nserver['class'].allow_reuse_address = True\nserver['instance'] = server['class'](\n- ('127.0.0.1', select_port(server['name']))\n+ (self.HOST_ADDRESS, select_port(server['name']))\n)\nserver['thread'] = threading.Thread(target=server['instance'].serve_forever)\n@@ -86,7 +104,7 @@ class NetflixService(object):\nself.library_updater = LibraryUpdateService()\nself.settings_monitor = SettingsMonitor()\n# Mark the service as active\n- self.window_cls.setProperty(self.prop_nf_service_status, 'running')\n+ self._set_service_status('running')\nif not g.ADDON.getSettingBool('disable_startup_notification'):\nfrom resources.lib.kodi.ui import show_notification\nshow_notification(get_local_string(30110))\n@@ -95,7 +113,7 @@ class NetflixService(object):\n\"\"\"\nStop the background services\n\"\"\"\n- self.window_cls.setProperty(self.prop_nf_service_status, 'stopped')\n+ self._set_service_status('stopped')\nfor server in self.SERVERS:\nserver['instance'].shutdown()\nserver['instance'].server_close()\n@@ -109,7 +127,7 @@ class NetflixService(object):\ntry:\nself.start_services()\nexcept Exception as exc: # pylint: disable=broad-except\n- self.window_cls.setProperty(self.prop_nf_service_status, 'stopped')\n+ self._set_service_status('stopped')\nimport traceback\nfrom resources.lib.kodi.ui import show_addon_error_info\nerror(g.py2_decode(traceback.format_exc(), 'latin-1'))\n@@ -133,6 +151,12 @@ class NetflixService(object):\nshow_notification(': '.join((exc.__class__.__name__, unicode(exc))))\nreturn self.controller.waitForAbort(1)\n+ def _set_service_status(self, status, message=None):\n+ \"\"\"Save the service status to a Kodi property\"\"\"\n+ from json import dumps\n+ status = {'status': status, 'message': message}\n+ self.window_cls.setProperty(self.prop_nf_service_status, dumps(status))\n+\ndef run(argv):\n# Initialize globals right away to avoid stale values from the last addon invocation.\n@@ -140,4 +164,6 @@ def run(argv):\n# PR: https://github.com/xbmc/xbmc/pull/13814\ng.init_globals(argv)\ncheck_service_upgrade()\n- NetflixService().run()\n+ netflix_service = NetflixService()\n+ if netflix_service.init_servers():\n+ netflix_service.run()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Handle cases of error in servers initialization of service Before was cause of possible break of service and the user had no way of knowing what was going on
106,046
16.04.2020 13:18:31
-7,200
9d0107de2411f8eac9b0c8797dc2ce0a39a463e8
Implemented profile lock
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -48,7 +48,9 @@ msgctxt \"#30005\"\nmsgid \"E-mail\"\nmsgstr \"\"\n-# Unused 30006\n+msgctxt \"#30006\"\n+msgid \"Enter PIN to access this profile\"\n+msgstr \"\"\nmsgctxt \"#30007\"\nmsgid \"Parental Control PIN (4 digits)\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -347,3 +347,18 @@ def verify_pin(pin):\n).get('success', False)\nexcept Exception: # pylint: disable=broad-except\nreturn False\n+\n+\[email protected]_execution(immediate=False)\n+def verify_profile_lock(guid, pin):\n+ \"\"\"Send profile PIN to Netflix and verify it.\"\"\"\n+ try:\n+ return common.make_call(\n+ 'post',\n+ {'component': 'profile_lock',\n+ 'data': {'pin': pin,\n+ 'action': 'verify',\n+ 'guid': guid}}\n+ ).get('success', False)\n+ except Exception: # pylint: disable=broad-except\n+ return False\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/dialogs.py", "new_path": "resources/lib/kodi/ui/dialogs.py", "diff": "@@ -64,12 +64,12 @@ def ask_for_rating():\nreturn None\n-def ask_for_pin():\n+def ask_for_pin(message):\n\"\"\"Ask the user for the adult pin\"\"\"\n- return xbmcgui.Dialog().numeric(\n- heading=common.get_local_string(30002),\n- type=0,\n- defaultt='') or None\n+ args = {'heading': message,\n+ 'type': 0,\n+ 'defaultt': ''}\n+ return xbmcgui.Dialog().numeric(**args) or None\ndef ask_for_search_term():\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -19,7 +19,7 @@ import resources.lib.kodi.ui as ui\nfrom resources.lib.database.db_utils import TABLE_MENU_DATA\nfrom resources.lib.globals import g\nfrom resources.lib.navigation.directory_utils import (finalize_directory, convert_list, custom_viewmode,\n- end_of_directory, get_title)\n+ end_of_directory, get_title, verify_profile_pin)\n# What means dynamic menus (and dynamic id):\n# Are considered dynamic menus all menus which context name do not exists in the 'lolomo_contexts' of\n@@ -49,8 +49,6 @@ class DirectoryBuilder(object):\nif self.perpetual_range_start == '0':\n# For cache identifier purpose\nself.perpetual_range_start = None\n- if 'switch_profile_guid' in params:\n- api.activate_profile(params['switch_profile_guid'])\ndef root(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show profiles or home listing when profile auto-selection is enabled\"\"\"\n@@ -95,6 +93,15 @@ class DirectoryBuilder(object):\n@custom_viewmode(g.VIEW_MAINMENU)\ndef home(self, pathitems=None, cache_to_disc=True): # pylint: disable=unused-argument\n\"\"\"Show home listing\"\"\"\n+ if 'switch_profile_guid' in self.params:\n+ # This is executed only when you have selected a profile from the profile list\n+ pin_result = verify_profile_pin(self.params.get('switch_profile_guid'))\n+ if not pin_result:\n+ if pin_result is not None:\n+ ui.show_notification(common.get_local_string(30106), time=8000)\n+ xbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\n+ return\n+ api.activate_profile(self.params['switch_profile_guid'])\ncommon.debug('Showing home listing')\nlist_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory_utils.py", "new_path": "resources/lib/navigation/directory_utils.py", "diff": "@@ -18,8 +18,10 @@ import xbmcgui\nimport xbmcplugin\nimport resources.lib.common as common\n+from resources.lib.api.api_requests import verify_profile_lock\nfrom resources.lib.database.db_utils import TABLE_MENU_DATA\nfrom resources.lib.globals import g\n+from resources.lib.kodi.ui import ask_for_pin\ndef custom_viewmode(partial_setting_id):\n@@ -123,3 +125,11 @@ def get_title(menu_data, extra_data):\ng.LOCAL_DB.get_value(menu_data['path'][1],\n{},\ntable=TABLE_MENU_DATA).get('title', '')))\n+\n+\n+def verify_profile_pin(guid):\n+ \"\"\"Verify if the profile is locked by a PIN and ask the PIN\"\"\"\n+ if not g.LOCAL_DB.get_profile_config('isPinLocked', False, guid=guid):\n+ return True\n+ pin = ask_for_pin(common.get_local_string(30006))\n+ return None if not pin else verify_profile_lock(guid, pin)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -75,7 +75,7 @@ def play(videoid):\npin_result = _verify_pin(metadata[0].get('requiresPin', False))\nif not pin_result:\nif pin_result is not None:\n- ui.show_notification(common.get_local_string(30106), time=10000)\n+ ui.show_notification(common.get_local_string(30106), time=8000)\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\nreturn\n@@ -188,7 +188,7 @@ def get_inputstream_listitem(videoid):\ndef _verify_pin(pin_required):\nif not pin_required:\nreturn True\n- pin = ui.ask_for_pin()\n+ pin = ui.ask_for_pin(common.get_local_string(30002))\nreturn None if not pin else api.verify_pin(pin)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -33,6 +33,7 @@ URLS = {\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+ 'profile_lock': {'endpoint': '/profileLock', 'is_api_call': True},\n'pin': {'endpoint': '/pin', 'is_api_call': False},\n'pin_reset': {'endpoint': '/pin/reset', 'is_api_call': True},\n'pin_service': {'endpoint': '/pin/service', 'is_api_call': True},\n@@ -154,7 +155,7 @@ class NFSessionRequests(NFSessionBase):\ndata = kwargs.get('data', {})\nheaders = kwargs.get('headers', {})\nparams = kwargs.get('params', {})\n- if component in ['set_video_rating', 'set_thumb_rating', 'update_my_list', 'pin_service']:\n+ if component in ['set_video_rating', 'set_thumb_rating', 'update_my_list', 'pin_service', 'profile_lock']:\nheaders.update({\n'Content-Type': 'application/json',\n'Accept': 'application/json, text/javascript, */*'})\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented profile lock
106,046
16.04.2020 13:48:11
-7,200
ac6be44981c7cc2f964fb0ed94a63f75ca57d713
Updated ids after
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -405,7 +405,7 @@ msgid \"Netflix returned the following error:\"\nmsgstr \"\"\nmsgctxt \"#30103\"\n-msgid \"Error details have been written to the Kodi log file. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, make a report by following the ReadMe instructions on GitHub.\"\n+msgid \"Error details have been written to the Kodi log file. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it on GitHub by following the Readme instructions.\"\nmsgstr \"\"\nmsgctxt \"#30104\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.it_it/strings.po", "new_path": "resources/language/resource.language.it_it/strings.po", "diff": "@@ -403,7 +403,7 @@ msgid \"Netflix returned the following error:\"\nmsgstr \"Netflix ha restituito il seguente errore:\"\nmsgctxt \"#30103\"\n-msgid \"Error details have been written to the Kodi logfile. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it via GitHub. Please provide a full debug log with your error report (enable \\\"Debug Logging\\\" in Kodi settings).\"\n+msgid \"Error details have been written to the Kodi log file. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it on GitHub by following the Readme instructions.\"\nmsgstr \"I dettagli dell'errore sono stati scritti nel file di log di Kodi. Se il messaggio di errore non fornisce indicazioni su come risolvere il problema o se l'errore continua a presentarsi, si prega di segnalarlo tramite GitHub. Nella segnalazione fornire un report dell'errore completo di log di debug (Attiva \\\"Logging di debug\\\" dalle impostazioni di Kodi).\"\nmsgctxt \"#30104\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.nl_nl/strings.po", "new_path": "resources/language/resource.language.nl_nl/strings.po", "diff": "@@ -401,7 +401,7 @@ msgid \"Netflix returned the following error:\"\nmsgstr \"Netflix had the volgende foutmelding:\"\nmsgctxt \"#30103\"\n-msgid \"Error details have been written to the Kodi logfile. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it via GitHub. Please provide a full debug log with your error report (enable \\\"Debug Logging\\\" in Kodi settings).\"\n+msgid \"Error details have been written to the Kodi log file. If the error message does not provide guidance on how to resolve the issue or you continue to receive this error, please report it on GitHub by following the Readme instructions.\"\nmsgstr \"Een gedetaileerde foutmelding werd weggeschreven in het Kodi logboek. Als de foutmelding niet helpt bij het oplossen van het probleem, of the probleem blijft zich voordoen, gelieve deze fout te melden op GitHub. Voeg de volledige debug log toe aan je probleemrapport (schakel \\\"Debug logboek\\\" in in de Kodi instellingen).\"\nmsgctxt \"#30104\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated ids after 174a466
106,046
16.04.2020 14:31:20
-7,200
843f8ec7ad9a985d0f9c3539783b25babb845e42
Fixed codeclimate deeply nested flow
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_tasks.py", "new_path": "resources/lib/kodi/library_tasks.py", "diff": "@@ -183,18 +183,20 @@ def _create_new_episodes_tasks(videoid, metadata, nfo_settings=None):\nif metadata and 'seasons' in metadata[0]:\nfor season in metadata[0]['seasons']:\nif not nfo_settings:\n- nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value,\n- VidLibProp['nfo_export'], False)\n+ nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value, VidLibProp['nfo_export'], False)\nnfo_settings = nfo.NFOSettings(nfo_export)\n+ # Check and add missing seasons and episodes\n+ _add_missing_items(tasks, season, videoid, metadata, nfo_settings)\n+ return tasks\n+\n+def _add_missing_items(tasks, season, videoid, metadata, nfo_settings):\nif g.SHARED_DB.season_id_exists(videoid.value, season['id']):\n# The season exists, try to find any missing episode\nfor episode in season['episodes']:\n- if not g.SHARED_DB.episode_id_exists(\n- videoid.value, season['id'], episode['id']):\n+ if not g.SHARED_DB.episode_id_exists(videoid.value, season['id'], episode['id']):\ntasks.append(_create_export_episode_task(\n- videoid=videoid.derive_season(\n- season['id']).derive_episode(episode['id']),\n+ videoid=videoid.derive_season(season['id']).derive_episode(episode['id']),\nepisode=episode,\nseason=season,\nshow=metadata[0],\n@@ -203,14 +205,13 @@ def _create_new_episodes_tasks(videoid, metadata, nfo_settings=None):\ncommon.debug('Auto exporting episode {}', episode['id'])\nelse:\n# The season does not exist, build task for the season\n- tasks += _compile_export_season_tasks(\n+ tasks.append(_compile_export_season_tasks(\nvideoid=videoid.derive_season(season['id']),\nshow=metadata[0],\nseason=season,\nnfo_settings=nfo_settings\n- )\n+ ))\ncommon.debug('Auto exporting season {}', season['id'])\n- return tasks\ndef _create_remove_movie_task(videoid):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed codeclimate deeply nested flow
106,046
16.04.2020 15:04:20
-7,200
28e1b20e7aed6f6d385646f423dde27910b10874
Changed line limit threshold per file
[ { "change_type": "MODIFY", "old_path": ".codeclimate.yml", "new_path": ".codeclimate.yml", "diff": "@@ -7,6 +7,11 @@ plugins:\nmarkdownlint:\nenabled: true\nchecks:\n+ file-lines:\n+ # There is no a real limit imposed, PyLint set it to 1000 lines and raccommanding a refactoring\n+ # A good development should be between 250 (default of CodeClimate) and 500 lines\n+ config:\n+ threshold: 400\nmethod-complexity:\nconfig:\nthreshold: 10\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Changed line limit threshold per file
106,046
16.04.2020 15:40:50
-7,200
a82d811f7ae1ef59586c9984721e9d50b36b8fac
Add profile lock check to profile autoselection
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -73,7 +73,7 @@ class DirectoryBuilder(object):\ng.settings_monitor_suspend(False)\nelse:\ncommon.info('Performing auto-selection of profile {}', autoselect_profile_guid)\n- api.activate_profile(autoselect_profile_guid)\n+ if self._activate_profile(autoselect_profile_guid):\nself.home(None, False)\nreturn True\nreturn False\n@@ -95,13 +95,9 @@ class DirectoryBuilder(object):\n\"\"\"Show home listing\"\"\"\nif 'switch_profile_guid' in self.params:\n# This is executed only when you have selected a profile from the profile list\n- pin_result = verify_profile_pin(self.params.get('switch_profile_guid'))\n- if not pin_result:\n- if pin_result is not None:\n- ui.show_notification(common.get_local_string(30106), time=8000)\n+ if not self._activate_profile(self.params['switch_profile_guid']):\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\nreturn\n- api.activate_profile(self.params['switch_profile_guid'])\ncommon.debug('Showing home listing')\nlist_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable\n@@ -110,6 +106,15 @@ class DirectoryBuilder(object):\n' - ' + common.get_local_string(30097)))\nend_of_directory(False, cache_to_disc)\n+ def _activate_profile(self, guid):\n+ pin_result = verify_profile_pin(guid)\n+ if not pin_result:\n+ if pin_result is not None:\n+ ui.show_notification(common.get_local_string(30106), time=8000)\n+ return False\n+ api.activate_profile(guid)\n+ return True\n+\[email protected]_execution(immediate=False)\[email protected]_video_id(path_offset=0, inject_full_pathitems=True)\ndef show(self, videoid, pathitems):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add profile lock check to profile autoselection
106,046
20.04.2020 12:46:34
-7,200
30012824474429e76539677a4b71575140112f8b
Implemented numeric mask input
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/dialogs.py", "new_path": "resources/lib/kodi/ui/dialogs.py", "diff": "@@ -69,6 +69,8 @@ def ask_for_pin(message):\nargs = {'heading': message,\n'type': 0,\n'defaultt': ''}\n+ if not g.KODI_VERSION.is_major_ver('18'): # Kodi => 19.x support mask input\n+ args['bHiddenInput'] = True\nreturn xbmcgui.Dialog().numeric(**args) or None\n" }, { "change_type": "MODIFY", "old_path": "tests/xbmcgui.py", "new_path": "tests/xbmcgui.py", "diff": "@@ -136,7 +136,8 @@ class Dialog:\nreturn 'Foobar'\n@staticmethod\n- def numeric(type, heading, defaultt=''): # pylint: disable=redefined-builtin\n+ # def numeric(type, heading, defaultt=''): # Kodi 18\n+ def numeric(type, heading, defaultt='', bHiddenInput=False): # pylint: disable=redefined-builtin\n\"\"\"A stub implementation for the xbmcgui Dialog class numeric() method\"\"\"\nreturn\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented numeric mask input (#570)
106,046
20.04.2020 12:48:42
-7,200
97f1ef51cd08bc8593a030558f939349a7cc3670
Updated metadata request
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -296,6 +296,7 @@ def _metadata(video_id):\n\"\"\"Retrieve additional metadata for a video.This is a separate method from\nmetadata(videoid) to work around caching issues when new episodes are added\nto a show by Netflix.\"\"\"\n+ import time\ncommon.debug('Requesting metadata for {}', video_id)\n# Always use params 'movieid' to all videoid identifier\nipc_call = common.make_http_call if g.IS_SERVICE else common.make_call\n@@ -303,8 +304,8 @@ def _metadata(video_id):\n'get',\n{\n'component': 'metadata',\n- 'req_type': 'api',\n- 'params': {'movieid': video_id.value}\n+ 'params': {'movieid': video_id.value,\n+ '_': int(time.time())}\n})\nif not metadata_data:\n# This return empty\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated metadata request
106,046
20.04.2020 12:50:13
-7,200
b6126dff294398c3125e3a86bd1c4f6dda23fd78
Do not broken service in case of InvalidMembershipStatusAnonymous
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -24,7 +24,7 @@ from resources.lib.services.nfsession.nfsession_requests import NFSessionRequest\nfrom resources.lib.services.nfsession.nfsession_cookie import NFSessionCookie\nfrom resources.lib.api.exceptions import (LoginFailedError, LoginValidateError,\nMissingCredentialsError, InvalidMembershipStatusError,\n- LoginValidateErrorIncorrectPassword)\n+ InvalidMembershipStatusAnonymous, LoginValidateErrorIncorrectPassword)\ntry: # Python 2\nunicode\n@@ -56,7 +56,7 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ncommon.info('Login prefetch: No stored credentials are available')\nexcept (LoginFailedError, LoginValidateError):\nui.show_notification(common.get_local_string(30009))\n- except InvalidMembershipStatusError:\n+ except (InvalidMembershipStatusError, InvalidMembershipStatusAnonymous):\nui.show_notification(common.get_local_string(30180), time=10000)\[email protected]_execution(immediate=True)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Do not broken service in case of InvalidMembershipStatusAnonymous
106,046
20.04.2020 12:51:25
-7,200
f3129f66fc90468d13c736a288b876b9f57cb080
Open directly login page instead redirect
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -95,7 +95,7 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ncurrent_esn = g.get_esn()\ntry:\n# First we get the authentication url without logging in, required for login API call\n- react_context = website.extract_json(self._get('profiles'), 'reactContext')\n+ react_context = website.extract_json(self._get('login'), 'reactContext')\nauth_url = website.extract_api_data(react_context)['auth_url']\ncommon.debug('Logging in...')\nlogin_response = self._post(\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Open directly login page instead redirect
106,046
20.04.2020 13:18:15
-7,200
bf28ec77d60dda050fe14704ef09f28d24187e92
Endpoints more configurable
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -80,6 +80,7 @@ def extract_session_data(content, validate=False):\nif user_data.get('membershipStatus') == 'ANONYMOUS':\n# Possible known causes:\n# -Login password has been changed\n+ # -In the login request, 'Content-Type' specified is not compliant with data passed or no more supported\n# -Expired profiles cookies!? (not verified)\n# In these cases it is mandatory to login again\nraise InvalidMembershipStatusAnonymous\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -15,7 +15,6 @@ 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.directorybuilder.dir_builder import DirectoryBuilder\nfrom resources.lib.services.nfsession.nfsession_access import NFSessionAccess\n@@ -84,7 +83,6 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\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})\n@@ -189,34 +187,14 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\ndef _path_request(self, paths):\n\"\"\"Execute a path request with static paths\"\"\"\ncommon.debug('Executing path request: {}', json.dumps(paths))\n- headers = {\n- 'Content-Type': 'application/x-www-form-urlencoded',\n- 'Accept': 'application/json, text/javascript, */*'}\n-\n- # params:\n- # drmSystem drm used\n- # falcor_server json responses like browser\n- # withSize puts the 'size' field inside each dictionary\n- # materialize if true, when a path that no longer exists is requested (like 'storyarts')\n- # it is still added in an 'empty' form in the response\n- params = {\n- 'drmSystem': 'widevine',\n- # 'falcor_server': '0.1.0',\n- 'withSize': '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+ custom_params = {\n+ 'method': 'call'\n}\n- data = 'path=' + '&path='.join(json.dumps(path) for path in paths)\n- data += '&authURL=' + self.auth_url\n+ # Use separators with dumps because Netflix rejects spaces\n+ data = 'path=' + '&path='.join(json.dumps(path, separators=(',', ':')) for path in paths)\nreturn self._post(\ncomponent='shakti',\n- req_type='api',\n- params=params,\n- headers=headers,\n+ params=custom_params,\ndata=data)['value']\[email protected]_return_call\n@@ -228,46 +206,33 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\[email protected]_execution(immediate=True)\ndef _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\ncommon.debug('Executing callPath request: {} params: {} path_suffixs: {}',\njson.dumps(callpaths),\nparams,\njson.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+ custom_params = {\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- 'original_path': '/shakti/{}/pathEvaluator'.format(\n- g.LOCAL_DB.get_value('build_identifier', '', TABLE_SESSION))\n}\n- data = 'callPath=' + '&callPath='.join(json.dumps(callpath) for callpath in callpaths)\n+ # Use separators with dumps because Netflix rejects spaces\n+ data = 'callPath=' + '&callPath='.join(\n+ json.dumps(callpath, separators=(',', ':')) for callpath in callpaths)\nif params:\n+ # 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 will raise error 401\n+ # if the parameters are not formatted correctly will raise error 401\ndata += '&param=' + '&param='.join(params)\nif 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+ data += '&pathSuffix=' + '&pathSuffix='.join(\n+ json.dumps(path_suffix, separators=(',', ':')) for path_suffix in path_suffixs)\n# common.debug('callPath request data: {}', data)\nresponse_data = self._post(\ncomponent='shakti',\n- req_type='api',\n- params=req_params,\n- headers=headers,\n+ params=custom_params,\ndata=data)\n- if 'falcor_server' in req_params:\nreturn response_data['jsonGraph']\n- return response_data['value']\ndef _set_range_selector(paths, range_start, range_end):\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"\n+ Copyright (C) 2017 Sebastian Golasch (plugin.video.netflix)\n+ Copyright (C) 2020 Stefano Gottardo - @CastagnaIT (original implementation module)\n+ Netflix API endpoints\n+\n+ SPDX-License-Identifier: MIT\n+ See LICENSES/MIT.md for more information.\n+\"\"\"\n+\n+# Secure Netflix url\n+BASE_URL = 'https://www.netflix.com'\n+\n+# List of all static endpoints for HTML/JSON POST/GET requests\n+\n+# is_api_call:\n+# specify which address to use for the endpoint\n+# True -> The https address used is composed with 'apiUrl' value from reactContext data\n+# False -> The https address used is composed with the BASE_URL\n+\n+# use_default_params:\n+# Add to the request the default parameters (see _prepare_request_properties)\n+\n+# add_auth_url:\n+# Specifies if and where to put the 'authURL' value\n+# None -> Will not be added\n+# 'to_data' -> It will be added with the data to send\n+# 'to_params' -> It will be added to the request parameters\n+\n+# content_type:\n+# If required add the Content-Type property to request header\n+\n+URLS = {\n+ 'login':\n+ {'endpoint': '/login',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None,\n+ # By default to login Netflix use 'application/x-www-form-urlencoded' Content-Type,\n+ # instead we use 'application/json' for simplicity of data conversion\n+ # if in the future login raise InvalidMembershipStatusAnonymous can means that json is no more accepted\n+ 'content_type': 'application/json'},\n+ 'logout':\n+ {'endpoint': '/SignOut',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'shakti':\n+ {'endpoint': '/pathEvaluator',\n+ 'is_api_call': True,\n+ 'use_default_params': True,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/x-www-form-urlencoded'},\n+ 'browse':\n+ {'endpoint': '/browse',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'profiles':\n+ {'endpoint': '/profiles/manage',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'switch_profile':\n+ {'endpoint': '/SwitchProfile',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'activate_profile':\n+ {'endpoint': '/profiles/switch',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'profile_lock':\n+ {'endpoint': '/profileLock',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/json'},\n+ 'pin':\n+ {'endpoint': '/pin',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'pin_reset':\n+ {'endpoint': '/pin/reset',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': None},\n+ 'pin_service':\n+ {'endpoint': '/pin/service',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/json'},\n+ 'metadata':\n+ {'endpoint': '/metadata',\n+ 'is_api_call': True,\n+ 'use_default_params': True,\n+ 'add_auth_url': 'to_params'},\n+ 'set_video_rating': # Old rating system\n+ {'endpoint': '/setVideoRating',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/json'},\n+ 'set_thumb_rating':\n+ {'endpoint': '/setThumbRating',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/json'},\n+ 'update_my_list':\n+ {'endpoint': '/playlistop',\n+ 'is_api_call': True,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'content_type': 'application/json'}\n+ # Don't know what these could be used for. Keeping for reference\n+ # 'video_list_ids': {'endpoint': '/preflight', 'is_api_call': True},\n+ # 'kids': {'endpoint': '/Kids', 'is_api_call': False}\n+}\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -21,32 +21,7 @@ from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.api.exceptions import (APIError, WebsiteParsingError,\nInvalidMembershipStatusError, InvalidMembershipStatusAnonymous,\nLoginValidateErrorIncorrectPassword)\n-\n-BASE_URL = 'https://www.netflix.com'\n-\"\"\"str: Secure Netflix url\"\"\"\n-\n-URLS = {\n- 'login': {'endpoint': '/login', 'is_api_call': False},\n- 'logout': {'endpoint': '/SignOut', 'is_api_call': False},\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- 'profile_lock': {'endpoint': '/profileLock', 'is_api_call': True},\n- 'pin': {'endpoint': '/pin', 'is_api_call': False},\n- 'pin_reset': {'endpoint': '/pin/reset', 'is_api_call': True},\n- 'pin_service': {'endpoint': '/pin/service', 'is_api_call': True},\n- 'metadata': {'endpoint': '/metadata', 'is_api_call': True},\n- 'set_video_rating': {'endpoint': '/setVideoRating', 'is_api_call': True}, # Old rating system\n- 'set_thumb_rating': {'endpoint': '/setThumbRating', 'is_api_call': True},\n- 'update_my_list': {'endpoint': '/playlistop', 'is_api_call': True},\n- # Don't know what these could be used for. Keeping for reference\n- # 'video_list_ids': {'endpoint': '/preflight', 'is_api_call': True},\n- # 'kids': {'endpoint': '/Kids', 'is_api_call': False}\n-}\n-# List of all static endpoints for HTML/JSON POST/GET requests\n-# How many entries of a list will be fetched with one path request\n+from resources.lib.services.nfsession.nfsession_endpoints import URLS, BASE_URL\nclass NFSessionRequests(NFSessionBase):\n@@ -86,8 +61,7 @@ class NFSessionRequests(NFSessionBase):\nelse _document_url(component))\ncommon.debug('Executing {verb} request to {url}',\nverb='GET' if method == self.session.get else 'POST', url=url)\n- data, headers, params = self._prepare_request_properties(component,\n- kwargs)\n+ data, headers, params = self._prepare_request_properties(component, kwargs)\nstart = common.perf_clock()\nresponse = method(\nurl=url,\n@@ -153,15 +127,49 @@ class NFSessionRequests(NFSessionBase):\ndef _prepare_request_properties(self, component, kwargs):\ndata = kwargs.get('data', {})\n- headers = kwargs.get('headers', {})\n- params = kwargs.get('params', {})\n- if component in ['set_video_rating', 'set_thumb_rating', 'update_my_list', 'pin_service', 'profile_lock']:\n- headers.update({\n- 'Content-Type': 'application/json',\n- 'Accept': 'application/json, text/javascript, */*'})\n+ custom_headers = kwargs.get('headers', {})\n+ custom_params = kwargs.get('params', {})\n+ params = {}\n+\n+ headers = {'Accept': '*/*'}\n+ if URLS[component].get('content_type'):\n+ headers['Content-Type'] = URLS[component]['content_type']\n+ headers.update(custom_headers) # If needed override headers\n+ # Meanings parameters known:\n+ # drmSystem DRM used\n+ # falcor_server Use JSON Graph (responses like browser)\n+ # withSize Puts the 'size' field inside each dictionary\n+ # materialize If True, when a path that no longer exists is requested (like 'storyarts')\n+ # it is still added in an 'empty' form in the response\n+ if URLS[component]['use_default_params']:\n+ params = {\n+ 'drmSystem': 'widevine',\n+ 'withSize': 'false',\n+ 'materialize': 'false',\n+ 'routeAPIRequestsThroughFTL': 'false',\n+ 'isVolatileBillboardsEnabled': 'true',\n+ 'isTop10Supported': 'true',\n+ 'isLocoSupported': 'false',\n+ 'original_path': '/shakti/{}/pathEvaluator'.format(\n+ g.LOCAL_DB.get_value('build_identifier', '', TABLE_SESSION))\n+ }\n+ if URLS[component]['add_auth_url'] == 'to_params':\n+ params['authURL'] = self.auth_url\n+ params.update(custom_params) # If needed override parameters\n+\n+ # The 'data' can be passed in two way:\n+ # - As string (needs to be correctly formatted)\n+ # - As dict (will be converted as string here)\n+ if isinstance(data, dict):\n+ if URLS[component]['add_auth_url'] == 'to_data':\ndata['authURL'] = self.auth_url\n- data = json.dumps(data)\n- return data, headers, params\n+ data_converted = json.dumps(data, separators=(',', ':')) # Netflix rejects spaces\n+ else:\n+ data_converted = data\n+ if URLS[component]['add_auth_url'] == 'to_data':\n+ auth_data = 'authURL=' + self.auth_url\n+ data_converted += '&' + auth_data if data_converted else auth_data\n+ return data_converted, headers, params\ndef _document_url(component):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Endpoints more configurable
106,046
20.04.2020 13:20:31
-7,200
b529755a6516354759f6e388b9a1c2257116f96c
Avoid double get on dict and use more appropriated names
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "new_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "diff": "@@ -30,9 +30,9 @@ BASE_URL = 'https://www.netflix.com'\n# content_type:\n# If required add the Content-Type property to request header\n-URLS = {\n+ENDPOINTS = {\n'login':\n- {'endpoint': '/login',\n+ {'address': '/login',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None,\n@@ -41,82 +41,82 @@ URLS = {\n# if in the future login raise InvalidMembershipStatusAnonymous can means that json is no more accepted\n'content_type': 'application/json'},\n'logout':\n- {'endpoint': '/SignOut',\n+ {'address': '/SignOut',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None},\n'shakti':\n- {'endpoint': '/pathEvaluator',\n+ {'address': '/pathEvaluator',\n'is_api_call': True,\n'use_default_params': True,\n'add_auth_url': 'to_data',\n'content_type': 'application/x-www-form-urlencoded'},\n'browse':\n- {'endpoint': '/browse',\n+ {'address': '/browse',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None},\n'profiles':\n- {'endpoint': '/profiles/manage',\n+ {'address': '/profiles/manage',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None},\n'switch_profile':\n- {'endpoint': '/SwitchProfile',\n+ {'address': '/SwitchProfile',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None},\n'activate_profile':\n- {'endpoint': '/profiles/switch',\n+ {'address': '/profiles/switch',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': None},\n'profile_lock':\n- {'endpoint': '/profileLock',\n+ {'address': '/profileLock',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n'content_type': 'application/json'},\n'pin':\n- {'endpoint': '/pin',\n+ {'address': '/pin',\n'is_api_call': False,\n'use_default_params': False,\n'add_auth_url': None},\n'pin_reset':\n- {'endpoint': '/pin/reset',\n+ {'address': '/pin/reset',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': None},\n'pin_service':\n- {'endpoint': '/pin/service',\n+ {'address': '/pin/service',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n'content_type': 'application/json'},\n'metadata':\n- {'endpoint': '/metadata',\n+ {'address': '/metadata',\n'is_api_call': True,\n'use_default_params': True,\n'add_auth_url': 'to_params'},\n'set_video_rating': # Old rating system\n- {'endpoint': '/setVideoRating',\n+ {'address': '/setVideoRating',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n'content_type': 'application/json'},\n'set_thumb_rating':\n- {'endpoint': '/setThumbRating',\n+ {'address': '/setThumbRating',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n'content_type': 'application/json'},\n'update_my_list':\n- {'endpoint': '/playlistop',\n+ {'address': '/playlistop',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n'content_type': 'application/json'}\n# Don't know what these could be used for. Keeping for reference\n- # 'video_list_ids': {'endpoint': '/preflight', 'is_api_call': True},\n- # 'kids': {'endpoint': '/Kids', 'is_api_call': False}\n+ # 'video_list_ids': {'address': '/preflight', 'is_api_call': True},\n+ # 'kids': {'address': '/Kids', 'is_api_call': False}\n}\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -21,7 +21,7 @@ from resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.api.exceptions import (APIError, WebsiteParsingError,\nInvalidMembershipStatusError, InvalidMembershipStatusAnonymous,\nLoginValidateErrorIncorrectPassword)\n-from resources.lib.services.nfsession.nfsession_endpoints import URLS, BASE_URL\n+from resources.lib.services.nfsession.nfsession_endpoints import ENDPOINTS, BASE_URL\nclass NFSessionRequests(NFSessionBase):\n@@ -56,12 +56,13 @@ class NFSessionRequests(NFSessionBase):\nreturn self._request(method, component, None, **kwargs)\ndef _request(self, method, component, session_refreshed, **kwargs):\n- url = (_api_url(component)\n- if URLS[component]['is_api_call']\n- else _document_url(component))\n+ endpoint_conf = ENDPOINTS[component]\n+ url = (_api_url(endpoint_conf['address'])\n+ if endpoint_conf['is_api_call']\n+ else _document_url(endpoint_conf['address']))\ncommon.debug('Executing {verb} request to {url}',\nverb='GET' if method == self.session.get else 'POST', url=url)\n- data, headers, params = self._prepare_request_properties(component, kwargs)\n+ data, headers, params = self._prepare_request_properties(endpoint_conf, kwargs)\nstart = common.perf_clock()\nresponse = method(\nurl=url,\n@@ -80,7 +81,7 @@ class NFSessionRequests(NFSessionBase):\nreturn self._request(method, component, True, **kwargs)\nresponse.raise_for_status()\nreturn (_raise_api_error(response.json() if response.content else {})\n- if URLS[component]['is_api_call']\n+ if endpoint_conf['is_api_call']\nelse response.content)\ndef try_refresh_session_data(self, raise_exception=False):\n@@ -125,15 +126,15 @@ class NFSessionRequests(NFSessionBase):\ndef _login(self, modal_error_message=False):\nraise NotImplementedError\n- def _prepare_request_properties(self, component, kwargs):\n+ def _prepare_request_properties(self, endpoint_conf, kwargs):\ndata = kwargs.get('data', {})\ncustom_headers = kwargs.get('headers', {})\ncustom_params = kwargs.get('params', {})\nparams = {}\nheaders = {'Accept': '*/*'}\n- if URLS[component].get('content_type'):\n- headers['Content-Type'] = URLS[component]['content_type']\n+ if endpoint_conf.get('content_type'):\n+ headers['Content-Type'] = endpoint_conf['content_type']\nheaders.update(custom_headers) # If needed override headers\n# Meanings parameters known:\n# drmSystem DRM used\n@@ -141,7 +142,7 @@ class NFSessionRequests(NFSessionBase):\n# withSize Puts the 'size' field inside each dictionary\n# materialize If True, when a path that no longer exists is requested (like 'storyarts')\n# it is still added in an 'empty' form in the response\n- if URLS[component]['use_default_params']:\n+ if endpoint_conf['use_default_params']:\nparams = {\n'drmSystem': 'widevine',\n'withSize': 'false',\n@@ -153,7 +154,7 @@ class NFSessionRequests(NFSessionBase):\n'original_path': '/shakti/{}/pathEvaluator'.format(\ng.LOCAL_DB.get_value('build_identifier', '', TABLE_SESSION))\n}\n- if URLS[component]['add_auth_url'] == 'to_params':\n+ if endpoint_conf['add_auth_url'] == 'to_params':\nparams['authURL'] = self.auth_url\nparams.update(custom_params) # If needed override parameters\n@@ -161,25 +162,25 @@ class NFSessionRequests(NFSessionBase):\n# - As string (needs to be correctly formatted)\n# - As dict (will be converted as string here)\nif isinstance(data, dict):\n- if URLS[component]['add_auth_url'] == 'to_data':\n+ if endpoint_conf['add_auth_url'] == 'to_data':\ndata['authURL'] = self.auth_url\ndata_converted = json.dumps(data, separators=(',', ':')) # Netflix rejects spaces\nelse:\ndata_converted = data\n- if URLS[component]['add_auth_url'] == 'to_data':\n+ if endpoint_conf['add_auth_url'] == 'to_data':\nauth_data = 'authURL=' + self.auth_url\ndata_converted += '&' + auth_data if data_converted else auth_data\nreturn data_converted, headers, params\n-def _document_url(component):\n- return BASE_URL + URLS[component]['endpoint']\n+def _document_url(endpoint_address):\n+ return BASE_URL + endpoint_address\n-def _api_url(component):\n- return '{baseurl}{componenturl}'.format(\n+def _api_url(endpoint_address):\n+ return '{baseurl}{endpoint_adr}'.format(\nbaseurl=g.LOCAL_DB.get_value('api_endpoint_url', table=TABLE_SESSION),\n- componenturl=URLS[component]['endpoint'])\n+ endpoint_adr=endpoint_address)\ndef _raise_api_error(decoded_response):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Avoid double get on dict and use more appropriated names
106,046
21.04.2020 11:04:25
-7,200
3408398275f715641dd74f5198d0bb10a45c486e
Refresh session again from browse endpoint rarely happens AuthUrl error on service start when startup_requests_module is performed on nfsession_access i find difficult to understand the real cause of this problem
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -88,7 +88,7 @@ class NFSessionRequests(NFSessionBase):\n\"\"\"Refresh session_data from the Netflix website\"\"\"\n# pylint: disable=broad-except\ntry:\n- self.auth_url = website.extract_session_data(self._get('profiles'))['auth_url']\n+ self.auth_url = website.extract_session_data(self._get('browse'))['auth_url']\nself.update_session_data()\ncommon.debug('Successfully refreshed session data')\nreturn True\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refresh session again from browse endpoint rarely happens AuthUrl error on service start when startup_requests_module is performed on nfsession_access i find difficult to understand the real cause of this problem
106,046
21.04.2020 11:12:08
-7,200
88711ce44d2dd25ac4b4dcd4f8b9ac0008eb72c5
Integrated is_less_version
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -14,6 +14,7 @@ import json\nimport xbmc\nfrom resources.lib.globals import g\n+from .misc_utils import is_less_version\nfrom .logging import debug\n@@ -262,5 +263,8 @@ class GetKodiVersion(object):\ndef is_major_ver(self, major_ver):\nreturn bool(major_ver in self.major_version)\n+ def is_less_version(self, ver):\n+ return is_less_version(self.version, ver)\n+\ndef __str__(self):\nreturn self.build_version\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Integrated is_less_version
106,046
21.04.2020 11:13:39
-7,200
176cd59b186cd28c5da94f9546ddd5695a3a797b
Add unofficial support to Portughese-Brasil lang code
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -194,10 +194,15 @@ def convert_language_iso(from_value, use_fallback=True):\ndef fix_locale_languages(data_list):\n\"\"\"Replace locale code, Kodi does not understand the country code\"\"\"\n# Get all the ISO 639-1 codes (without country)\n+ verify_unofficial_lang = g.KODI_VERSION.is_major_ver('19') or not g.KODI_VERSION.is_less_version('18.7')\nlocale_list_nocountry = []\nfor item in data_list:\nif item.get('isNoneTrack', False):\ncontinue\n+ if verify_unofficial_lang and item['language'] == 'pt-BR':\n+ # Unofficial ISO 639-1 Portuguese (Brazil) language code has been added to Kodi 18.7 and Kodi 19.x\n+ # https://github.com/xbmc/xbmc/pull/17689\n+ item['language'] = 'pb'\nif len(item['language']) == 2 and not item['language'] in locale_list_nocountry:\nlocale_list_nocountry.append(item['language'])\n# Replace the locale languages with country with a new one\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add unofficial support to Portughese-Brasil lang code
106,046
21.04.2020 14:34:46
-7,200
3c71e90e4d27fc6393cf94fb2ded90ad1bee94f4
Updated license msl requests params
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -222,7 +222,7 @@ class MSLHandler(object):\ntimestamp = int(time.time() * 10000)\nxid = str(timestamp + 1610)\nparams = [{\n- 'sessionId': sid,\n+ 'drmSessionId': sid,\n'clientTime': int(timestamp / 10000),\n'challengeBase64': challenge,\n'xid': xid\n@@ -230,7 +230,7 @@ class MSLHandler(object):\nresponse = self.msl_requests.chunked_request(ENDPOINTS['license'],\nself.msl_requests.build_request_data(self.last_license_url,\nparams,\n- 'sessionId'),\n+ 'drmSessionId'),\ng.get_esn())\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@@ -271,10 +271,10 @@ class MSLHandler(object):\nparams = [{\n'url': url,\n'params': {\n- 'sessionId': sid,\n+ 'drmSessionId': sid,\n'xid': xid\n},\n- 'echo': 'sessionId'\n+ 'echo': 'drmSessionId'\n}]\nresponse = self.msl_requests.chunked_request(ENDPOINTS['license'],\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated license msl requests params
106,046
21.04.2020 16:54:07
-7,200
736cb74ab5b942faaf9b023b603ef7d74b6b477d
Regex improved
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -250,17 +250,17 @@ class GetKodiVersion(object):\nimport re\nself.build_version = xbmc.getInfoLabel('System.BuildVersion')\n# Parse the version number\n- result = re.search('\\\\d+\\\\.\\\\d+?(?=(\\\\s|-))', self.build_version)\n+ result = re.search(r'\\d+\\.\\d+', self.build_version)\nself.version = result.group(0) if result else ''\n# Parse the major version number\nself.major_version = self.version.split('.')[0] if self.version else ''\n# Parse the date of GIT build\n- result = re.search('(Git:)(\\\\d+?(?=(-|$)))', self.build_version)\n+ result = re.search(r'(Git:)(\\d+?(?=(-|$)))', self.build_version)\nself.date = int(result.group(2)) if result and len(result.groups()) >= 2 else None\n# Parse the stage name\n- result = re.search('(\\\\d+\\\\.\\\\d+-)(.+)(?=\\\\s)', self.build_version)\n+ result = re.search(r'(\\d+\\.\\d+-)(.+)(?=\\s)', self.build_version)\nif not result:\n- result = re.search('^(.+)(-\\\\d+\\\\.\\\\d+)', self.build_version)\n+ result = re.search(r'^(.+)(-\\d+\\.\\d+)', self.build_version)\nself.stage = result.group(1) if result else ''\nelse:\nself.stage = result.group(2) if result else ''\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Regex improved
106,046
22.04.2020 18:36:51
-7,200
4a576f3738940b290aa3144e4a5f928c78233514
Version bump (1.2.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=\"1.1.1\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"1.2.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-v1.1.1 (2020-03-24)\n--Fixed critical bug caused continuous profile switching\n--Fixed unicode decode error to profile auto-selection\n+v1.2.0 (2020-04-22)\n+-Parental control temporary disabled due to Netflix changes\n+-New cache management\n+-Add-on now is ready to works also on systems with special chars in the system path\n+-Implemented profile PIN protection\n+-Implemented masked PIN input (Kodi 19)\n+-Implemented auto purge cache of expired items\n+-Implemented paginated list of seasons\n+-Implemented cache to search menu\n+-Implemented Up Next also with \"Sync of watched status with Netflix\" feature\n+-Add support to Python 3.8\n+-Add title to search page\n+-Add profile name to homepage title\n+-Add a better handling of lolomo error with sync of watched status enabled\n+-Add romanian, swedish translation\n+-Improved watched status threshold\n+-Improved watched status update in the GUI display\n+-Improved catch of possible errors in events module\n+To see the full list of changes read the changelog.txt\n</news>\n</extension>\n</addon>\n" }, { "change_type": "MODIFY", "old_path": "changelog.txt", "new_path": "changelog.txt", "diff": "+v1.2.0 (2020-04-22)\n+-Parental control temporary disabled due to Netflix changes\n+-New cache management\n+-Add-on now is ready to works also on systems with special chars in the system path\n+-Implemented profile PIN protection\n+-Implemented masked PIN input (Kodi 19)\n+-Implemented auto purge cache of expired items\n+-Implemented paginated list of seasons\n+-Implemented cache to search menu\n+-Implemented Up Next also with \"Sync of watched status with Netflix\" feature\n+-Add support to Python 3.8\n+-Add title to search page\n+-Add profile name to homepage title\n+-Add a better handling of lolomo error with sync of watched status enabled\n+-Add romanian, swedish translation\n+-Improved watched status threshold\n+-Improved watched status update in the GUI display\n+-Improved catch of possible errors in events module\n+-EventHandler thread now is running only when sync of watched status is enabled\n+-Fixed an issue caused of disabling the Up Next setting\n+-Fixed an issue which prevented a correctly add/remove operations to paginated My list\n+-Fixed an issue caused mixing images with other languages of profiles\n+-Fixed an issue caused error when art data was missing\n+-Fixed an issue caused generic wrong error messages of BackendNotReady with HTTP IPC\n+-Fixed an issue caused ProfilesMissing with profiles without avatar\n+-Fixed an issue that show a wrong title in sub genres menus\n+-Fixed a possible cases of service breakage due to server init fails\n+-Fixed a possible cases of service controller breakage\n+-Fixed an issue caused not update of watched status when play video inside the add-on with Up Next\n+-Fixed a particular issue of wrong file url passed to Up Next\n+-Fixed a rare case of ImportError error at add-on start\n+-Fixed cases of CacheMiss error with Remember audio-subtitle or Sync of watched status\n+-Fixed possible issues with internal upgrade function and version rollback\n+-Fixed add-on not starts due to possible outdated MySQL or possible MySQL errors\n+-Updated translations de, es, hu, it, pl, tr, hr, pt-br\n+-A lot of other improvements and fixes\n+\n+v1.1.1 (2020-03-24)\n+-Fixed critical bug caused continuous profile switching\n+-Fixed unicode decode error to profile auto-selection\n+\nv1.1.0 (2020-03-20)\n-Added more supplemental info to plot info\n-Added customizable color to suppl. plot info\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (1.2.0)
106,046
23.04.2020 08:34:00
-7,200
6e2f9f32dad31eaa8611449326866aed644dac80
Intercept missing library on linux
[ { "change_type": "MODIFY", "old_path": "resources/lib/run_service.py", "new_path": "resources/lib/run_service.py", "diff": "@@ -30,12 +30,27 @@ class NetflixService(object):\n\"\"\"\nNetflix addon service\n\"\"\"\n+ SERVERS = []\n+ HOST_ADDRESS = '127.0.0.1'\n+\n+ def __init__(self):\n+ self.window_cls = Window(10000) # Kodi home window\n+ # If you use multiple Kodi profiles you need to distinguish the property of current profile\n+ self.prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name())\n+ self.controller = None\n+ self.library_updater = None\n+ self.settings_monitor = None\n+\n+ def init_servers(self):\n+ \"\"\"Initialize the http servers\"\"\"\n+ try:\n+ # Import modules here to intercept possible missing libraries on linux systems\nfrom resources.lib.services.msl.http_server import MSLTCPServer\nfrom resources.lib.services.nfsession.http_server import NetflixTCPServer\nfrom resources.lib.services.cache.http_server import CacheTCPServer\n# Do not change the init order of the servers,\n# MSLTCPServer must always be initialized first to get the DRM info\n- SERVERS = [\n+ self.SERVERS = [\n{\n'name': 'MSL',\n'class': MSLTCPServer,\n@@ -53,19 +68,7 @@ class NetflixService(object):\n'thread': None\n}\n]\n- HOST_ADDRESS = '127.0.0.1'\n-\n- def __init__(self):\n- self.window_cls = Window(10000) # Kodi home window\n- # If you use multiple Kodi profiles you need to distinguish the property of current profile\n- self.prop_nf_service_status = g.py2_encode('nf_service_status_' + get_current_kodi_profile_name())\n- self.controller = None\n- self.library_updater = None\n- self.settings_monitor = None\n- def init_servers(self):\n- \"\"\"Initialize the http servers\"\"\"\n- try:\nfor server in self.SERVERS:\nself._init_server(server)\nreturn True\n@@ -76,6 +79,10 @@ class NetflixService(object):\nif isinstance(exc, gaierror):\nmessage = ('Something is wrong in your network localhost configuration.\\r\\n'\n'It is possible that the hostname {} can not be resolved.').format(self.HOST_ADDRESS)\n+ elif ImportError(exc, ImportError):\n+ message = ('In your system is missing some required library to run Netflix.\\r\\n'\n+ 'Read how to install the add-on in the GitHub Readme.\\r\\n'\n+ 'Error details: {}'.format(exc))\nelse:\nmessage = unicode(exc)\nself._set_service_status('error', message)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Intercept missing library on linux
106,046
23.04.2020 09:23:01
-7,200
565269bda7f2fc6a8cf581787fdad41c4e26b90d
Catch possible error on rollback
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "@@ -73,8 +73,12 @@ def _perform_service_changes(previous_ver, current_ver):\nfrom resources.lib.upgrade_actions import delete_cache_folder\ndelete_cache_folder()\n# In the version 1.2.0 has been implemented in auto-update mode setting the option to disable the feature\n+ try:\nlib_auto_upd_mode = g.ADDON.getSettingInt('lib_auto_upd_mode')\ng.ADDON.setSettingInt('lib_auto_upd_mode', lib_auto_upd_mode + 1)\n+ except TypeError:\n+ # In case of a previous rollback this could fails\n+ g.ADDON.setSettingInt('lib_auto_upd_mode', 1)\n# Always leave this to last - After the operations set current version\ng.LOCAL_DB.set_value('service_previous_version', current_ver)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Catch possible error on rollback
106,046
23.04.2020 10:47:14
-7,200
8c91af2ac5c96bc3cec60c5ac88e337156e6958b
Update README.md New daily builds link
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -44,7 +44,7 @@ Install add-on via repository - provide automatic installation of updates:\n* [CastagnaIT Repository for KODI 19.x MATRIX - repository.castagnait-1.0.0.zip](https://github.com/castagnait/repository.castagnait/raw/matrix/repository.castagnait-1.0.0.zip)\nInstall add-on manually - updates should always be installed manually:\n-* [Daily build - Add-on download link to get latest fixes](http://www.mediafire.com/folder/vifnw8ve44bi7/KodiNetflixAddon) (not always published see dates)\n+* Daily builds - To get latest fixes https://bit.ly/citnfdailybuilds (not always published see dates)\n* As Kodi file source, only for Kodi 18:<br/>\nhttps://castagnait.github.io/repository.castagnait/ (url to add in the Kodi file manager)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Update README.md New daily builds link
106,046
25.04.2020 16:16:29
-7,200
c347b6187a26fbfc187fefd1e79b5716d56269a2
Added accept prop to endpoints config
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "new_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "diff": "@@ -30,6 +30,9 @@ BASE_URL = 'https://www.netflix.com'\n# content_type:\n# If required add the Content-Type property to request header\n+# accept:\n+# If required add the Accept property to request header (if not specified use */*)\n+\nENDPOINTS = {\n'login':\n{'address': '/login',\n@@ -39,12 +42,14 @@ ENDPOINTS = {\n# By default to login Netflix use 'application/x-www-form-urlencoded' Content-Type,\n# instead we use 'application/json' for simplicity of data conversion\n# if in the future login raise InvalidMembershipStatusAnonymous can means that json is no more accepted\n- 'content_type': 'application/json'},\n+ 'content_type': 'application/json',\n+ 'accept': 'text/html,application/xhtml+xml,application/xml'},\n'logout':\n{'address': '/SignOut',\n'is_api_call': False,\n'use_default_params': False,\n- 'add_auth_url': None},\n+ 'add_auth_url': None,\n+ 'accept': 'text/html,application/xhtml+xml,application/xml'},\n'shakti':\n{'address': '/pathEvaluator',\n'is_api_call': True,\n@@ -55,12 +60,14 @@ ENDPOINTS = {\n{'address': '/browse',\n'is_api_call': False,\n'use_default_params': False,\n- 'add_auth_url': None},\n+ 'add_auth_url': None,\n+ 'accept': 'text/html,application/xhtml+xml,application/xml'},\n'profiles':\n{'address': '/profiles/manage',\n'is_api_call': False,\n'use_default_params': False,\n- 'add_auth_url': None},\n+ 'add_auth_url': None,\n+ 'accept': 'text/html,application/xhtml+xml,application/xml'},\n'switch_profile':\n{'address': '/SwitchProfile',\n'is_api_call': False,\n@@ -76,7 +83,8 @@ ENDPOINTS = {\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n- 'content_type': 'application/json'},\n+ 'content_type': 'application/json',\n+ 'accept': 'application/json, text/javascript, */*'},\n'pin':\n{'address': '/pin',\n'is_api_call': False,\n@@ -92,7 +100,8 @@ ENDPOINTS = {\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n- 'content_type': 'application/json'},\n+ 'content_type': 'application/json',\n+ 'accept': 'application/json, text/javascript, */*'},\n'metadata':\n{'address': '/metadata',\n'is_api_call': True,\n@@ -103,19 +112,22 @@ ENDPOINTS = {\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n- 'content_type': 'application/json'},\n+ 'content_type': 'application/json',\n+ 'accept': 'application/json, text/javascript, */*'},\n'set_thumb_rating':\n{'address': '/setThumbRating',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n- 'content_type': 'application/json'},\n+ 'content_type': 'application/json',\n+ 'accept': 'application/json, text/javascript, */*'},\n'update_my_list':\n{'address': '/playlistop',\n'is_api_call': True,\n'use_default_params': False,\n'add_auth_url': 'to_data',\n- 'content_type': 'application/json'}\n+ 'content_type': 'application/json',\n+ 'accept': 'application/json, text/javascript, */*'}\n# Don't know what these could be used for. Keeping for reference\n# 'video_list_ids': {'address': '/preflight', 'is_api_call': True},\n# 'kids': {'address': '/Kids', 'is_api_call': False}\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_requests.py", "new_path": "resources/lib/services/nfsession/nfsession_requests.py", "diff": "@@ -132,7 +132,7 @@ class NFSessionRequests(NFSessionBase):\ncustom_params = kwargs.get('params', {})\nparams = {}\n- headers = {'Accept': '*/*'}\n+ headers = {'Accept': endpoint_conf.get('accept', '*/*')}\nif endpoint_conf.get('content_type'):\nheaders['Content-Type'] = endpoint_conf['content_type']\nheaders.update(custom_headers) # If needed override headers\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added accept prop to endpoints config
106,046
26.04.2020 10:50:02
-7,200
13a9bb2b8935cdc85e70ec72a0654869249f149b
Fixed double profile switch with autoselection this also fix: case of ProfileMissing, when a profile is deleted and autoselection try to login with it case of ProfileMissing, when open the addon and the profile set as active no more exists avoid performing switch profile when return to main menu from sub-menus
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "from __future__ import absolute_import, division, unicode_literals\nimport json\n-from re import compile as recompile, DOTALL, sub, findall\nfrom collections import OrderedDict\n+from re import compile as recompile, DOTALL, sub, findall\nimport resources.lib.common as common\n-\n+from resources.lib.database.db_exceptions import ProfilesMissing\nfrom resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\n-from .paths import resolve_refs\nfrom .exceptions import (InvalidProfilesError, InvalidAuthURLError, InvalidMembershipStatusError,\nWebsiteParsingError, LoginValidateError, InvalidMembershipStatusAnonymous,\nLoginValidateErrorIncorrectPassword)\n+from .paths import resolve_refs\ntry: # Python 2\nunicode\n@@ -113,7 +113,6 @@ def parse_profiles(profiles_list_data):\nprofiles_list = OrderedDict(resolve_refs(profiles_list_data['profilesList'], profiles_list_data))\nif not profiles_list:\nraise InvalidProfilesError('It has not been possible to obtain the list of profiles.')\n- _delete_non_existing_profiles(profiles_list)\nsort_order = 0\nfor guid, profile in list(profiles_list.items()):\ncommon.debug('Parsing profile {}', guid)\n@@ -130,6 +129,7 @@ def parse_profiles(profiles_list_data):\ng.LOCAL_DB.set_profile_config(key, value, guid)\ng.LOCAL_DB.set_profile_config('avatar', avatar_url, guid)\nsort_order += 1\n+ _delete_non_existing_profiles(profiles_list)\nexcept Exception:\nimport traceback\ncommon.error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n@@ -170,12 +170,27 @@ def parse_profiles(profiles_list_data):\ndef _delete_non_existing_profiles(profiles_list):\n+ profiles_list = list(profiles_list)\nlist_guid = g.LOCAL_DB.get_guid_profiles()\nfor guid in list_guid:\n- if guid not in list(profiles_list):\n+ if guid not in profiles_list:\ncommon.debug('Deleting non-existing profile {}', guid)\ng.LOCAL_DB.delete_profile(guid)\ng.SHARED_DB.delete_profile(guid)\n+ # Ensures at least one active profile\n+ try:\n+ g.LOCAL_DB.get_active_profile_guid()\n+ except ProfilesMissing:\n+ g.LOCAL_DB.switch_active_profile(g.LOCAL_DB.get_guid_owner_profile())\n+ # Verify if auto select profile exists\n+ autoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid', '')\n+ if autoselect_profile_guid and autoselect_profile_guid not in profiles_list:\n+ common.warn('Auto-selection disabled, the GUID {} not more exists', autoselect_profile_guid)\n+ g.LOCAL_DB.set_value('autoselect_profile_guid', '')\n+ g.settings_monitor_suspend(True)\n+ g.ADDON.setSetting('autoselect_profile_name', '')\n+ g.ADDON.setSettingBool('autoselect_profile_enabled', False)\n+ g.settings_monitor_suspend(False)\ndef _get_avatar(profiles_list_data, profile):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -52,38 +52,29 @@ class Directory(object):\ndef root(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show profiles or home listing when profile auto-selection is enabled\"\"\"\n- if not self._home_autoselect_profile():\n- self.profiles()\n-\n- def _home_autoselect_profile(self):\n- \"\"\"\n- Show home listing if profile auto-selection is enabled\n- :return: True when the auto-selection is done correctly\n- \"\"\"\n+ # Update profiles data in the database\n+ # (the update sanitize also settings relative to profiles see _delete_non_existing_profiles in website.py)\n+ list_data, extra_data = common.make_call('get_profiles')\nautoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid', '')\nif autoselect_profile_guid:\n- # Check if the GUID still exists in the profile list\n- if autoselect_profile_guid not in g.LOCAL_DB.get_guid_profiles():\n- common.warn('Auto-selection of profile not performed, the GUID {} not exist',\n- autoselect_profile_guid)\n- g.LOCAL_DB.set_value('autoselect_profile_guid', '')\n- g.settings_monitor_suspend(True)\n- g.ADDON.setSetting('autoselect_profile_name', '')\n- g.ADDON.setSettingBool('autoselect_profile_enabled', False)\n- g.settings_monitor_suspend(False)\n- else:\ncommon.info('Performing auto-selection of profile {}', autoselect_profile_guid)\n- if self._activate_profile(autoselect_profile_guid):\n- self.home(None, False)\n- return True\n- return False\n+ # Get the URL parent path of the navigation,\n+ # do not perform the switch if you are coming from a page that is not the root url,\n+ # prevents switching when returning to the main menu from one of the sub-menus\n+ parent_path = xbmc.getInfoLabel('Container.FolderPath') # It can be found in log as \"ParentPath = [xyz]\"\n+ if parent_path != g.BASE_URL + '/' or self._activate_profile(autoselect_profile_guid):\n+ self.home(None, False, True)\n+ return\n+ self._profiles(list_data, extra_data)\n@custom_viewmode(g.VIEW_PROFILES)\ndef profiles(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show profiles listing\"\"\"\ncommon.debug('Showing profiles listing')\n- list_data, extra_data = common.make_call('get_profiles') # pylint: disable=unused-variable\n+ list_data, extra_data = common.make_call('get_profiles')\n+ self._profiles(list_data, extra_data)\n+ def _profiles(self, list_data, extra_data): # pylint: disable=unused-argument\n# The standard kodi theme does not allow to change view type if the content is \"files\" type,\n# so here we use \"images\" type, visually better to see\nfinalize_directory(convert_list(list_data), g.CONTENT_IMAGES)\n@@ -91,16 +82,15 @@ class Directory(object):\[email protected]_execution(immediate=False)\n@custom_viewmode(g.VIEW_MAINMENU)\n- def home(self, pathitems=None, cache_to_disc=True): # pylint: disable=unused-argument\n+ def home(self, pathitems=None, cache_to_disc=True, is_autoselect_profile=False): # pylint: disable=unused-argument\n\"\"\"Show home listing\"\"\"\n- if 'switch_profile_guid' in self.params:\n+ if not is_autoselect_profile and 'switch_profile_guid' in self.params:\n# This is executed only when you have selected a profile from the profile list\nif not self._activate_profile(self.params['switch_profile_guid']):\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\nreturn\ncommon.debug('Showing home listing')\nlist_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable\n-\nfinalize_directory(convert_list(list_data), g.CONTENT_FOLDER,\ntitle=(g.LOCAL_DB.get_profile_config('profileName', '???') +\n' - ' + common.get_local_string(30097)))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed double profile switch with autoselection this also fix: -case of ProfileMissing, when a profile is deleted and autoselection try to login with it -case of ProfileMissing, when open the addon and the profile set as active no more exists -avoid performing switch profile when return to main menu from sub-menus
106,046
29.04.2020 21:14:04
-7,200
7a1e432508700a0ce4d49658e9ff5eee3a3583d6
Add some falcor json graph helper functions
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/paths.py", "new_path": "resources/lib/api/paths.py", "diff": "@@ -234,3 +234,53 @@ def _remove_nesting(ref):\nreturn (ref['reference']\nif isinstance(ref, dict) and 'reference' in ref\nelse ref)\n+\n+\n+def jgraph_get(key, data, full_data=None):\n+ \"\"\"\n+ Expand the standard python dict.get() to implement the resolution of Falcor JSON Graph primitive types.\n+ :param full_data: pass the entire JSON Graph data (is only needed to resolve the 'ref' primitive type),\n+ if 'data' is equal to 'full_data' this param can be ignored\n+ \"\"\"\n+ return _resolve_type(data.get(key), full_data or data)\n+\n+\n+def jgraph_get_path(path, data, full_data=None):\n+ \"\"\"\n+ Retrieve a value from a nested dict by following the path.\n+ :param full_data: pass the entire JSON Graph data (is only needed to resolve the 'ref' primitive type),\n+ if 'data' is equal to 'full_data' this param can be ignored\n+ :raise KeyError: if any key along the path does not exist\n+ \"\"\"\n+ current_value = jgraph_get(path[0], data, full_data or data)\n+ if len(path) == 1:\n+ return current_value\n+ return jgraph_get_path(path[1:], current_value, full_data or data)\n+\n+\n+def _resolve_type(return_data, full_data):\n+ \"\"\"Resolve the data on basis of Falcor JSON Graph primitive types\"\"\"\n+ if isinstance(return_data, dict):\n+ primitive_type = return_data.get('$type')\n+ if primitive_type == 'ref':\n+ # Reference type: used to find and get a value within the same JSON Graph data\n+ return_data = jgraph_get_path(return_data['value'], full_data)\n+ # Look for a recursive reference\n+ return _resolve_type(return_data, full_data)\n+ if primitive_type == 'atom':\n+ # Atom: contains a JSON data and other properties (not managed here) to handle metadata\n+ return return_data.get('value')\n+ return return_data\n+\n+\n+def jgraph_get_list(key, full_data):\n+ \"\"\"\n+ Get the data of a list by resolving the Falcor JSON Graph primitive types\n+ ('summary' establishes the amount of data to retrieve)\n+ :return a dict\n+ \"\"\"\n+ data = full_data[key]\n+ converted = {}\n+ for n in range(0, jgraph_get_path(['summary', 'length'], data)):\n+ converted[n] = jgraph_get(str(n), data, full_data)\n+ return converted\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add some falcor json graph helper functions
106,046
29.04.2020 21:20:34
-7,200
3e57219677fad5e3127c46843771978b1ff8bb20
Add profilegate endpoint to now only for take note
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "new_path": "resources/lib/services/nfsession/nfsession_endpoints.py", "diff": "@@ -62,6 +62,13 @@ ENDPOINTS = {\n'use_default_params': False,\n'add_auth_url': None,\n'accept': '*/*'},\n+ 'profiles_gate':\n+ # This endpoint is used after ending editing profiles page, i think to force close an active profile session\n+ {'address': '/ProfilesGate',\n+ 'is_api_call': False,\n+ 'use_default_params': False,\n+ 'add_auth_url': 'to_data',\n+ 'accept': '*/*'},\n'profiles':\n{'address': '/profiles/manage',\n'is_api_call': False,\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add profilegate endpoint to now only for take note
106,046
29.04.2020 21:23:35
-7,200
ac0a34dc48db3802b47e24ba0d6b9f80a82d4dc6
Add json graph optional param
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -184,18 +184,19 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\[email protected]_execution(immediate=True)\n@needs_login\n- def _path_request(self, paths):\n+ def _path_request(self, paths, use_jsongraph=False):\n\"\"\"Execute a path request with static paths\"\"\"\ncommon.debug('Executing path request: {}', json.dumps(paths))\n- custom_params = {\n- 'method': 'call'\n- }\n+ custom_params = {'method': 'call'}\n+ if use_jsongraph:\n+ custom_params['falcor_server'] = '0.1.0'\n# Use separators with dumps because Netflix rejects spaces\ndata = 'path=' + '&path='.join(json.dumps(path, separators=(',', ':')) for path in paths)\n- return self._post(\n+ response = self._post(\ncomponent='shakti',\nparams=custom_params,\n- data=data)['value']\n+ data=data)\n+ return response['jsonGraph'] if use_jsongraph else response['value']\[email protected]_return_call\n@needs_login\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add json graph optional param
106,046
30.04.2020 10:55:49
-7,200
c867bdf79957e505191863ec554f20282e485e45
Reviewed first access and profile switch this is an attempt to reproduce more accurately the access and the profile switch, in order to be able to find a solution to the http 401 error problem, the situation has improved but in some cases the error still persist
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -53,36 +53,6 @@ def login(ask_credentials=True):\nraise\n-def activate_profile(profile_guid):\n- \"\"\"Activate the profile with the given GUID\"\"\"\n- common.make_call('activate_profile', profile_guid)\n- if g.ADDON.getSettingBool('ProgressManager_enabled'):\n- save_current_lolomo_data()\n-\n-\n-def save_current_lolomo_data():\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- context_name = 'continueWatching'\n- lolomo_data = common.make_call('path_request',\n- [['lolomo', [context_name], ['context', 'id', 'index']]])\n- lolomo_root = lolomo_data['lolomo'][1]\n- g.LOCAL_DB.set_value('lolomo_root_id', lolomo_root, TABLE_SESSION)\n- # Todo: In the new profiles, there is no 'continueWatching' list and no list is returned\n- # How get the lolomo of continueWatching?\n- if ('lolomos' in lolomo_data and\n- lolomo_root in lolomo_data['lolomos'] and\n- context_name in lolomo_data['lolomos'][lolomo_root]):\n- context_index = lolomo_data['lolomos'][lolomo_root][context_name][2]\n- context_id = lolomo_data['lolomos'][lolomo_root][context_index][1]\n- else:\n- common.debug('Context continueWatching lolomo not found. Returned data: {}', lolomo_data)\n- context_index = ''\n- context_id = ''\n- g.LOCAL_DB.set_value('lolomo_{}_index'.format(context_name.lower()), context_index, TABLE_SESSION)\n- g.LOCAL_DB.set_value('lolomo_{}_id'.format(context_name.lower()), context_id, TABLE_SESSION)\n-\n-\ndef update_lolomo_context(context_name):\n\"\"\"Update the lolomo list by context\"\"\"\nlolomo_root = g.LOCAL_DB.get_value('lolomo_root_id', '', TABLE_SESSION)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "from __future__ import absolute_import, division, unicode_literals\nimport json\n-from collections import OrderedDict\nfrom re import compile as recompile, DOTALL, sub, findall\n+from future.utils import iteritems\n+\nimport resources.lib.common as common\nfrom resources.lib.database.db_exceptions import ProfilesMissing\nfrom resources.lib.database.db_utils import (TABLE_SESSION)\n@@ -20,7 +21,7 @@ from resources.lib.globals import g\nfrom .exceptions import (InvalidProfilesError, InvalidAuthURLError, InvalidMembershipStatusError,\nWebsiteParsingError, LoginValidateError, InvalidMembershipStatusAnonymous,\nLoginValidateErrorIncorrectPassword)\n-from .paths import resolve_refs\n+from .paths import jgraph_get, jgraph_get_list, jgraph_get_path\ntry: # Python 2\nunicode\n@@ -66,7 +67,7 @@ PROFILE_DEBUG_INFO = ['profileName', 'isAccountOwner', 'isActive', 'isKids', 'ma\[email protected]_execution(immediate=True)\n-def extract_session_data(content, validate=False):\n+def extract_session_data(content, validate=False, update_profiles=False):\n\"\"\"\nCall all the parsers we need to extract all\nthe session relevant data from the HTML page\n@@ -91,9 +92,41 @@ def extract_session_data(content, validate=False):\nraise InvalidMembershipStatusError(user_data.get('membershipStatus'))\napi_data = extract_api_data(react_context)\n- # Note: falcor cache does not exist if membershipStatus is not CURRENT_MEMBER\n- # falcor cache is not more used to extract profiles data\n- # falcor_cache = extract_json(content, 'falcorCache')\n+ # Note: Falcor cache does not exist if membershipStatus is not CURRENT_MEMBER\n+ falcor_cache = extract_json(content, 'falcorCache')\n+\n+ if update_profiles:\n+ parse_profiles(falcor_cache)\n+\n+ # Extract lolomo root id\n+ lolomo_root = falcor_cache['lolomo']['value'][1]\n+ g.LOCAL_DB.set_value('lolomo_root_id', lolomo_root, TABLE_SESSION)\n+\n+ # Check if current 'profile session' is still active\n+ # What means 'profile session':\n+ # In web browser, after you select a profile and then you close the browse page,\n+ # when you reopen it you will not be asked to select a profile again, this means that the same profile session\n+ # still active, and the lolomo root id (and child contexts id's) are still the same.\n+ # Here one way to understand this, is checking if there is an 'summary' entry in the lolomos dictionary.\n+ is_profile_session_active = 'summary' in falcor_cache['lolomos'][lolomo_root]\n+\n+ # Extract lolomo continueWatching id and index\n+ cw_list_data = jgraph_get('continueWatching', falcor_cache['lolomos'][lolomo_root], falcor_cache)\n+ if cw_list_data:\n+ context_index = falcor_cache['lolomos'][lolomo_root]['continueWatching']['value'][2]\n+ g.LOCAL_DB.set_value('lolomo_continuewatching_index', context_index, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('lolomo_continuewatching_id', jgraph_get('id', cw_list_data), TABLE_SESSION)\n+ elif is_profile_session_active:\n+ # Todo: In the new profiles, there is no 'continueWatching' context\n+ # How get or generate the continueWatching context?\n+ # (needed to update lolomo list for watched state sync, see update_lolomo_context in api_requests.py)\n+ cur_profile = jgraph_get_path(['profilesList', 'current'], falcor_cache)\n+ common.warn('Context continueWatching not found in lolomos for profile guid {}.',\n+ jgraph_get('summary', cur_profile)['guid'])\n+ g.LOCAL_DB.set_value('lolomo_continuewatching_index', '', TABLE_SESSION)\n+ g.LOCAL_DB.set_value('lolomo_continuewatching_id', '', TABLE_SESSION)\n+ else:\n+ common.warn('Is not possible to find the context continueWatching, the profile session is no more active')\n# Save only some info of the current profile from user data\ng.LOCAL_DB.set_value('build_identifier', user_data.get('BUILD_IDENTIFIER'), TABLE_SESSION)\n@@ -103,25 +136,30 @@ 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+\n+ api_data['is_profile_session_active'] = is_profile_session_active\nreturn api_data\[email protected]_execution(immediate=True)\n-def parse_profiles(profiles_list_data):\n+def parse_profiles(data):\n\"\"\"Parse profile information from Netflix response\"\"\"\n+ profiles_list = jgraph_get_list('profilesList', data)\ntry:\n- profiles_list = OrderedDict(resolve_refs(profiles_list_data['profilesList'], profiles_list_data))\nif not profiles_list:\nraise InvalidProfilesError('It has not been possible to obtain the list of profiles.')\nsort_order = 0\n- for guid, profile in list(profiles_list.items()):\n- common.debug('Parsing profile {}', guid)\n- avatar_url = _get_avatar(profiles_list_data, profile)\n- profile = profile['summary']\n- is_active = profile.pop('isActive')\n+ current_guids = []\n+ for index, profile_data in iteritems(profiles_list): # pylint: disable=unused-variable\n+ summary = jgraph_get('summary', profile_data)\n+ guid = summary['guid']\n+ current_guids.append(guid)\n+ common.debug('Parsing profile {}', summary['guid'])\n+ avatar_url = _get_avatar(profile_data, data, guid)\n+ is_active = summary.pop('isActive')\ng.LOCAL_DB.set_profile(guid, is_active, sort_order)\ng.SHARED_DB.set_profile(guid, sort_order)\n- for key, value in list(profile.items()):\n+ for key, value in iteritems(summary):\nif key in PROFILE_DEBUG_INFO:\ncommon.debug('Profile info {}', {key: value})\nif key == 'profileName': # The profile name is coded as HTML\n@@ -129,51 +167,18 @@ def parse_profiles(profiles_list_data):\ng.LOCAL_DB.set_profile_config(key, value, guid)\ng.LOCAL_DB.set_profile_config('avatar', avatar_url, guid)\nsort_order += 1\n- _delete_non_existing_profiles(profiles_list)\n+ _delete_non_existing_profiles(current_guids)\nexcept Exception:\nimport traceback\ncommon.error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n- common.error('Profile list data: {}', profiles_list_data)\n+ common.error('Profile list data: {}', profiles_list)\nraise InvalidProfilesError\n-# @common.time_execution(immediate=True)\n-# def extract_profiles(falkor_cache):\n-# \"\"\"Extract profile information from Netflix website\"\"\"\n-# try:\n-# profiles_list = OrderedDict(resolve_refs(falkor_cache['profilesList'], falkor_cache))\n-# if not profiles_list:\n-# common.error('The profiles list from falkor cache is empty. '\n-# 'The profiles were not parsed nor updated!')\n-# else:\n-# _delete_non_existing_profiles(profiles_list)\n-# sort_order = 0\n-# for guid, profile in list(profiles_list.items()):\n-# common.debug('Parsing profile {}', guid)\n-# avatar_url = _get_avatar(falkor_cache, profile)\n-# profile = profile['summary']['value']\n-# debug_info = ['profileName', 'isAccountOwner', 'isActive', 'isKids', 'maturityLevel']\n-# for k_info in debug_info:\n-# common.debug('Profile info {}', {k_info: profile[k_info]})\n-# is_active = profile.pop('isActive')\n-# g.LOCAL_DB.set_profile(guid, is_active, sort_order)\n-# g.SHARED_DB.set_profile(guid, sort_order)\n-# for key, value in list(profile.items()):\n-# g.LOCAL_DB.set_profile_config(key, value, guid)\n-# g.LOCAL_DB.set_profile_config('avatar', avatar_url, guid)\n-# sort_order += 1\n-# except Exception:\n-# import traceback\n-# common.error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n-# common.error('Falkor cache: {}', falkor_cache)\n-# raise\n-\n-\n-def _delete_non_existing_profiles(profiles_list):\n- profiles_list = list(profiles_list)\n+def _delete_non_existing_profiles(current_guids):\nlist_guid = g.LOCAL_DB.get_guid_profiles()\nfor guid in list_guid:\n- if guid not in profiles_list:\n+ if guid not in current_guids:\ncommon.debug('Deleting non-existing profile {}', guid)\ng.LOCAL_DB.delete_profile(guid)\ng.SHARED_DB.delete_profile(guid)\n@@ -184,7 +189,7 @@ def _delete_non_existing_profiles(profiles_list):\ng.LOCAL_DB.switch_active_profile(g.LOCAL_DB.get_guid_owner_profile())\n# Verify if auto select profile exists\nautoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid', '')\n- if autoselect_profile_guid and autoselect_profile_guid not in profiles_list:\n+ if autoselect_profile_guid and autoselect_profile_guid not in current_guids:\ncommon.warn('Auto-selection disabled, the GUID {} not more exists', autoselect_profile_guid)\ng.LOCAL_DB.set_value('autoselect_profile_guid', '')\ng.settings_monitor_suspend(True)\n@@ -193,12 +198,13 @@ def _delete_non_existing_profiles(profiles_list):\ng.settings_monitor_suspend(False)\n-def _get_avatar(profiles_list_data, profile):\n+def _get_avatar(profile_data, data, guid):\ntry:\n- return common.get_path(profile['avatar'] + AVATAR_SUBPATH, profiles_list_data)\n+ avatar = jgraph_get('avatar', profile_data, data)\n+ return jgraph_get_path(AVATAR_SUBPATH, avatar)\nexcept (KeyError, TypeError):\n- common.warn('Cannot find avatar for profile {}', profile['summary']['guid'])\n- common.debug('Profile list data: {}', profiles_list_data)\n+ common.warn('Cannot find avatar for profile {}', guid)\n+ common.debug('Profile list data: {}', profile_data)\nreturn g.ICON\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -12,7 +12,6 @@ from __future__ import absolute_import, division, unicode_literals\nimport xbmc\nimport xbmcplugin\n-import resources.lib.api.api_requests as api\nimport resources.lib.common as common\nimport resources.lib.kodi.library as library\nimport resources.lib.kodi.ui as ui\n@@ -52,26 +51,31 @@ class Directory(object):\ndef root(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show profiles or home listing when profile auto-selection is enabled\"\"\"\n- # Update profiles data in the database\n- # (the update sanitize also settings relative to profiles see _delete_non_existing_profiles in website.py)\n- list_data, extra_data = common.make_call('get_profiles')\n+ # Get the URL parent path of the navigation: xbmc.getInfoLabel('Container.FolderPath')\n+ # it can be found in Kodi log as \"ParentPath = [xyz]\" but not always return the exact value\n+ is_parent_root_path = xbmc.getInfoLabel('Container.FolderPath') == g.BASE_URL + '/'\n+ # Fetch initial page to refresh all session data\n+ if is_parent_root_path:\n+ common.make_call('fetch_initial_page')\n+ # Note when the profiles are updated to the database (by fetch_initial_page call),\n+ # the update sanitize also relative settings to profiles (see _delete_non_existing_profiles in website.py)\nautoselect_profile_guid = g.LOCAL_DB.get_value('autoselect_profile_guid', '')\nif autoselect_profile_guid:\n+ if is_parent_root_path:\ncommon.info('Performing auto-selection of profile {}', autoselect_profile_guid)\n- # Get the URL parent path of the navigation,\n- # do not perform the switch if you are coming from a page that is not the root url,\n- # prevents switching when returning to the main menu from one of the sub-menus\n- parent_path = xbmc.getInfoLabel('Container.FolderPath') # It can be found in log as \"ParentPath = [xyz]\"\n- if parent_path != g.BASE_URL + '/' or self._activate_profile(autoselect_profile_guid):\n+ # Do not perform the profile switch if navigation come from a page that is not the root url,\n+ # prevents profile switching when returning to the main menu from one of the sub-menus\n+ if not is_parent_root_path or self._activate_profile(autoselect_profile_guid):\nself.home(None, False, True)\nreturn\n+ list_data, extra_data = common.make_call('get_profiles', {'request_update': False})\nself._profiles(list_data, extra_data)\n@custom_viewmode(g.VIEW_PROFILES)\ndef profiles(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show profiles listing\"\"\"\ncommon.debug('Showing profiles listing')\n- list_data, extra_data = common.make_call('get_profiles')\n+ list_data, extra_data = common.make_call('get_profiles', {'request_update': True})\nself._profiles(list_data, extra_data)\ndef _profiles(self, list_data, extra_data): # pylint: disable=unused-argument\n@@ -90,11 +94,27 @@ class Directory(object):\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\nreturn\ncommon.debug('Showing home listing')\n+ try:\nlist_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable\nfinalize_directory(convert_list(list_data), g.CONTENT_FOLDER,\ntitle=(g.LOCAL_DB.get_profile_config('profileName', '???') +\n' - ' + common.get_local_string(30097)))\nend_of_directory(False, cache_to_disc)\n+ except Exception as exc: # pylint: disable=broad-except\n+ if str(exc) != 'HTTPError':\n+ raise\n+ # 30/04/2020 - http error 401 issue\n+ # After the profile selection sometime can happen the http error 401 Client Error: Unauthorized for url ...\n+ # due to the failure of the first shakti API request.\n+ # After a revision of the code of initial access, i have not found any reason that could cause this problem,\n+ # i am beginning to suspect that is a problem of the netflix service.\n+ # Not found any solutions, two http attempts are already made, so notify the user of the problem.\n+ common.error('Stop navigation due to too many http authURL errors (known error currently unresolvable)')\n+ ui.show_ok_dialog(common.get_local_string(30105),\n+ ('There was a communication problem with Netflix.\\r\\n'\n+ 'This is a known and unresolvable issue, do not submit reports.\\r\\n'\n+ 'You can try the operation again or exit.'))\n+ xbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\ndef _activate_profile(self, guid):\npin_result = verify_profile_pin(guid)\n@@ -102,7 +122,7 @@ class Directory(object):\nif pin_result is not None:\nui.show_notification(common.get_local_string(30106), time=8000)\nreturn False\n- api.activate_profile(guid)\n+ common.make_call('activate_profile', guid)\nreturn True\[email protected]_execution(immediate=False)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/hub.py", "new_path": "resources/lib/navigation/hub.py", "diff": "from __future__ import absolute_import, division, unicode_literals\nimport resources.lib.common as common\n-import resources.lib.api.api_requests as api\n# Needs skin support!\n@@ -20,8 +19,8 @@ class HubBrowser(object):\ndef __init__(self, params):\ncommon.debug('Initializing \"HubBrowser\" with params: {}', params)\nself.params = params\n- if 'profile_guid' in params:\n- api.activate_profile(params['profile_guid'])\n+ if 'switch_profile_guid' in params:\n+ common.make_call('activate_profile', params['switch_profile_guid'])\ndef browse(self, pathitems):\n\"\"\"Browse the hub at a given location\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/directorybuilder/dir_builder.py", "new_path": "resources/lib/services/directorybuilder/dir_builder.py", "diff": "@@ -52,7 +52,15 @@ class DirectoryBuilder(DirectoryRequests):\[email protected]_execution(immediate=True)\[email protected]_return_call\n- def get_profiles(self):\n+ def get_profiles(self, request_update):\n+ \"\"\"\n+ Get the list of profiles stored to the database\n+ :param request_update: when true, perform a request to the shakti API to fetch new profile data\n+ \"\"\"\n+ # The profiles data are automatically updated (parsed from falcorCache) in the following situations:\n+ # -At first log-in, see '_login' in nf_session_access.py\n+ # -When navigation accesses to the root path, see 'root' in directory.py (ref. to 'fetch_initial_page' call)\n+ if request_update:\nself.req_profiles_info()\nreturn build_profiles_listing()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/directorybuilder/dir_builder_requests.py", "new_path": "resources/lib/services/directorybuilder/dir_builder_requests.py", "diff": "@@ -89,7 +89,7 @@ class DirectoryRequests(object):\n['profilesList', 'current', 'summary'],\n['profilesList', {'to': 5}, 'summary'],\n['profilesList', {'to': 5}, 'avatar', 'images', 'byWidth', 320]])\n- path_response = self.netflix_session._path_request(paths)\n+ path_response = self.netflix_session._path_request(paths, use_jsongraph=True)\nif update_database:\nfrom resources.lib.api.website import parse_profiles\nparse_profiles(path_response)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -29,6 +29,7 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\nNFSessionAccess.__init__(self)\nDirectoryBuilder.__init__(self, self)\nself.slots = [\n+ self.fetch_initial_page,\nself.login,\nself.logout,\nself.activate_profile,\n@@ -37,12 +38,12 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\nself.perpetual_path_request,\nself.callpath_request,\nself.get,\n- self.post,\n- self.startup_requests_module\n+ self.post\n]\nfor slot in self.slots:\ncommon.register_slot(slot)\nself.prefetch_login()\n+ self.is_profile_session_active = False\[email protected]_return_call\n@needs_login\n@@ -70,23 +71,46 @@ class NetflixSession(NFSessionAccess, DirectoryBuilder):\nextracted_content['pin'] = pin\nreturn extracted_content\n+ @common.time_execution(immediate=True)\n+ @common.addonsignals_return_call\n+ @needs_login\n+ def fetch_initial_page(self):\n+ \"\"\"Fetch initial page\"\"\"\n+ common.debug('Fetch initial page')\n+ response = self._get('browse')\n+ # Update the session data, the profiles data to the database, and update the authURL\n+ api_data = website.extract_session_data(response, update_profiles=True)\n+ self.auth_url = api_data['auth_url']\n+ # Check if the profile session is still active, used only to activate_profile\n+ self.is_profile_session_active = api_data['is_profile_session_active']\n+\[email protected]_execution(immediate=True)\[email protected]_return_call\n@needs_login\ndef activate_profile(self, guid):\n\"\"\"Set the profile identified by guid as active\"\"\"\ncommon.debug('Switching to profile {}', guid)\n+ current_active_guid = g.LOCAL_DB.get_active_profile_guid()\n+ if self.is_profile_session_active and guid == current_active_guid:\n+ common.info('The profile session of guid {} is still active, activation not needed.', guid)\n+ if not self.is_profile_session_active or (self.is_profile_session_active and\n+ guid != current_active_guid):\n+ common.info('Activating profile {}', guid)\n+ # INIT Method 1 - HTTP mode\nresponse = 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-\n- # if guid != g.LOCAL_DB.get_active_profile_guid():\n- # common.info('Activating profile {}', guid)\n+ self.auth_url = website.extract_session_data(response)['auth_url']\n+ # END Method 1\n+ # INIT Method 2 - API mode\n+ # import time\n# self._get(component='activate_profile',\n# params={'switchProfileGuid': guid,\n# '_': int(time.time()),\n# 'authURL': self.auth_url})\n-\n+ # # Retrieve browse page to update authURL\n+ # response = self._get('browse')\n+ # self.auth_url = website.extract_session_data(response)['auth_url']\n+ # END Method 2\n+ self.is_profile_session_active = True\ng.LOCAL_DB.switch_active_profile(guid)\ng.CACHE_MANAGEMENT.identifier_prefix = guid\nself.update_session_data()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession_access.py", "new_path": "resources/lib/services/nfsession/nfsession_access.py", "diff": "@@ -43,9 +43,6 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\ncommon.get_credentials()\nif not self.is_logged_in():\nself._login()\n- else:\n- # A hack way to full load requests module without blocking the service startup\n- common.send_signal(signal='startup_requests_module', non_blocking=True)\nself.is_prefetch_login = True\nexcept requests.exceptions.RequestException as exc:\n# It was not possible to connect to the web service, no connection, network problem, etc\n@@ -75,14 +72,6 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\nreturn self.try_refresh_session_data()\nreturn True\n- def startup_requests_module(self, data=None): # pylint: disable=unused-argument\n- \"\"\"A hack way to full load requests module before making any other calls\"\"\"\n- # The first call made with 'requests' module, can takes more than one second longer then\n- # usual to elaborate (depend from device/os/connection), to camouflage this delay\n- # and make the add-on frontend faster this request is made when the service is started.\n- # Side note: authURL probably has a expiration time not knowing which one we are obliged to refresh session data\n- self.try_refresh_session_data()\n-\[email protected]_return_call\ndef login(self):\n\"\"\"AddonSignals interface for login function\"\"\"\n@@ -102,7 +91,7 @@ class NFSessionAccess(NFSessionRequests, NFSessionCookie):\n'login',\ndata=_login_payload(common.get_credentials(), auth_url))\ntry:\n- website.extract_session_data(login_response, validate=True)\n+ website.extract_session_data(login_response, validate=True, update_profiles=True)\ncommon.info('Login successful')\nui.show_notification(common.get_local_string(30109))\nself.update_session_data(current_esn)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Reviewed first access and profile switch this is an attempt to reproduce more accurately the access and the profile switch, in order to be able to find a solution to the http 401 error problem, the situation has improved but in some cases the error still persist
106,046
30.04.2020 09:00:50
-7,200
ba205e0493737a4c4dc9aeca13723eac8cffaf8f
Fixed unrelated pylint
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/cache_utils.py", "new_path": "resources/lib/common/cache_utils.py", "diff": "@@ -63,7 +63,6 @@ def cache_output(bucket, fixed_identifier=None,\nttl=None,\nignore_self_class=False):\n\"\"\"Decorator that ensures caching the output of a function\"\"\"\n- # pylint: too-many-arguments\ndef caching_decorator(func):\n@wraps(func)\ndef wrapper(*args, **kwargs):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "@@ -24,7 +24,7 @@ def get_shareddb_class(use_mysql=False):\nclass NFSharedDatabase(base_class):\ndef __init__(self):\nif use_mysql:\n- super(NFSharedDatabase, self).__init__()\n+ super(NFSharedDatabase, self).__init__() # pylint: disable=no-value-for-parameter\nelse:\nsuper(NFSharedDatabase, self).__init__(db_utils.SHARED_DB_FILENAME)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -29,7 +29,6 @@ def lazy_login(func):\n\"\"\"\nDecorator to ensure that a valid login is present when calling a method\n\"\"\"\n- # pylint: missing-docstring\n@wraps(func)\ndef lazy_login_wrapper(*args, **kwargs):\nfrom resources.lib.api.exceptions import (NotLoggedInError, MissingCredentialsError,\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed unrelated pylint
106,046
30.04.2020 17:23:00
-7,200
1f28665d70104b92038b746679cd78fba66acb4e
On Kodi 19 makeLegalFilename is moved to xbmcvfs module
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -23,6 +23,11 @@ from resources.lib.kodi.library_items import (export_item, remove_item, export_n\nItemNotFound, FOLDER_MOVIES, FOLDER_TV, library_path)\nfrom resources.lib.kodi.library_tasks import compile_tasks, execute_tasks\n+try: # Kodi >= 19\n+ from xbmcvfs import makeLegalFilename # pylint: disable=ungrouped-imports\n+except ImportError: # Kodi 18\n+ from xbmc import makeLegalFilename # pylint: disable=ungrouped-imports\n+\ndef update_kodi_library(library_operation):\n\"\"\"Decorator that ensures an update of the Kodi library\"\"\"\n@@ -171,7 +176,7 @@ def purge():\ng.SHARED_DB.purge_library()\nfor folder_name in [FOLDER_MOVIES, FOLDER_TV]:\nsection_dir = xbmc.translatePath(\n- xbmc.makeLegalFilename('/'.join([library_path(), folder_name])))\n+ makeLegalFilename('/'.join([library_path(), folder_name])))\ncommon.delete_folder_contents(section_dir, delete_subfolders=True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library_items.py", "new_path": "resources/lib/kodi/library_items.py", "diff": "@@ -22,6 +22,11 @@ import resources.lib.kodi.ui as ui\nfrom resources.lib.api.exceptions import MetadataNotAvailable\nfrom resources.lib.globals import g\n+try: # Kodi >= 19\n+ from xbmcvfs import makeLegalFilename # pylint: disable=ungrouped-imports\n+except ImportError: # Kodi 18\n+ from xbmc import makeLegalFilename # pylint: disable=ungrouped-imports\n+\nLIBRARY_HOME = 'library'\nFOLDER_MOVIES = 'movies'\nFOLDER_TV = 'shows'\n@@ -71,7 +76,7 @@ def _get_library_entry(videoid):\ndef _get_item(mediatype, filename):\n# To ensure compatibility with previously exported items,\n# make the filename legal\n- fname = xbmc.makeLegalFilename(filename)\n+ fname = makeLegalFilename(filename)\nuntranslated_path = os.path.dirname(g.py2_decode(fname))\ntranslated_path = os.path.dirname(g.py2_decode(xbmc.translatePath(fname)))\nshortname = os.path.basename(g.py2_decode(xbmc.translatePath(fname)))\n@@ -106,7 +111,7 @@ def get_previously_exported_items():\nvideoid_pattern = re.compile('video_id=(\\\\d+)')\nfor folder in _lib_folders(FOLDER_MOVIES) + _lib_folders(FOLDER_TV):\nfor filename in xbmcvfs.listdir(folder)[1]:\n- filepath = g.py2_decode(xbmc.makeLegalFilename('/'.join([folder, filename])))\n+ filepath = g.py2_decode(makeLegalFilename('/'.join([folder, filename])))\nif filepath.endswith('.strm'):\ncommon.debug('Trying to migrate {}', filepath)\ntry:\n@@ -124,8 +129,8 @@ def get_previously_exported_items():\ndef _lib_folders(section):\n- section_dir = g.py2_decode(xbmc.translatePath(xbmc.makeLegalFilename('/'.join([library_path(), section]))))\n- return [g.py2_decode(xbmc.makeLegalFilename('/'.join([section_dir, folder.decode('utf-8')])))\n+ section_dir = g.py2_decode(xbmc.translatePath(makeLegalFilename('/'.join([library_path(), section]))))\n+ return [g.py2_decode(makeLegalFilename('/'.join([section_dir, folder.decode('utf-8')])))\nfor folder\nin xbmcvfs.listdir(section_dir)[0]]\n@@ -149,16 +154,16 @@ def export_new_item(item_task, library_home):\ndef export_item(item_task, library_home):\n\"\"\"Create strm file for an item and add it to the library\"\"\"\n# Paths must be legal to ensure NFS compatibility\n- destination_folder = g.py2_decode(xbmc.makeLegalFilename('/'.join(\n+ destination_folder = g.py2_decode(makeLegalFilename('/'.join(\n[library_home, item_task['section'], item_task['destination']])))\n_create_destination_folder(destination_folder)\nif item_task['is_strm']:\n- export_filename = g.py2_decode(xbmc.makeLegalFilename('/'.join(\n+ export_filename = g.py2_decode(makeLegalFilename('/'.join(\n[destination_folder, item_task['filename'] + '.strm'])))\n_add_to_library(item_task['videoid'], export_filename, (item_task['nfo_data'] is not None))\n_write_strm_file(item_task, export_filename)\nif item_task['nfo_data'] is not None:\n- nfo_filename = g.py2_decode(xbmc.makeLegalFilename('/'.join(\n+ nfo_filename = g.py2_decode(makeLegalFilename('/'.join(\n[destination_folder, item_task['filename'] + '.nfo'])))\n_write_nfo_file(item_task['nfo_data'], nfo_filename)\ncommon.debug('Exported {}', item_task['title'])\n@@ -222,7 +227,7 @@ def remove_item(item_task, library_home=None):\nif xbmcvfs.exists(nfo_file):\nxbmcvfs.delete(nfo_file)\ndirs, files = xbmcvfs.listdir(parent_folder)\n- tvshow_nfo_file = g.py2_decode(xbmc.makeLegalFilename('/'.join([parent_folder, 'tvshow.nfo'])))\n+ tvshow_nfo_file = g.py2_decode(makeLegalFilename('/'.join([parent_folder, 'tvshow.nfo'])))\n# Remove tvshow_nfo_file only when is the last file\n# (users have the option of removing even single seasons)\nif xbmcvfs.exists(tvshow_nfo_file) and not dirs and len(files) == 1:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -19,6 +19,11 @@ import resources.lib.common as common\nimport resources.lib.kodi.library as kodi_library\nfrom resources.lib.kodi.library_autoupdate import auto_update_library\n+try: # Kodi >= 19\n+ from xbmcvfs import makeLegalFilename # pylint: disable=ungrouped-imports\n+except ImportError: # Kodi 18\n+ from xbmc import makeLegalFilename # pylint: disable=ungrouped-imports\n+\nclass LibraryUpdateService(xbmc.Monitor):\n\"\"\"\n@@ -112,7 +117,7 @@ class LibraryUpdateService(xbmc.Monitor):\ncommon.debug('Kodi library update requested from library auto-update')\nself.scan_awaiting = False\ncommon.scan_library(\n- xbmc.makeLegalFilename(\n+ makeLegalFilename(\nxbmc.translatePath(\nkodi_library.library_path())))\nelse:\n" }, { "change_type": "MODIFY", "old_path": "tests/xbmc.py", "new_path": "tests/xbmc.py", "diff": "@@ -174,7 +174,7 @@ def log(msg, level):\nprint('\u001b[32;1m%s: \u001b[32;0m%s\u001b[0m' % (level, msg))\n-def makeLegalFilename(filename, fatX=None):\n+def makeLegalFilename(filename, fatX=None): # Kodi 18\n\"\"\"A reimplementation of the xbmc makeLegalFilename() function\"\"\"\nif fatX:\nreturn filename\n" }, { "change_type": "MODIFY", "old_path": "tests/xbmcvfs.py", "new_path": "tests/xbmcvfs.py", "diff": "@@ -89,3 +89,8 @@ def rename(file, newFileName): # pylint: disable=redefined-builtin\ndef rmdir(path):\n\"\"\"A reimplementation of the xbmcvfs rmdir() function\"\"\"\nreturn os.rmdir(path)\n+\n+\n+def makeLegalFilename(filename): # Kodi >= 19 (on xbmc there is the method for Kodi 18)\n+ \"\"\"A reimplementation of the xbmc makeLegalFilename() function\"\"\"\n+ return os.path.basename(filename)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
On Kodi 19 makeLegalFilename is moved to xbmcvfs module
106,046
30.04.2020 17:40:47
-7,200
1e6d59018e8f5460661fbe59bf3749c9ff57ccfd
Fixed first param as list
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -138,7 +138,7 @@ class AddonActionExecutor(object):\ndef force_update_mylist(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Clear the cache of my list to force the update\"\"\"\nfrom resources.lib.common.cache_utils import CACHE_MYLIST\n- g.CACHE.clear(CACHE_MYLIST, clear_database=False)\n+ g.CACHE.clear([CACHE_MYLIST], clear_database=False)\ndef view_esn(self, pathitems=None): # pylint: disable=unused-argument\n\"\"\"Show the ESN in use\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed first param as list
106,046
01.05.2020 09:52:35
-7,200
1d23047d8d14f813a9d994f69cac9323107df1a4
Changed service address with 127.0.0.1 see note
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/ipc.py", "new_path": "resources/lib/common/ipc.py", "diff": "@@ -97,7 +97,7 @@ def make_http_call(callname, data):\nfrom urllib2 import build_opener, install_opener, ProxyHandler, HTTPError, URLError, urlopen\nimport json\ndebug('Handling HTTP IPC call to {}'.format(callname))\n- # Note: Using 'localhost' here slowdown the call, not sure if it is an urllib issue\n+ # Note: On python 3, using 'localhost' slowdown the call (Windows OS is affected) not sure if it is an urllib issue\nurl = 'http://127.0.0.1:{}/{}'.format(g.LOCAL_DB.get_value('ns_service_port', 8001), callname)\ninstall_opener(build_opener(ProxyHandler({}))) # don't use proxy for localhost\ntry:\n@@ -121,7 +121,7 @@ def make_http_call_cache(callname, params, data):\nfrom urllib2 import build_opener, install_opener, ProxyHandler, HTTPError, URLError, Request, urlopen\nimport json\n# debug('Handling HTTP IPC call to {}'.format(callname))\n- # Note: Using 'localhost' here slowdown the call, not sure if it is an urllib issue\n+ # Note: On python 3, using 'localhost' slowdown the call (Windows OS is affected) not sure if it is an urllib issue\nurl = 'http://127.0.0.1:{}/{}'.format(g.LOCAL_DB.get_value('cache_service_port', 8002), callname)\ninstall_opener(build_opener(ProxyHandler({}))) # don't use proxy for localhost\nr = Request(url=url, data=data, headers={'Params': json.dumps(params)})\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -21,7 +21,10 @@ import resources.lib.api.api_requests as api\nimport resources.lib.kodi.infolabels as infolabels\nimport resources.lib.kodi.ui as ui\n-SERVICE_URL_FORMAT = 'http://localhost:{port}'\n+# Note: On SERVICE_URL_FORMAT with python 3, using 'localhost' slowdown the call (Windows OS is affected),\n+# so the time that Kodi takes to start a video increases, (due to requests exchange between ISA and the add-on)\n+# not sure if it is an urllib issue\n+SERVICE_URL_FORMAT = 'http://127.0.0.1:{port}'\nMANIFEST_PATH_FORMAT = '/manifest?id={videoid}'\nLICENSE_PATH_FORMAT = '/license?id={videoid}'\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Changed service address with 127.0.0.1 see note
106,046
01.05.2020 10:04:38
-7,200
f4bf4140897fb5ffcba79105a1dde65ff3b74fc8
Minor event data update
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -235,7 +235,7 @@ class EventsHandler(threading.Thread):\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+ 'preferUnletterboxed': False, # Should be set equal to the manifest request\n'uiplaycontext': {\n# 'list_id': list_id, # not mandatory\n# Add 'lolomo_id' seems to prevent failure of the 'refreshListByContext' request\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Minor event data update
106,046
01.05.2020 15:48:11
-7,200
8dab286d6cdfe66bc61be10f1b29b91749153c9f
Fixed h265 video mediaflag
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/infolabels.py", "new_path": "resources/lib/kodi/infolabels.py", "diff": "@@ -26,10 +26,13 @@ try: # Python 2\nexcept NameError: # Python 3\nunicode = str # pylint: disable=redefined-builtin\n+# For each videos Netflix provides multiple codecs and the resolutions depends on type of device/SO/DRM used\n+# it is not possible to provide specific info, then we set info according to the video properties of the video list data\n+# h264 is the entry-level codec always available to all streams, the 4k only works with HEVC\nQUALITIES = [\n{'codec': 'h264', 'width': '960', 'height': '540'},\n{'codec': 'h264', 'width': '1920', 'height': '1080'},\n- {'codec': 'h265', 'width': '3840', 'height': '2160'}\n+ {'codec': 'hevc', 'width': '3840', 'height': '2160'}\n]\nJSONRPC_MAPPINGS = {\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed h265 video mediaflag
106,046
01.05.2020 09:28:16
-7,200
35beb04786071add7d11f3bd2619e98f851ad29b
Fixed get_video_raw_data path request cause of KeyError: u'videos' error when play videos
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/api_requests.py", "new_path": "resources/lib/api/api_requests.py", "diff": "@@ -125,12 +125,12 @@ def update_videoid_bookmark(video_id):\[email protected]_execution(immediate=False)\ndef get_video_raw_data(videoids, custom_partial_path=None): # Do not apply cache to this method\n\"\"\"Retrieve raw data for specified video id's\"\"\"\n- video_ids = [videoid.value for videoid in videoids]\n+ video_ids = [int(videoid.value) for videoid in videoids]\ncommon.debug('Requesting video raw data for {}', video_ids)\nif not custom_partial_path:\npaths = build_paths(['videos', video_ids], EPISODES_PARTIAL_PATHS)\nif videoids[0].mediatype == common.VideoId.EPISODE:\n- paths.extend(build_paths(['videos', videoids[0].tvshowid], ART_PARTIAL_PATHS + [['title']]))\n+ paths.extend(build_paths(['videos', int(videoids[0].tvshowid)], ART_PARTIAL_PATHS + [['title']]))\nelse:\npaths = build_paths(['videos', video_ids], custom_partial_path)\nreturn common.make_call('path_request', paths)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/infolabels.py", "new_path": "resources/lib/kodi/infolabels.py", "diff": "@@ -256,7 +256,7 @@ def get_info_from_netflix(videoids):\nif videoids_to_request:\n# Retrieve missing data from API\n- common.debug('Retrieving infolabels and art from API for videoids {}', videoids_to_request)\n+ common.debug('Retrieving infolabels and art from API for {} videoids', len(videoids_to_request))\nraw_data = api.get_video_raw_data(videoids_to_request)\nfor videoid in videoids_to_request:\ninfos = get_info(videoid, raw_data['videos'][videoid.value], raw_data, profile_language_code)[0]\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed get_video_raw_data path request cause of KeyError: u'videos' error when play videos
106,046
02.05.2020 11:47:41
-7,200
4eb489638a372bbfd21f865988c1c71cc6ba00fe
Init lenght more precise
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -23,9 +23,9 @@ def convert_to_dash(manifest):\nhas_drm_streams = manifest['hasDrmStreams']\nprotection_info = _get_protection_info(manifest) if has_drm_streams else None\n- seconds = int(manifest['duration'] / 1000)\n+ seconds = manifest['duration'] / 1000\ninit_length = int(seconds / 2 * 12 + 20 * 1000)\n- duration = \"PT\" + str(seconds) + \".00S\"\n+ duration = \"PT\" + str(int(seconds)) + \".00S\"\nroot = _mpd_manifest_root(duration)\nperiod = ET.SubElement(root, 'Period', start='PT0S', duration=duration)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Init lenght more precise
106,046
02.05.2020 12:01:56
-7,200
e6346cd733cb95933822770bb6edbd360b28b788
Fixed conversion of protection data
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -20,9 +20,6 @@ def convert_to_dash(manifest):\nfrom xbmcaddon import Addon\nisa_version = g.remove_ver_suffix(g.py2_decode(Addon('inputstream.adaptive').getAddonInfo('version')))\n- has_drm_streams = manifest['hasDrmStreams']\n- protection_info = _get_protection_info(manifest) if has_drm_streams else None\n-\nseconds = manifest['duration'] / 1000\ninit_length = int(seconds / 2 * 12 + 20 * 1000)\nduration = \"PT\" + str(int(seconds)) + \".00S\"\n@@ -30,15 +27,21 @@ def convert_to_dash(manifest):\nroot = _mpd_manifest_root(duration)\nperiod = ET.SubElement(root, 'Period', start='PT0S', duration=duration)\n+ has_video_drm_streams = manifest['video_tracks'][0].get('hasDrmStreams', False)\n+ video_protection_info = _get_protection_info(manifest['video_tracks'][0]) if has_video_drm_streams else None\n+\nfor video_track in manifest['video_tracks']:\n- _convert_video_track(video_track, period, init_length, protection_info, has_drm_streams)\n+ _convert_video_track(video_track, period, init_length, video_protection_info, has_video_drm_streams)\ncommon.fix_locale_languages(manifest['audio_tracks'])\ncommon.fix_locale_languages(manifest['timedtexttracks'])\n+ has_audio_drm_streams = manifest['audio_tracks'][0].get('hasDrmStreams', False)\n+\ndefault_audio_language_index = _get_default_audio_language(manifest)\nfor index, audio_track in enumerate(manifest['audio_tracks']):\n- _convert_audio_track(audio_track, period, init_length, (index == default_audio_language_index), has_drm_streams)\n+ _convert_audio_track(audio_track, period, init_length, (index == default_audio_language_index),\n+ has_audio_drm_streams)\ndefault_subtitle_language_index = _get_default_subtitle_language(manifest)\nfor index, text_track in enumerate(manifest['timedtexttracks']):\n@@ -72,31 +75,26 @@ def _add_segment_base(representation, init_length):\nindexRangeExact='true')\n-def _get_protection_info(manifest):\n- try:\n- pssh = None\n- keyid = None\n- if 'drmHeader' in manifest:\n- pssh = manifest['drmHeader']['bytes']\n- keyid = manifest['drmHeader']['keyId']\n- except (KeyError, AttributeError, IndexError):\n- pssh = None\n- keyid = None\n+def _get_protection_info(content):\n+ pssh = content.get('drmHeader', {}).get('bytes')\n+ keyid = content.get('drmHeader', {}).get('keyId')\nreturn {'pssh': pssh, 'keyid': keyid}\ndef _add_protection_info(adaptation_set, pssh, keyid):\nif keyid:\n+ from base64 import standard_b64decode\nprotection = ET.SubElement(\nadaptation_set, # Parent\n'ContentProtection', # Tag\nvalue='cenc',\n- schemeIdUri='urn:mpeg:dash:mp4protection:2011').set(\n- 'cenc:default_KID', str(uuid.UUID(bytes=keyid)))\n+ schemeIdUri='urn:mpeg:dash:mp4protection:2011')\n+ protection.set('cenc:default_KID', str(uuid.UUID(bytes=standard_b64decode(keyid))))\n+ else:\nprotection = ET.SubElement(\nadaptation_set, # Parent\n'ContentProtection', # Tag\n- schemeIdUri='urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED')\n+ schemeIdUri='urn:uuid:EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED') # Widevine UUID\nET.SubElement(\nprotection, # Parent\n'widevine:license', # Tag\n@@ -105,7 +103,7 @@ def _add_protection_info(adaptation_set, pssh, keyid):\nET.SubElement(protection, 'cenc:pssh').text = pssh\n-def _convert_video_track(video_track, period, init_length, protection, drm_streams):\n+def _convert_video_track(video_track, period, init_length, protection, has_drm_streams):\nadaptation_set = ET.SubElement(\nperiod, # Parent\n'AdaptationSet', # Tag\n@@ -114,10 +112,10 @@ def _convert_video_track(video_track, period, init_length, protection, drm_strea\nif protection:\n_add_protection_info(adaptation_set, **protection)\n- limit_res = _limit_video_resolution(video_track['streams'], drm_streams)\n+ limit_res = _limit_video_resolution(video_track['streams'], has_drm_streams)\nfor downloadable in video_track['streams']:\n- if downloadable['isDrm'] != drm_streams:\n+ if downloadable['isDrm'] != has_drm_streams:\ncontinue\nif limit_res:\nif int(downloadable['res_h']) > limit_res:\n@@ -125,7 +123,7 @@ def _convert_video_track(video_track, period, init_length, protection, drm_strea\n_convert_video_downloadable(downloadable, adaptation_set, init_length)\n-def _limit_video_resolution(video_tracks, drm_streams):\n+def _limit_video_resolution(video_tracks, has_drm_streams):\n\"\"\"Limit max video resolution to user choice\"\"\"\nmax_resolution = g.ADDON.getSettingString('stream_max_resolution')\nif max_resolution != '--':\n@@ -143,7 +141,7 @@ def _limit_video_resolution(video_tracks, drm_streams):\nreturn None\n# At least an equal or lower resolution must exist otherwise disable the imposed limit\nfor downloadable in video_tracks:\n- if downloadable['isDrm'] != drm_streams:\n+ if downloadable['isDrm'] != has_drm_streams:\ncontinue\nif int(downloadable['res_h']) <= res_limit:\nreturn res_limit\n@@ -176,7 +174,7 @@ def _determine_video_codec(content_profile):\nreturn 'h264'\n-def _convert_audio_track(audio_track, period, init_length, default, drm_streams): # pylint: disable=unused-argument\n+def _convert_audio_track(audio_track, period, init_length, default, has_drm_streams): # pylint: disable=unused-argument\nchannels_count = {'1.0': '1', '2.0': '2', '5.1': '6', '7.1': '8'}\nimpaired = 'true' if audio_track['trackType'] == 'ASSISTIVE' else 'false'\noriginal = 'true' if audio_track['isNative'] else 'false'\n@@ -197,7 +195,7 @@ def _convert_audio_track(audio_track, period, init_length, default, drm_streams)\nadaptation_set.set('name', 'ATMOS')\nfor downloadable in audio_track['streams']:\n# Some audio stream has no drm\n- # if downloadable['isDrm'] != drm_streams:\n+ # if downloadable['isDrm'] != has_drm_streams:\n# continue\n_convert_audio_downloadable(downloadable, adaptation_set, init_length, channels_count[downloadable['channels']])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed conversion of protection data
106,046
02.05.2020 16:11:29
-7,200
fdbb9d65e672fcc0574595c22707b83388af7337
Catch error 401 more deeply the http 401 error seem apparently more complex
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/exceptions.py", "new_path": "resources/lib/api/exceptions.py", "diff": "@@ -83,3 +83,7 @@ class CacheMiss(Exception):\nclass UnknownCacheBucketError(Exception):\n\"\"\"The requested cache bucket does not exist\"\"\"\n+\n+\n+class HttpError401(Exception):\n+ \"\"\"The request has returned http error 401 unauthorized for url ...\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -94,27 +94,11 @@ class Directory(object):\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\nreturn\ncommon.debug('Showing home listing')\n- try:\nlist_data, extra_data = common.make_call('get_mainmenu') # pylint: disable=unused-variable\nfinalize_directory(convert_list(list_data), g.CONTENT_FOLDER,\ntitle=(g.LOCAL_DB.get_profile_config('profileName', '???') +\n' - ' + common.get_local_string(30097)))\nend_of_directory(False, cache_to_disc)\n- except Exception as exc: # pylint: disable=broad-except\n- if str(exc) != 'HTTPError':\n- raise\n- # 30/04/2020 - http error 401 issue\n- # After the profile selection sometime can happen the http error 401 Client Error: Unauthorized for url ...\n- # due to the failure of the first shakti API request.\n- # After a revision of the code of initial access, i have not found any reason that could cause this problem,\n- # i am beginning to suspect that is a problem of the netflix service.\n- # Not found any solutions, two http attempts are already made, so notify the user of the problem.\n- common.error('Stop navigation due to too many http authURL errors (known error currently unresolvable)')\n- ui.show_ok_dialog(common.get_local_string(30105),\n- ('There was a communication problem with Netflix.\\r\\n'\n- 'This is a known and unresolvable issue, do not submit reports.\\r\\n'\n- 'You can try the operation again or exit.'))\n- xbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\ndef _activate_profile(self, guid):\npin_result = verify_profile_pin(guid)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -13,10 +13,11 @@ from functools import wraps\nfrom xbmc import getCondVisibility, Monitor, getInfoLabel\nfrom xbmcgui import Window\n-from resources.lib.globals import g\n+from resources.lib.api.exceptions import HttpError401\nfrom resources.lib.common import (info, debug, warn, error, check_credentials, BackendNotReady,\nlog_time_trace, reset_log_level_global_var,\nget_current_kodi_profile_name, get_local_string)\n+from resources.lib.globals import g\nfrom resources.lib.upgrade_controller import check_addon_upgrade\n@@ -165,7 +166,7 @@ def _check_valid_credentials():\ndef run(argv):\n- # pylint: disable=broad-except,ungrouped-imports\n+ # pylint: disable=broad-except,ungrouped-imports,too-many-branches\n# Initialize globals right away to avoid stale values from the last addon invocation.\n# Otherwise Kodi's reuseLanguageInvoker will cause some really quirky behavior!\n# PR: https://github.com/xbmc/xbmc/pull/13814\n@@ -210,6 +211,14 @@ def run(argv):\nfrom resources.lib.kodi.ui import show_backend_not_ready\nshow_backend_not_ready()\nsuccess = False\n+ except HttpError401:\n+ # Http error 401 Client Error: Unauthorized for url ... issue (see _request in nfsession_requests.py)\n+ from resources.lib.kodi.ui import show_ok_dialog\n+ show_ok_dialog(get_local_string(30105),\n+ ('There was a communication problem with Netflix.\\r\\n'\n+ 'This is a known and unresolvable issue, do not submit reports.\\r\\n'\n+ 'You can try the operation again or exit.'))\n+ success = False\nexcept Exception as exc:\nimport traceback\nfrom resources.lib.kodi.ui import show_addon_error_info\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.services.nfsession.nfsession_base import NFSessionBase, needs\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.api.exceptions import (APIError, WebsiteParsingError,\nInvalidMembershipStatusError, InvalidMembershipStatusAnonymous,\n- LoginValidateErrorIncorrectPassword)\n+ LoginValidateErrorIncorrectPassword, HttpError401)\nfrom resources.lib.services.nfsession.nfsession_endpoints import ENDPOINTS, BASE_URL\n@@ -79,6 +79,17 @@ class NFSessionRequests(NFSessionBase):\ncommon.warn('Try refresh session data due to {} http error', response.status_code)\nif self.try_refresh_session_data():\nreturn self._request(method, component, True, **kwargs)\n+ if response.status_code == 401:\n+ # 30/04/2020: first signal of http error 401 issues\n+ # After the profile selection sometime can happen the http error 401 Client Error: Unauthorized for url ...\n+ # due to the failure of the first shakti API request.\n+ # After a revision of the code of initial access, i have not found any reason that could cause this problem,\n+ # i am beginning to suspect that is a problem of the netflix service.\n+ # Not found any solutions, two http attempts are already made, so notify the user of the problem.\n+ # 02/05/2020: i intercepted this problem even browsing several times the lists,\n+ # does not happen often, so the problem is more complex.\n+ common.error('Raise error due to too many http error 401 (known error currently unresolvable)')\n+ raise HttpError401\nresponse.raise_for_status()\nreturn (_raise_api_error(response.json() if response.content else {})\nif endpoint_conf['is_api_call']\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Catch error 401 more deeply the http 401 error seem apparently more complex
106,046
03.05.2020 16:27:54
-7,200
ffa1fa160d2a09a897ae293597fd2c39c6180802
Fixed send signal to upnext sending a signal to upnext addon with empty data will cause upnext to crash this will be handled in the future upnext addon versions
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -89,7 +89,7 @@ def play(videoid):\nvideoid_next_episode = None\nif not is_played_from_addon or is_upnext_enabled:\n- if is_upnext_enabled:\n+ if is_upnext_enabled and videoid.mediatype == common.VideoId.EPISODE:\n# When UpNext is enabled, get the next episode to play\nvideoid_next_episode = _upnext_get_next_episode_videoid(videoid, metadata)\ninfo_data = infolabels.get_info_from_netflix(\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/upnext.py", "new_path": "resources/lib/services/playback/upnext.py", "diff": "@@ -29,7 +29,7 @@ class UpNextNotifier(PlaybackActionManager):\nreturn 'enabled={}'.format(self.enabled)\ndef _initialize(self, data):\n- if not data['info_data'] or not data['videoid_next_episode']:\n+ if not data['videoid_next_episode'] or not data['info_data']:\nreturn\nvideoid = common.VideoId.from_dict(data['videoid'])\nvideoid_next_episode = common.VideoId.from_dict(data['videoid_next_episode'])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed send signal to upnext sending a signal to upnext addon with empty data will cause upnext to crash this will be handled in the future upnext addon versions
106,046
04.05.2020 18:34:11
-7,200
ae8e17aea7478ba24c7281c10e4fe6b83cfebd69
Add CDN selection setting
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -951,3 +951,7 @@ msgstr \"\"\nmsgctxt \"#30240\"\nmsgid \"The background services cannot be started due to this problem:\\r\\n{}\"\nmsgstr \"\"\n+\n+msgctxt \"#30241\"\n+msgid \"Open Connect CDN (the lower index is better)\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -20,6 +20,11 @@ def convert_to_dash(manifest):\nfrom xbmcaddon import Addon\nisa_version = g.remove_ver_suffix(g.py2_decode(Addon('inputstream.adaptive').getAddonInfo('version')))\n+ # If a CDN server has stability problems it may cause errors with streaming,\n+ # we allow users to select a different CDN server\n+ # (should be managed by ISA but is currently is not implemented)\n+ cdn_index = int(g.ADDON.getSettingString('cdn_server')[-1]) - 1\n+\nseconds = manifest['duration'] / 1000\ninit_length = int(seconds / 2 * 12 + 20 * 1000)\nduration = \"PT\" + str(int(seconds)) + \".00S\"\n@@ -31,7 +36,7 @@ def convert_to_dash(manifest):\nvideo_protection_info = _get_protection_info(manifest['video_tracks'][0]) if has_video_drm_streams else None\nfor video_track in manifest['video_tracks']:\n- _convert_video_track(video_track, period, init_length, video_protection_info, has_video_drm_streams)\n+ _convert_video_track(video_track, period, init_length, video_protection_info, has_video_drm_streams, cdn_index)\ncommon.fix_locale_languages(manifest['audio_tracks'])\ncommon.fix_locale_languages(manifest['timedtexttracks'])\n@@ -41,13 +46,13 @@ def convert_to_dash(manifest):\ndefault_audio_language_index = _get_default_audio_language(manifest)\nfor index, audio_track in enumerate(manifest['audio_tracks']):\n_convert_audio_track(audio_track, period, init_length, (index == default_audio_language_index),\n- has_audio_drm_streams)\n+ has_audio_drm_streams, cdn_index)\ndefault_subtitle_language_index = _get_default_subtitle_language(manifest)\nfor index, text_track in enumerate(manifest['timedtexttracks']):\nif text_track['isNoneTrack']:\ncontinue\n- _convert_text_track(text_track, period, (index == default_subtitle_language_index), isa_version)\n+ _convert_text_track(text_track, period, (index == default_subtitle_language_index), cdn_index, isa_version)\nxml = ET.tostring(root, encoding='utf-8', method='xml')\nif common.is_debug_verbose():\n@@ -103,7 +108,7 @@ def _add_protection_info(adaptation_set, pssh, keyid):\nET.SubElement(protection, 'cenc:pssh').text = pssh\n-def _convert_video_track(video_track, period, init_length, protection, has_drm_streams):\n+def _convert_video_track(video_track, period, init_length, protection, has_drm_streams, cdn_index):\nadaptation_set = ET.SubElement(\nperiod, # Parent\n'AdaptationSet', # Tag\n@@ -120,7 +125,7 @@ def _convert_video_track(video_track, period, init_length, protection, has_drm_s\nif limit_res:\nif int(downloadable['res_h']) > limit_res:\ncontinue\n- _convert_video_downloadable(downloadable, adaptation_set, init_length)\n+ _convert_video_downloadable(downloadable, adaptation_set, init_length, cdn_index)\ndef _limit_video_resolution(video_tracks, has_drm_streams):\n@@ -148,7 +153,7 @@ def _limit_video_resolution(video_tracks, has_drm_streams):\nreturn None\n-def _convert_video_downloadable(downloadable, adaptation_set, init_length):\n+def _convert_video_downloadable(downloadable, adaptation_set, init_length, cdn_index):\nrepresentation = ET.SubElement(\nadaptation_set, # Parent\n'Representation', # Tag\n@@ -160,7 +165,7 @@ def _convert_video_downloadable(downloadable, adaptation_set, init_length):\ncodecs=_determine_video_codec(downloadable['content_profile']),\nframeRate=str(downloadable['framerate_value'] / downloadable['framerate_scale']),\nmimeType='video/mp4')\n- _add_base_url(representation, downloadable['urls'][0]['url'])\n+ _add_base_url(representation, downloadable['urls'][cdn_index]['url'])\n_add_segment_base(representation, init_length)\n@@ -174,7 +179,8 @@ def _determine_video_codec(content_profile):\nreturn 'h264'\n-def _convert_audio_track(audio_track, period, init_length, default, has_drm_streams): # pylint: disable=unused-argument\n+# pylint: disable=unused-argument\n+def _convert_audio_track(audio_track, period, init_length, default, has_drm_streams, cdn_index):\nchannels_count = {'1.0': '1', '2.0': '2', '5.1': '6', '7.1': '8'}\nimpaired = 'true' if audio_track['trackType'] == 'ASSISTIVE' else 'false'\noriginal = 'true' if audio_track['isNative'] else 'false'\n@@ -197,10 +203,11 @@ def _convert_audio_track(audio_track, period, init_length, default, has_drm_stre\n# Some audio stream has no drm\n# if downloadable['isDrm'] != has_drm_streams:\n# continue\n- _convert_audio_downloadable(downloadable, adaptation_set, init_length, channels_count[downloadable['channels']])\n+ _convert_audio_downloadable(downloadable, adaptation_set, init_length, channels_count[downloadable['channels']],\n+ cdn_index)\n-def _convert_audio_downloadable(downloadable, adaptation_set, init_length, channels_count):\n+def _convert_audio_downloadable(downloadable, adaptation_set, init_length, channels_count, cdn_index):\ncodec_type = 'aac'\nif 'ddplus-' in downloadable['content_profile'] or 'dd-' in downloadable['content_profile']:\ncodec_type = 'ec-3'\n@@ -216,11 +223,11 @@ def _convert_audio_downloadable(downloadable, adaptation_set, init_length, chann\n'AudioChannelConfiguration', # Tag\nschemeIdUri='urn:mpeg:dash:23003:3:audio_channel_configuration:2011',\nvalue=channels_count)\n- _add_base_url(representation, downloadable['urls'][0]['url'])\n+ _add_base_url(representation, downloadable['urls'][cdn_index]['url'])\n_add_segment_base(representation, init_length)\n-def _convert_text_track(text_track, period, default, isa_version):\n+def _convert_text_track(text_track, period, default, cdn_index, isa_version):\n# Only one subtitle representation per adaptationset\ndownloadable = text_track.get('ttDownloadables')\nif not text_track:\n@@ -262,7 +269,7 @@ def _convert_text_track(text_track, period, default, isa_version):\nadaptation_set, # Parent\n'Representation', # Tag\nnflxProfile=content_profile)\n- _add_base_url(representation, list(downloadable[content_profile]['downloadUrls'].values())[0])\n+ _add_base_url(representation, list(downloadable[content_profile]['downloadUrls'].values())[cdn_index])\ndef _get_default_audio_language(manifest):\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"ishelper_settings\" type=\"action\" label=\"30213\" action=\"Addon.OpenSettings(script.module.inputstreamhelper)\" option=\"close\"/>\n<setting label=\"30115\" type=\"lsep\"/><!--Content Profiles-->\n<!--If something is changed in this group remember to make the changes also on settings_monitor.py \"content profiles\"-->\n- <setting id=\"stream_max_resolution\" type=\"labelenum\" label=\"30194\" values=\"--|SD 480p|SD 576p|HD 720p|Full HD 1080p|UHD 4K\" default=\"--\" />\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n<setting id=\"enable_vp9_profiles\" type=\"bool\" label=\"30137\" enable=\"eq(1,false)|eq(0,true)\" default=\"true\"/>\n<setting id=\"enable_hevc_profiles\" type=\"bool\" label=\"30060\" enable=\"eq(-1,false)|eq(0,true)\" default=\"false\"/>\n<setting id=\"enable_dolbyvision_profiles\" type=\"bool\" label=\"30099\" default=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting id=\"disable_webvtt_subtitle\" type=\"bool\" label=\"30144\" default=\"false\"/>\n<setting id=\"enable_force_hdcp\" type=\"bool\" label=\"30081\" default=\"false\"/>\n- <setting label=\"30016\" type=\"lsep\"/><!--ESN-->\n- <setting id=\"view_esn\" type=\"action\" label=\"30216\" action=\"RunPlugin(plugin://plugin.video.netflix/action/view_esn/)\"/>\n- <setting id=\"esn\" type=\"text\" label=\"30034\" value=\"\" default=\"\"/>\n- <setting id=\"reset_esn\" type=\"action\" label=\"30217\" action=\"RunPlugin(plugin://plugin.video.netflix/action/reset_esn/)\" option=\"close\"/>\n<setting label=\"30116\" type=\"lsep\"/><!--Advanced Addon Configuration-->\n<setting id=\"debug_log_level\" type=\"labelenum\" label=\"30066\" values=\"Disabled|Info|Verbose\" default=\"Disabled\"/>\n<setting id=\"enable_timing\" type=\"bool\" label=\"30134\" default=\"false\" visible=\"eq(-1,2)\" subsetting=\"true\"/>\n<setting id=\"show_codec_info\" type=\"bool\" label=\"30073\" default=\"false\" visible=\"eq(-2,2)\" subsetting=\"true\"/>\n+ <setting id=\"stream_max_resolution\" type=\"labelenum\" label=\"30194\" values=\"--|SD 480p|SD 576p|HD 720p|Full HD 1080p|UHD 4K\" default=\"--\" />\n+ <setting id=\"cdn_server\" type=\"labelenum\" label=\"30241\" values=\"Server 1|Server 2|Server 3\" default=\"Server 1\" />\n<setting id=\"enable_ipc_over_http\" type=\"bool\" label=\"30139\" default=\"false\"/>\n<setting id=\"disable_modal_error_display\" type=\"bool\" label=\"30130\" default=\"false\"/>\n<setting id=\"ssl_verification\" type=\"bool\" label=\"30024\" default=\"true\" visible=\"false\"/> <!-- just for developers -->\n+ <setting label=\"30016\" type=\"lsep\"/><!--ESN-->\n+ <setting id=\"view_esn\" type=\"action\" label=\"30216\" action=\"RunPlugin(plugin://plugin.video.netflix/action/view_esn/)\"/>\n+ <setting id=\"esn\" type=\"text\" label=\"30034\" value=\"\" default=\"\"/>\n+ <setting id=\"reset_esn\" type=\"action\" label=\"30217\" action=\"RunPlugin(plugin://plugin.video.netflix/action/reset_esn/)\" option=\"close\"/>\n<setting label=\"30117\" type=\"lsep\"/><!--Cache-->\n<setting id=\"cache_ttl\" type=\"slider\" option=\"int\" range=\"5,5,2880\" label=\"30084\" default=\"180\"/>\n<setting id=\"cache_mylist_ttl\" type=\"slider\" option=\"int\" range=\"10,10,1440\" label=\"30086\" default=\"60\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add CDN selection setting
106,046
04.05.2020 20:38:47
-7,200
cc5916044e132b4bcc9129f5dd6a32393c71b6dd
Catch InputStreamHelper errors avoids confusing users most of the time they think the problem is in this add-on
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/exceptions.py", "new_path": "resources/lib/api/exceptions.py", "diff": "@@ -87,3 +87,7 @@ class UnknownCacheBucketError(Exception):\nclass HttpError401(Exception):\n\"\"\"The request has returned http error 401 unauthorized for url ...\"\"\"\n+\n+\n+class InputStreamHelperError(Exception):\n+ \"\"\"An internal error has occurred to InputStream Helper add-on\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/config_wizard.py", "new_path": "resources/lib/config_wizard.py", "diff": "@@ -14,6 +14,7 @@ from xbmc import getCondVisibility\nfrom xbmcaddon import Addon\nfrom xbmcgui import getScreenHeight, getScreenWidth\n+from resources.lib.api.exceptions import InputStreamHelperError\nfrom 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@@ -47,10 +48,17 @@ def run_addon_configuration(show_end_msg=False):\ndef _set_isa_addon_settings(is_4k_capable, hdcp_override):\n\"\"\"Method for self-configuring of InputStream Adaptive add-on\"\"\"\n+ try:\nis_helper = inputstreamhelper.Helper('mpd')\nif not is_helper.check_inputstream():\nshow_ok_dialog(get_local_string(30154), get_local_string(30046))\nreturn\n+ except Exception as exc: # pylint: disable=broad-except\n+ # Captures all types of ISH internal errors\n+ import traceback\n+ error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n+ raise InputStreamHelperError(str(exc))\n+\nisa_addon = Addon('inputstream.adaptive')\nisa_addon.setSettingBool('HDCPOVERRIDE', hdcp_override)\nif isa_addon.getSettingInt('STREAMSELECTION') == 1:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -12,7 +12,7 @@ from __future__ import absolute_import, division, unicode_literals\nimport xbmcplugin\nimport xbmcgui\n-from resources.lib.api.exceptions import MetadataNotAvailable\n+from resources.lib.api.exceptions import MetadataNotAvailable, InputStreamHelperError\nfrom resources.lib.api.paths import EVENT_PATHS\nfrom resources.lib.database.db_utils import TABLE_SESSION\nfrom resources.lib.globals import g\n@@ -45,10 +45,6 @@ INPUTSTREAM_SERVER_CERTIFICATE = (\n'0fFdCmw=')\n-class InputstreamError(Exception):\n- \"\"\"There was an error with setting up inputstream.adaptive\"\"\"\n-\n-\[email protected]_video_id(path_offset=0, pathitems_arg='videoid', inject_full_pathitems=True)\[email protected]_execution(immediate=False)\ndef play(videoid):\n@@ -160,11 +156,18 @@ def get_inputstream_listitem(videoid):\nlist_item.setProperty('isFolder', 'false')\nlist_item.setProperty('IsPlayable', 'true')\n+ try:\nimport inputstreamhelper\nis_helper = inputstreamhelper.Helper('mpd', drm='widevine')\n-\n- if not is_helper.check_inputstream():\n- raise InputstreamError(common.get_local_string(30046))\n+ inputstream_ready = is_helper.check_inputstream()\n+ except Exception as exc: # pylint: disable=broad-except\n+ # Captures all types of ISH internal errors\n+ import traceback\n+ common.error(g.py2_decode(traceback.format_exc(), 'latin-1'))\n+ raise InputStreamHelperError(str(exc))\n+\n+ if not inputstream_ready:\n+ raise Exception(common.get_local_string(30046))\nlist_item.setProperty(\nkey=is_helper.inputstream_addon + '.stream_headers',\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/run_addon.py", "new_path": "resources/lib/run_addon.py", "diff": "@@ -13,7 +13,7 @@ from functools import wraps\nfrom xbmc import getCondVisibility, Monitor, getInfoLabel\nfrom xbmcgui import Window\n-from resources.lib.api.exceptions import HttpError401\n+from resources.lib.api.exceptions import HttpError401, InputStreamHelperError\nfrom resources.lib.common import (info, debug, warn, error, check_credentials, BackendNotReady,\nlog_time_trace, reset_log_level_global_var,\nget_current_kodi_profile_name, get_local_string)\n@@ -211,6 +211,13 @@ def run(argv):\nfrom resources.lib.kodi.ui import show_backend_not_ready\nshow_backend_not_ready()\nsuccess = False\n+ except InputStreamHelperError as exc:\n+ from resources.lib.kodi.ui import show_ok_dialog\n+ show_ok_dialog('InputStream Helper Add-on error',\n+ ('The operation has been cancelled.\\r\\n'\n+ 'InputStream Helper has generated an internal error:\\r\\n{}\\r\\n\\r\\n'\n+ 'Please report it to InputStream Helper github.'.format(exc)))\n+ success = False\nexcept HttpError401:\n# Http error 401 Client Error: Unauthorized for url ... issue (see _request in nfsession_requests.py)\nfrom resources.lib.kodi.ui import show_ok_dialog\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Catch InputStreamHelper errors avoids confusing users most of the time they think the problem is in this add-on
106,047
04.05.2020 19:59:31
14,400
370e347cd95586c4e1b3c29ad8564064e6ec215f
fix wrong timestamps in viewing activity
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/events_handler.py", "new_path": "resources/lib/services/msl/events_handler.py", "diff": "@@ -200,7 +200,7 @@ class EventsHandler(threading.Thread):\n# Get previous elaborated data of the same video id\n# Some tags must remain unchanged between events\nprevious_data, previous_player_state = self.cache_data_events.get(videoid.value, ({}, None))\n- timestamp = int(time.time() * 10000)\n+ timestamp = int(time.time() * 1000)\n# Context location values can be easily viewed from tag data-ui-tracking-context\n# of a preview box in website html\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
fix wrong timestamps in viewing activity