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
08.06.2019 21:21:04
-7,200
9e0bad3670e81dd66a6dd6a032c9042f310e9de6
Version bump (14.4)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.3\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.4\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.14.4 (2019-06-08)\n+-Implemented the trailers list to every TvShows and Movies (context menu)\n+-Audio/subtitle preferences is now also saved for movies\n+-The STRM now can be resumed it's a workaround (can be disabled in settings)\n+-Added UpNext settings shortcut in to settings\n+-Fixed visibility of non-existing subgenres\n+-Fixed order sequence of profiles\n+-Many other improvements and fixes\n+\nv0.14.3 (2019-05-24)\n- Fixed error when playing from kodi library\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (14.4)
106,046
08.06.2019 22:44:02
-7,200
afc7775199ca243bccc7edc20e1cb21cd27a8af9
Forgotten metadata variable for trailers
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -330,7 +330,7 @@ def update_my_list(videoid, operation):\[email protected]_execution(immediate=False)\ndef metadata(videoid):\n\"\"\"Retrieve additional metadata for the given VideoId\"\"\"\n- if videoid.mediatype == common.VideoId.MOVIE:\n+ if videoid.mediatype == common.VideoId.MOVIE or videoid.mediatype == common.VideoId.SUPPLEMENTAL:\nreturn _metadata(videoid), None\nif videoid.mediatype == common.VideoId.SEASON:\nreturn _metadata(videoid.derive_parent(None)), None\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Forgotten metadata variable for trailers
105,991
09.06.2019 14:25:39
-7,200
a85e584e42409bd779a821752489055dccd43fcc
Fix Show or other missing metadata
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -330,7 +330,7 @@ def update_my_list(videoid, operation):\[email protected]_execution(immediate=False)\ndef metadata(videoid):\n\"\"\"Retrieve additional metadata for the given VideoId\"\"\"\n- if videoid.mediatype == common.VideoId.MOVIE or videoid.mediatype == common.VideoId.SUPPLEMENTAL:\n+ if videoid.mediatype not in [common.VideoId.EPISODE, common.VideoId.SEASON]:\nreturn _metadata(videoid), None\nif videoid.mediatype == common.VideoId.SEASON:\nreturn _metadata(videoid.derive_parent(None)), None\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix Show or other missing metadata
106,046
14.06.2019 21:43:23
-7,200
f0c42bc770f0b16653127ef38d3b574822f81961
Updated profiles Removed playready-heaac-2-dash often cause problems often on android devices and some rpi, audio tracks are silented, several errors in reading the stream. Readded ddplus-5.1hq-dash it's working again very good! sound quality up to 640kbps Added heaac-2hq-dash stereo sound quality up to 128kbps
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/profiles.py", "new_path": "resources/lib/services/msl/profiles.py", "diff": "@@ -34,11 +34,10 @@ PROFILES = {\n'base': [\n# Audio\n'heaac-2-dash',\n- 'playready-heaac-2-dash',\n+ 'heaac-2hq-dash',\n# Unknown\n'BIF240', 'BIF320'],\n- # 'dd-5.1-elem' DD 384< Bitrate, currently inputstream fails to manage this profile\n- 'dolbysound': ['ddplus-2.0-dash', 'ddplus-5.1-dash', 'ddplus-atmos-dash'],\n+ 'dolbysound': ['ddplus-2.0-dash', 'ddplus-5.1-dash', 'ddplus-5.1hq-dash', 'ddplus-atmos-dash'],\n'h264': ['playready-h264mpl30-dash', 'playready-h264mpl31-dash',\n'playready-h264mpl40-dash',\n'playready-h264hpl30-dash', 'playready-h264hpl31-dash',\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated profiles -Removed playready-heaac-2-dash often cause problems often on android devices and some rpi, audio tracks are silented, several errors in reading the stream. -Readded ddplus-5.1hq-dash it's working again very good! sound quality up to 640kbps -Added heaac-2hq-dash stereo sound quality up to 128kbps
106,046
15.06.2019 10:55:13
-7,200
b2baa3a50ffb65800be7173ce6649010bf14ed3c
Fixed rating value conversion to UpNext Addon
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -178,6 +178,8 @@ def _find_next_episode(videoid, metadata):\ndef 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 UpNext Addon\n+ rating = infos.get('rating', None)\nreturn {\n'episodeid': videoid.episodeid,\n'tvshowid': videoid.tvshowid,\n@@ -195,6 +197,6 @@ def upnext_info(videoid, infos, art):\n'playcount': infos.get('playcount', 0),\n'season': infos['season'],\n'episode': infos['episode'],\n- 'rating': infos.get('rating', infos.get('userrating', '')),\n+ 'rating': rating if rating else None,\n'firstaired': infos.get('year', infos.get('firstaired', ''))\n}\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed rating value conversion to UpNext Addon
106,046
18.06.2019 20:34:14
-7,200
ba56b170962a9fa8e7f92aeb8584ac3242d7b85a
Hide subtitle workaround more precise I found the example of an episode that had forced subtitles in other languages except the one being listened to
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -223,11 +223,7 @@ def _get_default_audio_language(manifest):\nchannelList = {'1.0': '1', '2.0': '2'}\nchannelListDolby = {'5.1': '6', '7.1': '8'}\n- # Read language in Kodi settings\n- audio_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})\n- audio_language = xbmc.convertLanguage(audio_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n- audio_language = audio_language if audio_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n- audio_language = audio_language if audio_language else 'en'\n+ audio_language = _get_kodi_audio_language()\n# Try to find the preferred language with the right channels\nif g.ADDON.getSettingBool('enable_dolby_sound'):\n@@ -252,22 +248,21 @@ def _get_default_audio_language(manifest):\ndef _get_default_subtitle_language(manifest):\n- subtitle_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})\n- if subtitle_language['value'] == 'forced_only':\n- # When we set \"forced only\" subtitles in Kodi Player and the forced streams are missing,\n- # Kodi selects the first available non-forced stream. This Kodi behavior is totally non sense.\n+ subtitle_language = _get_kodi_subtitle_language()\n+ if subtitle_language == 'forced_only':\n+ if g.ADDON.getSettingBool('forced_subtitle_workaround'):\n+ # When we set \"forced only\" subtitles in Kodi Player, Kodi use this behavior:\n+ # 1) try to select forced subtitle that matches audio language\n+ # 2) when missing, try to select the first \"regular\" subtitle that matches audio language\n+ # This Kodi behavior is totally non sense. If forced is selected you must not view the regular subtitles\n# There is no other solution than to disable the subtitles manually.\n- if g.ADDON.getSettingBool('forced_subtitle_workaround')\\\n- and not any(text_track.get('isForcedNarrative', False) is True\n+ audio_language = _get_kodi_audio_language()\n+ if not any(text_track.get('isForcedNarrative', False) is True and text_track['language'] == audio_language\nfor text_track in manifest['timedtexttracks']):\nxbmc.Player().showSubtitles(False)\n# Leave the selection of forced subtitles to Kodi\nreturn -1\nelse:\n- subtitle_language = xbmc.convertLanguage(subtitle_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n- subtitle_language = subtitle_language if subtitle_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n- subtitle_language = subtitle_language if subtitle_language else 'en'\n-\nfor index, text_track in enumerate(manifest['timedtexttracks']):\nif text_track['isNoneTrack']:\ncontinue\n@@ -315,3 +310,26 @@ def _adjust_locale(locale_code, lang_code_without_country_exists):\nelse:\ncommon.debug('AdjustLocale - missing mapping conversion for locale: {}'.format(locale_code))\nreturn locale_code\n+\n+\n+def _get_kodi_audio_language():\n+ \"\"\"\n+ Return the audio language from Kodi settings\n+ \"\"\"\n+ audio_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})\n+ audio_language = xbmc.convertLanguage(audio_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n+ audio_language = audio_language if audio_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n+ return audio_language if audio_language else 'en'\n+\n+\n+def _get_kodi_subtitle_language():\n+ \"\"\"\n+ Return the subtitle language from Kodi settings\n+ \"\"\"\n+ subtitle_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})\n+ if subtitle_language['value'] == 'forced_only':\n+ return subtitle_language['value']\n+ subtitle_language = xbmc.convertLanguage(subtitle_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n+ subtitle_language = subtitle_language if subtitle_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n+ subtitle_language = subtitle_language if subtitle_language else 'en'\n+ return subtitle_language\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Hide subtitle workaround more precise I found the example of an episode that had forced subtitles in other languages except the one being listened to
106,046
19.06.2019 21:43:54
-7,200
5ed88c8c48ac016c55a76d5c121506058d80d918
API_BASE_URL model path changed
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -22,7 +22,7 @@ PAGE_ITEMS = [\n'models/serverDefs/data/BUILD_IDENTIFIER',\n'models/serverDefs/data/ICHNAEA_ROOT',\n'models/serverDefs/data/API_ROOT',\n- 'models/serverDefs/data/API_BASE_URL',\n+ 'models/playerModel/data/config/ui/initParams/apiUrl',\n'models/esnGeneratorModel/data/esn',\n'models/memberContext/data/geo/preferredLocale'\n]\n@@ -113,7 +113,7 @@ def _parse_api_data(user_data):\nfor api_item in (\nitem.split('/')[-1]\nfor item in PAGE_ITEMS\n- if 'serverDefs' in item)}\n+ if ('serverDefs' in item) or ('initParams/apiUrl' in item))}\ndef assert_valid_auth_url(user_data):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -445,10 +445,8 @@ def _document_url(component):\ndef _api_url(component, api_data):\n- return '{apiroot}{baseurl}/{buildid}{componenturl}'.format(\n- apiroot=api_data['API_ROOT'],\n- baseurl=api_data['API_BASE_URL'],\n- buildid=api_data['BUILD_IDENTIFIER'],\n+ return '{baseurl}{componenturl}'.format(\n+ baseurl=api_data['apiUrl'],\ncomponenturl=URLS[component]['endpoint'])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
API_BASE_URL model path changed Co-authored-by: Jaker MX <[email protected]> Co-authored-by: Smeulf <[email protected]>
106,046
19.06.2019 21:55:48
-7,200
3e83e416453b1117bcc89e7b43371a16fe72627b
Version bump (14.5)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.4\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.5\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.14.5 (2019-06-19)\n+-Fixed Login error due to Netflix API changes\n+-Fixed return to main menu after a research\n+-No more show subtitle when forced subtitle aren't present\n+-Fixed rating conversion to UpNext Addon\n+-Re-Added DolbyDigital HQ (always enabled on Premium)\n+-Updated Portughese-Brasil, french language\n+-Fixed error with metadata\n+\nv0.14.4 (2019-06-08)\n-Implemented the trailers list to every TvShows and Movies (context menu)\n-Audio/subtitle preferences is now also saved for movies\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (14.5)
106,046
23.06.2019 15:38:01
-7,200
55860266575d8b23804a2525bdd11f1ec154c67f
Moved audio/subtitle/fix_locale functions to kodiops
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -123,3 +123,67 @@ def play_media(media):\ndef stop_playback():\n\"\"\"Stop the running playback\"\"\"\nxbmc.executebuiltin('PlayerControl(Stop)')\n+\n+\n+def get_kodi_audio_language():\n+ \"\"\"\n+ Return the audio language from Kodi settings\n+ \"\"\"\n+ audio_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})\n+ audio_language = xbmc.convertLanguage(audio_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n+ audio_language = audio_language if audio_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n+ return audio_language if audio_language else 'en'\n+\n+\n+def get_kodi_subtitle_language():\n+ \"\"\"\n+ Return the subtitle language from Kodi settings\n+ \"\"\"\n+ subtitle_language = json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})\n+ if subtitle_language['value'] == 'forced_only':\n+ return subtitle_language['value']\n+ subtitle_language = xbmc.convertLanguage(subtitle_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n+ subtitle_language = subtitle_language if subtitle_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n+ subtitle_language = subtitle_language if subtitle_language else 'en'\n+ return subtitle_language\n+\n+\n+def 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+ locale_list_nocountry = []\n+ for item in data_list:\n+ if item.get('isNoneTrack', False):\n+ continue\n+ if len(item['language']) == 2 and not item['language'] in locale_list_nocountry:\n+ locale_list_nocountry.append(item['language'])\n+ # Replace the locale languages with country with a new one\n+ for item in data_list:\n+ if item.get('isNoneTrack', False):\n+ continue\n+ if len(item['language']) == 2:\n+ continue\n+ item['language'] = _adjust_locale(item['language'], item['language'][0:2] in locale_list_nocountry)\n+\n+\n+def _adjust_locale(locale_code, lang_code_without_country_exists):\n+ \"\"\"\n+ Locale conversion helper\n+ Conversion table to prevent Kodi to display es-ES as Spanish - Spanish, pt-BR as Portuguese - Breton, and so on\n+ \"\"\"\n+ locale_conversion_table = {\n+ 'es-ES': 'es-Spain',\n+ 'pt-BR': 'pt-Brazil',\n+ 'fr-CA': 'fr-Canada',\n+ 'ar-EG': 'ar-Egypt',\n+ 'nl-BE': 'nl-Belgium'\n+ }\n+ language_code = locale_code[0:2]\n+ if not lang_code_without_country_exists:\n+ return language_code\n+ else:\n+ if locale_code in locale_conversion_table:\n+ return locale_conversion_table[locale_code]\n+ else:\n+ common.debug('AdjustLocale - missing mapping conversion for locale: {}'.format(locale_code))\n+ return locale_code\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -26,8 +26,8 @@ def convert_to_dash(manifest):\n_convert_video_track(\nvideo_track, period, init_length, protection, drm_streams)\n- _fix_locale_languages(manifest['audio_tracks'])\n- _fix_locale_languages(manifest['timedtexttracks'])\n+ common.fix_locale_languages(manifest['audio_tracks'])\n+ common.fix_locale_languages(manifest['timedtexttracks'])\ndefault_audio_language_index = _get_default_audio_language(manifest)\nfor index, audio_track in enumerate(manifest['audio_tracks']):\n@@ -223,7 +223,7 @@ def _get_default_audio_language(manifest):\nchannelList = {'1.0': '1', '2.0': '2'}\nchannelListDolby = {'5.1': '6', '7.1': '8'}\n- audio_language = _get_kodi_audio_language()\n+ audio_language = common.get_kodi_audio_language()\n# Try to find the preferred language with the right channels\nif g.ADDON.getSettingBool('enable_dolby_sound'):\n@@ -248,7 +248,7 @@ def _get_default_audio_language(manifest):\ndef _get_default_subtitle_language(manifest):\n- subtitle_language = _get_kodi_subtitle_language()\n+ subtitle_language = common.get_kodi_subtitle_language()\nif subtitle_language == 'forced_only':\nif g.ADDON.getSettingBool('forced_subtitle_workaround'):\n# When we set \"forced only\" subtitles in Kodi Player, Kodi use this behavior:\n@@ -256,7 +256,7 @@ def _get_default_subtitle_language(manifest):\n# 2) when missing, try to select the first \"regular\" subtitle that matches audio language\n# This Kodi behavior is totally non sense. If forced is selected you must not view the regular subtitles\n# There is no other solution than to disable the subtitles manually.\n- audio_language = _get_kodi_audio_language()\n+ audio_language = common.get_kodi_audio_language()\nif not any(text_track.get('isForcedNarrative', False) is True and text_track['language'] == audio_language\nfor text_track in manifest['timedtexttracks']):\nxbmc.Player().showSubtitles(False)\n@@ -269,67 +269,3 @@ def _get_default_subtitle_language(manifest):\nif not text_track.get('isForcedNarrative') and text_track['language'] == subtitle_language:\nreturn index\nreturn -1\n-\n-\n-def _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- locale_list_nocountry = []\n- for item in data_list:\n- if item.get('isNoneTrack', False):\n- continue\n- if len(item['language']) == 2 and not item['language'] in locale_list_nocountry:\n- locale_list_nocountry.append(item['language'])\n- # Replace the locale languages with country with a new one\n- for item in data_list:\n- if item.get('isNoneTrack', False):\n- continue\n- if len(item['language']) == 2:\n- continue\n- item['language'] = _adjust_locale(item['language'], item['language'][0:2] in locale_list_nocountry)\n-\n-\n-def _adjust_locale(locale_code, lang_code_without_country_exists):\n- \"\"\"\n- Locale conversion helper\n- Conversion table to prevent Kodi to display es-ES as Spanish - Spanish, pt-BR as Portuguese - Breton, and so on\n- \"\"\"\n- locale_conversion_table = {\n- 'es-ES': 'es-Spain',\n- 'pt-BR': 'pt-Brazil',\n- 'fr-CA': 'fr-Canada',\n- 'ar-EG': 'ar-Egypt',\n- 'nl-BE': 'nl-Belgium'\n- }\n- language_code = locale_code[0:2]\n- if not lang_code_without_country_exists:\n- return language_code\n- else:\n- if locale_code in locale_conversion_table:\n- return locale_conversion_table[locale_code]\n- else:\n- common.debug('AdjustLocale - missing mapping conversion for locale: {}'.format(locale_code))\n- return locale_code\n-\n-\n-def _get_kodi_audio_language():\n- \"\"\"\n- Return the audio language from Kodi settings\n- \"\"\"\n- audio_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.audiolanguage'})\n- audio_language = xbmc.convertLanguage(audio_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n- audio_language = audio_language if audio_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n- return audio_language if audio_language else 'en'\n-\n-\n-def _get_kodi_subtitle_language():\n- \"\"\"\n- Return the subtitle language from Kodi settings\n- \"\"\"\n- subtitle_language = common.json_rpc('Settings.GetSettingValue', {'setting': 'locale.subtitlelanguage'})\n- if subtitle_language['value'] == 'forced_only':\n- return subtitle_language['value']\n- subtitle_language = xbmc.convertLanguage(subtitle_language['value'].encode('utf-8'), xbmc.ISO_639_1)\n- subtitle_language = subtitle_language if subtitle_language else xbmc.getLanguage(xbmc.ISO_639_1, False)\n- subtitle_language = subtitle_language if subtitle_language else 'en'\n- return subtitle_language\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Moved audio/subtitle/fix_locale functions to kodiops
106,046
23.06.2019 15:51:33
-7,200
0ff432fb8e6d511792f311481f95de80b3f7fab3
Moved forced subtitle workaround to stream_continuity In slow systems it could happen that the workaround didn't work because the player started too late
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/stream_continuity.py", "new_path": "resources/lib/services/playback/stream_continuity.py", "diff": "@@ -8,6 +8,8 @@ from __future__ import unicode_literals\nimport xbmc\n+import json\n+\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n@@ -37,7 +39,7 @@ class StreamContinuityManager(PlaybackActionManager):\n\"\"\"\ndef __init__(self):\nsuper(StreamContinuityManager, self).__init__()\n- self.storage = common.PersistentStorage(__name__)\n+ self.storage = common.PersistentStorage(__name__, no_save_on_destroy=True)\nself.current_videoid = None\nself.current_streams = {}\nself.player = xbmc.Player()\n@@ -50,7 +52,6 @@ class StreamContinuityManager(PlaybackActionManager):\nreturn self.storage.get(self.current_videoid, {})\ndef _initialize(self, data):\n- self.resume = data.get('resume', {})\nif 'tvshowid' in data['videoid']:\nself.did_restore = False\nself.current_videoid = data['videoid']['tvshowid']\n@@ -61,17 +62,22 @@ class StreamContinuityManager(PlaybackActionManager):\nself.enabled = False\ndef _on_playback_started(self, player_state):\n- xbmc.sleep(500)\n+ xbmc.sleep(500) # Wait for slower systems\n+ subtitle_streams_restored = False\nfor stype in STREAMS:\nself._set_current_stream(stype, player_state)\n- self._restore_stream(stype)\n+ is_restored = self._restore_stream(stype)\n+ if stype != 'audio':\n+ subtitle_streams_restored = is_restored\n+ if not subtitle_streams_restored and g.ADDON.getSettingBool('forced_subtitle_workaround'):\n+ # Use the workaround only when the user did not change the settings\n+ _show_only_forced_subtitle()\nself.did_restore = True\ndef _on_tick(self, player_state):\nif not self.did_restore:\ncommon.debug('Did not restore streams yet, ignoring tick')\nreturn\n-\nfor stype in STREAMS:\ncurrent_stream = self.current_streams[stype]\nplayer_stream = player_state.get(STREAMS[stype]['current'])\n@@ -98,6 +104,8 @@ class StreamContinuityManager(PlaybackActionManager):\nelse stored_stream))\nself.current_streams[stype] = stored_stream\ncommon.debug('Restored {} to {}'.format(stype, stored_stream))\n+ return True\n+ return False\ndef _save_changed_stream(self, stype, stream):\ncommon.debug('Save changed stream {} for {}'.format(stream, stype))\n@@ -109,3 +117,17 @@ class StreamContinuityManager(PlaybackActionManager):\ndef __repr__(self):\nreturn ('enabled={}, current_videoid={}'\n.format(self.enabled, self.current_videoid))\n+\n+\n+def _show_only_forced_subtitle():\n+ # When we have \"forced only\" subtitle setting in Kodi Player, Kodi use this behavior:\n+ # 1) try to select forced subtitle that matches audio language\n+ # 2) when missing, try to select the first \"regular\" subtitle that matches audio language\n+ # This Kodi behavior is totally non sense. If forced is selected you must not view the regular subtitles\n+ # There is no other solution than to disable the subtitles manually.\n+ manifest_data = json.loads(common.load_file('manifest.json'))\n+ common.fix_locale_languages(manifest_data['timedtexttracks'])\n+ audio_language = common.get_kodi_audio_language()\n+ if not any(text_track.get('isForcedNarrative', False) is True and text_track['language'] == audio_language\n+ for text_track in manifest_data['timedtexttracks']):\n+ xbmc.Player().showSubtitles(False)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Moved forced subtitle workaround to stream_continuity In slow systems it could happen that the workaround didn't work because the player started too late
106,046
23.06.2019 20:13:56
-7,200
d616fffb9ecb1f7bb3ee0153fbbb9967d24244fc
Fixed type error File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/services/msl/msl_handler.py", line 45, in error_catching_wrapper netflix_error=isinstance(exc, MSLError)) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/kodi/ui/dialogs.py", line 113, in show_error_info line3=common.get_local_string(30103)) TypeError: argument "line2" for method "ok" must be unicode or str
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -40,7 +40,7 @@ def display_error_info(func):\ntry:\nreturn func(*args, **kwargs)\nexcept Exception as exc:\n- ui.show_error_info(common.get_local_string(30028), exc.message,\n+ ui.show_error_info(common.get_local_string(30028), unicode(exc.message),\nunknown_error=not exc.message,\nnetflix_error=isinstance(exc, MSLError))\nraise\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed type error File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/services/msl/msl_handler.py", line 45, in error_catching_wrapper netflix_error=isinstance(exc, MSLError)) File "/storage/.kodi/addons/plugin.video.netflix/resources/lib/kodi/ui/dialogs.py", line 113, in show_error_info line3=common.get_local_string(30103)) TypeError: argument "line2" for method "ok" must be unicode or str
105,991
24.06.2019 20:30:31
-7,200
e21a56f313b904c81b31088c36309956ba52f797
Implemented NFO Export
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -743,3 +743,51 @@ msgstr \"\"\nmsgctxt \"#30181\"\nmsgid \"Disable subtitles if there are no forced subtitles streams (Works only if Kodi Player is set to \\\"Only forced\\\" subtitles)\"\nmsgstr \"\"\n+\n+msgctxt \"#30282\"\n+msgid \"Export NFO files\"\n+msgstr \"\"\n+\n+msgctxt \"#30283\"\n+msgid \"Do you want to export NFO files for the {}?\"\n+msgstr \"\"\n+\n+msgctxt \"#30284\"\n+msgid \"NFO Files\"\n+msgstr \"\"\n+\n+msgctxt \"#30285\"\n+msgid \"Enable NFO files export\"\n+msgstr \"\"\n+\n+msgctxt \"#30286\"\n+msgid \"For Movies\"\n+msgstr \"\"\n+\n+msgctxt \"#30287\"\n+msgid \"For TV Show\"\n+msgstr \"\"\n+\n+msgctxt \"#30288\"\n+msgid \"Ask\"\n+msgstr \"\"\n+\n+msgctxt \"#30289\"\n+msgid \"movie\"\n+msgstr \"\"\n+\n+msgctxt \"#30290\"\n+msgid \"TV show\"\n+msgstr \"\"\n+\n+msgctxt \"#30291\"\n+msgid \"Do you want to export NFO files for the {} added to 'My List'?\"\n+msgstr \"\"\n+\n+msgctxt \"#30292\"\n+msgid \"\\r\\nThese files are used by the provider information scrapers to integrate movies and tv shows info, useful with bonus episodes or director's cut\"\n+msgstr \"\"\n+\n+msgctxt \"#30293\"\n+msgid \"Include all information in NFO files (use only with 'Local Information' scraper)\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -4,6 +4,8 @@ from __future__ import unicode_literals\nimport os\nimport re\n+import sys\n+\nfrom datetime import datetime, timedelta\nfrom functools import wraps\n@@ -14,6 +16,10 @@ from resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.api.shakti as api\nimport resources.lib.kodi.ui as ui\n+import resources.lib.kodi.nfo as nfo\n+\n+import xml.etree.ElementTree as ET\n+\nLIBRARY_HOME = 'library'\nFOLDER_MOVIES = 'movies'\n@@ -89,9 +95,10 @@ def _get_item(mediatype, filename):\n{'field': 'path', 'operator': 'startswith', 'value': path},\n{'field': 'filename', 'operator': 'is', 'value': shortname}\n]})[0]\n+ if not library_item:\n+ raise ItemNotFound\nreturn common.get_library_item_details(\nmediatype, library_item[mediatype + 'id'])\n- raise ItemNotFound\ndef list_contents():\n@@ -116,7 +123,7 @@ def update_kodi_library(library_operation):\n_remove_from_kodi_library(videoid)\nlibrary_operation(videoid, task_handler, *args, **kwargs)\nif not is_remove:\n- # Update kodi library through service\n+ # Update Kodi library through service\n# This prevents a second call to cancel the update\ncommon.debug('Notify service to update the library')\ncommon.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n@@ -129,7 +136,7 @@ def _remove_from_kodi_library(videoid):\ntry:\nkodi_library_items = [get_item(videoid)]\nif videoid.mediatype == common.VideoId.SHOW or videoid.mediatype == common.VideoId.SEASON:\n- # Retreive the all episodes in the export folder\n+ # Retrieve the all episodes in the export folder\nfilters = {'and': [\n{'field': 'path', 'operator': 'startswith', 'value': os.path.dirname(kodi_library_items[0]['file'])},\n{'field': 'filename', 'operator': 'endswith', 'value': '.strm'}\n@@ -174,70 +181,89 @@ def purge():\[email protected]_execution(immediate=False)\n-def compile_tasks(videoid):\n+def compile_tasks(videoid, nfo_settings=None):\n\"\"\"Compile a list of tasks for items based on the videoid\"\"\"\ncommon.debug('Compiling library tasks for {}'.format(videoid))\nmetadata = api.metadata(videoid)\nif videoid.mediatype == common.VideoId.MOVIE:\n- return _create_movie_task(videoid, metadata[0])\n+ return _create_movie_task(videoid, metadata[0], nfo_settings)\nelif videoid.mediatype in common.VideoId.TV_TYPES:\n- return _create_tv_tasks(videoid, metadata)\n-\n+ return _create_tv_tasks(videoid, metadata, nfo_settings)\nraise ValueError('Cannot handle {}'.format(videoid))\n-def _create_movie_task(videoid, movie):\n+def _create_movie_task(videoid, movie, nfo_settings):\n\"\"\"Create a task for a movie\"\"\"\n+ # Reset NFO export to false if we never want movies nfo\nname = '{title} ({year})'.format(title=movie['title'], year=movie['year'])\n- return [_create_item_task(name, FOLDER_MOVIES, videoid, name, name)]\n+ return [_create_item_task(name, FOLDER_MOVIES, videoid, name, name,\n+ nfo.create_movie_nfo(movie) if\n+ nfo_settings and nfo_settings.export_movie_enabled else None)]\n-def _create_tv_tasks(videoid, metadata):\n+def _create_tv_tasks(videoid, metadata, nfo_settings):\n\"\"\"Create tasks for a show, season or episode.\nIf videoid represents a show or season, tasks will be generated for\nall contained seasons and episodes\"\"\"\nif videoid.mediatype == common.VideoId.SHOW:\n- return _compile_show_tasks(videoid, metadata[0])\n+ tasks = _compile_show_tasks(videoid, metadata[0], nfo_settings)\nelif videoid.mediatype == common.VideoId.SEASON:\n- return _compile_season_tasks(videoid, metadata[0],\n- common.find(int(videoid.seasonid), 'id',\n- metadata[0]['seasons']))\n- return [_create_episode_task(videoid, *metadata)]\n+ tasks = _compile_season_tasks(videoid,\n+ metadata[0],\n+ common.find(int(videoid.seasonid),\n+ 'id',\n+ metadata[0]['seasons']),\n+ nfo_settings)\n+ else:\n+ tasks = [_create_episode_task(videoid, *metadata, nfo_settings=nfo_settings)]\n+\n+ if nfo_settings and nfo_settings.export_full_tvshow:\n+ # Create tvshow.nfo file\n+ tasks.append(_create_item_task('tvshow.nfo', FOLDER_TV, videoid,\n+ metadata[0]['title'],\n+ 'tvshow',\n+ nfo.create_show_nfo(metadata[0]),\n+ False))\n+ return tasks\n-def _compile_show_tasks(videoid, show):\n+def _compile_show_tasks(videoid, show, nfo_settings):\n\"\"\"Compile a list of task items for all episodes of all seasons\nof a tvshow\"\"\"\n- # This nested comprehension is nasty but neccessary. It flattens\n+ # This nested comprehension is nasty but necessary. It flattens\n# the task lists for each season into one list\nreturn [task for season in show['seasons']\nfor task in _compile_season_tasks(\n- videoid.derive_season(season['id']), show, season)]\n+ videoid.derive_season(season['id']), show, season, nfo_settings)]\n-def _compile_season_tasks(videoid, show, season):\n+def _compile_season_tasks(videoid, show, season, nfo_settings):\n\"\"\"Compile a list of task items for all episodes in a season\"\"\"\nreturn [_create_episode_task(videoid.derive_episode(episode['id']),\n- episode, season, show)\n+ episode, season, show, nfo_settings)\nfor episode in season['episodes']]\n-def _create_episode_task(videoid, episode, season, show):\n+def _create_episode_task(videoid, episode, season, show, nfo_settings):\n\"\"\"Export a single episode to the library\"\"\"\nfilename = 'S{:02d}E{:02d}'.format(season['seq'], episode['seq'])\ntitle = ' - '.join((show['title'], filename, episode['title']))\nreturn _create_item_task(title, FOLDER_TV, videoid, show['title'],\n- filename)\n+ filename,\n+ nfo.create_episode_nfo(episode, season, show)\n+ if nfo_settings and nfo_settings.export_tvshow_enabled else None)\n-def _create_item_task(title, section, videoid, destination, filename):\n+def _create_item_task(title, section, videoid, destination, filename, nfo_data=None, is_strm=True):\n\"\"\"Create a single task item\"\"\"\nreturn {\n'title': title,\n'section': section,\n'videoid': videoid,\n'destination': re.sub(ILLEGAL_CHARACTERS, '', destination),\n- 'filename': re.sub(ILLEGAL_CHARACTERS, '', filename)\n+ 'filename': re.sub(ILLEGAL_CHARACTERS, '', filename),\n+ 'nfo_data': nfo_data,\n+ 'is_strm': is_strm\n}\n@@ -247,11 +273,16 @@ def export_item(item_task, library_home):\n# Paths must be legal to ensure NFS compatibility\ndestination_folder = xbmc.makeLegalFilename(os.path.join(\nlibrary_home, item_task['section'], item_task['destination']))\n+ _create_destination_folder(destination_folder)\n+ if item_task['is_strm']:\nexport_filename = xbmc.makeLegalFilename(os.path.join(\ndestination_folder.decode('utf-8'), item_task['filename'] + '.strm'))\n_add_to_library(item_task['videoid'], export_filename)\n- _create_destination_folder(destination_folder)\n_write_strm_file(item_task, export_filename)\n+ if item_task['nfo_data'] is not None:\n+ nfo_filename = xbmc.makeLegalFilename(os.path.join(\n+ destination_folder.decode('utf-8'), item_task['filename'] + '.nfo'))\n+ _write_nfo_file(item_task['nfo_data'], nfo_filename)\ncommon.debug('Exported {}'.format(item_task['title']))\n@@ -272,6 +303,16 @@ def _write_strm_file(item_task, export_filename):\nfilehandle.close()\n+def _write_nfo_file(nfo_data, nfo_filename):\n+ \"\"\"Write the NFO file\"\"\"\n+ filehandle = xbmcvfs.File(xbmc.translatePath(nfo_filename), 'w')\n+ try:\n+ filehandle.write('<?xml version=\\'1.0\\' encoding=\\'UTF-8\\'?>'.encode('utf-8'))\n+ filehandle.write(ET.tostring(nfo_data, encoding='utf-8', method='xml'))\n+ finally:\n+ filehandle.close()\n+\n+\ndef _add_to_library(videoid, export_filename):\n\"\"\"Add an exported file to the library\"\"\"\nlibrary_node = g.library()\n@@ -291,6 +332,7 @@ def _add_to_library(videoid, export_filename):\ndef remove_item(item_task, library_home=None):\n\"\"\"Remove an item from the library and delete if from disk\"\"\"\n# pylint: disable=unused-argument, broad-except\n+ if item_task['is_strm']: # We don't take care of a tvshow.nfo task if we are running an update\ncommon.debug('Removing {} from library'.format(item_task['title']))\nif not is_in_library(item_task['videoid']):\ncommon.warn('cannot remove {}, item not in library'\n@@ -302,9 +344,21 @@ def remove_item(item_task, library_home=None):\nparent_folder = os.path.dirname(exported_filename)\ntry:\nxbmcvfs.delete(xbmc.translatePath(exported_filename).decode(\"utf-8\"))\n- # Fix parent folder not removed\n+ # Remove the NFO files if exists\n+ nfo_file = os.path.splitext(xbmc.translatePath(exported_filename).decode(\"utf-8\"))[0]+'.nfo'\n+ if xbmcvfs.exists(nfo_file):\n+ xbmcvfs.delete(nfo_file)\ndirs, files = xbmcvfs.listdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\n- if not dirs and not files: # the destination folder is empty\n+ tvshow_nfo_file = xbmc.makeLegalFilename(\n+ os.path.join(\n+ xbmc.translatePath(parent_folder).decode(\"utf-8\"), 'tvshow.nfo'))\n+ # Remove tvshow_nfo_file only when is the last file (users have the option of removing even single seasons)\n+ if xbmcvfs.exists(tvshow_nfo_file) and not dirs and len(files) == 1:\n+ xbmcvfs.delete(tvshow_nfo_file)\n+ # Delete parent folder\n+ xbmcvfs.rmdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\n+ # Delete parent folder when empty\n+ if not dirs and not files:\nxbmcvfs.rmdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\nexcept Exception:\ncommon.debug('Cannot delete {}, file does not exist'\n@@ -345,10 +399,10 @@ def update_library():\n@update_kodi_library\n-def execute_library_tasks(videoid, task_handler, title, sync_mylist=True):\n+def execute_library_tasks(videoid, task_handler, title, sync_mylist=True, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and show errors in foreground\"\"\"\ncommon.execute_tasks(title=title,\n- tasks=compile_tasks(videoid),\n+ tasks=compile_tasks(videoid, nfo_settings),\ntask_handler=task_handler,\nnotify_errors=True,\nlibrary_home=library_path())\n@@ -356,10 +410,10 @@ def execute_library_tasks(videoid, task_handler, title, sync_mylist=True):\n@update_kodi_library\n-def execute_library_tasks_silently(videoid, task_handler, sync_mylist):\n+def execute_library_tasks_silently(videoid, task_handler, sync_mylist, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and don't show any GUI feedback\"\"\"\n# pylint: disable=broad-except\n- for task in compile_tasks(videoid):\n+ for task in compile_tasks(videoid, nfo_settings):\ntry:\ntask_handler(task, library_path())\nexcept Exception:\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/kodi/nfo.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Functions for Kodi library NFO creation\"\"\"\n+\n+from resources.lib.globals import g\n+import resources.lib.common as common\n+import resources.lib.kodi.ui as ui\n+\n+import xml.etree.ElementTree as ET\n+\n+\n+class NFOSettings:\n+ def __init__(self):\n+ self._enabled = g.ADDON.getSettingBool('enable_nfo_export')\n+ self._export_movie_id = g.ADDON.getSettingInt('export_movie_nfo')\n+ self._export_tvshow_id = g.ADDON.getSettingInt('export_tvshow_nfo')\n+ self._export_full_tvshow = g.ADDON.getSettingBool('export_full_tvshow_nfo')\n+\n+ @property\n+ def export_enabled(self):\n+ \"\"\"Return True if NFO Export is enabled\"\"\"\n+ return self._enabled\n+\n+ @property\n+ def export_movie_enabled(self):\n+ \"\"\"Return True if Movie NFO Export is enabled (also depends on the export dialog)\"\"\"\n+ return self._enabled and self._export_movie_id != 0\n+\n+ @property\n+ def export_tvshow_enabled(self):\n+ \"\"\"Return True if TvShow NFO Export is enabled (also depends on the export dialog)\"\"\"\n+ return self._enabled and self._export_tvshow_id != 0\n+\n+ @property\n+ def export_full_tvshow(self):\n+ \"\"\"Return True if full NFO must be exported (also depends on the export dialog)\n+ i.e. create tvshow.nfo\n+ The file tvshow.nfo should be exported only when 'Local Information' scraper is used,\n+ if it is exported while using other scrapers (like TMDB),\n+ they will not get the full information for the tv show from the internet database\"\"\"\n+ return self._enabled and self._export_full_tvshow and self.export_tvshow_enabled\n+\n+ @property\n+ def movie_prompt_dialog(self):\n+ \"\"\"Ask to user when export Movie NFO\"\"\"\n+ return self._enabled and self._export_movie_id == 2\n+\n+ @property\n+ def tvshow_prompt_dialog(self):\n+ \"\"\"Ask to user when export TvShow NFO\"\"\"\n+ return self._enabled and self._export_tvshow_id == 2\n+\n+ def show_export_dialog(self, mediatype=None, dialog_message=common.get_local_string(30283)):\n+ \"\"\"Ask the user if he wants to export NFO for movies and/or tvshows, this override the default settings\"\"\"\n+ if not self.export_enabled or (not self.movie_prompt_dialog and not self.tvshow_prompt_dialog):\n+ return\n+ ask_message_typelist = []\n+ if mediatype == common.VideoId.MOVIE and self.movie_prompt_dialog:\n+ ask_message_typelist.append(common.get_local_string(30289))\n+ if mediatype in common.VideoId.TV_TYPES and self.tvshow_prompt_dialog:\n+ ask_message_typelist.append(common.get_local_string(30290))\n+ if not mediatype:\n+ # If 'None' a massive export has been requested (i.e. first library sync, manual sync, my list auto-sync...)\n+ if self.movie_prompt_dialog:\n+ ask_message_typelist.append(common.get_local_string(30289))\n+ if self.tvshow_prompt_dialog:\n+ ask_message_typelist.append(common.get_local_string(30290))\n+ if ask_message_typelist:\n+ message = ' {} '.format(common.get_local_string(1397)).join(ask_message_typelist)\n+ message = dialog_message.format(message) + common.get_local_string(30292)\n+ user_choice = ui.ask_for_confirmation(common.get_local_string(30282), message)\n+ if len(ask_message_typelist) == 2 and not user_choice:\n+ self._export_movie_id = 0\n+ self._export_tvshow_id = 0\n+ elif common.get_local_string(30289) in ask_message_typelist and not user_choice:\n+ self._export_movie_id = 0\n+ elif common.get_local_string(30290) in ask_message_typelist and not user_choice:\n+ self._export_tvshow_id = 0\n+\n+\n+def create_episode_nfo(episode, season, show):\n+ \"\"\"Build NFO file for episode\"\"\"\n+ tags = {\n+ 'title': episode.get('title'),\n+ 'showtitle': show.get('title'),\n+ 'season': season.get('seq'),\n+ 'episode': episode.get('seq'),\n+ 'plot': episode.get('synopsis'),\n+ 'runtime': episode.get('runtime', 0)/60,\n+ 'year': season.get('year'),\n+ 'id': episode.get('id')\n+ }\n+\n+ root = _build_root_node('episodedetails', tags)\n+ _add_episode_thumb(root, episode)\n+ return root\n+\n+\n+def create_show_nfo(show):\n+ \"\"\"Build NFO file for TV Show\"\"\"\n+ tags = {\n+ 'title': show['title'],\n+ 'showtitle': show['title'],\n+ 'plot': show.get('synopsis'),\n+ 'id': show['id'],\n+ 'mpaa': show.get('rating')\n+ }\n+ root = _build_root_node('tvshow', tags)\n+ _add_poster(root, show)\n+ _add_fanart(root, show)\n+ return root\n+\n+\n+def create_movie_nfo(movie):\n+ tags = {\n+ 'title': movie.get('title'),\n+ 'plot': movie.get('synopsis'),\n+ 'id': movie.get('id'),\n+ 'mpaa': movie.get('rating'),\n+ 'year': movie.get('year'),\n+ 'runtime': movie.get('runtime', 0)/60,\n+ }\n+ root = _build_root_node('movie', tags)\n+ _add_poster(root, movie)\n+ _add_fanart(root, movie)\n+ common.debug(root)\n+ return root\n+\n+\n+def _add_episode_thumb(root, episode):\n+ if episode.get('thumbs') and len(episode['thumbs']) > 0:\n+ for thumb in episode['thumbs']:\n+ url = thumb['url']\n+ thumbnail = ET.SubElement(root, 'thumb')\n+ thumbnail.text = url\n+\n+\n+def _add_poster(root, data):\n+ if data.get('boxart') and len(data['boxart']) > 0:\n+ for boxart in data['boxart']:\n+ url = boxart['url']\n+ poster = ET.SubElement(root, 'thumb', {'aspect': 'poster'})\n+ poster.text = url\n+\n+\n+def _add_fanart(root, data):\n+ if data.get('storyart') and len(data['storyart']) > 0:\n+ for storyart in data['storyart']:\n+ url = storyart['url']\n+ fanart = ET.SubElement(root, 'fanart')\n+ thumb = ET.SubElement(fanart, 'thumb')\n+ thumb.text = url\n+\n+\n+def _build_root_node(root_name, tags):\n+ root = ET.Element(root_name)\n+ for (k, v) in tags.items():\n+ if v:\n+ tag = ET.SubElement(root, k)\n+ tag.text = unicode(v)\n+ return root\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -8,6 +8,7 @@ import resources.lib.common as common\nimport resources.lib.api.shakti as api\nimport resources.lib.kodi.ui as ui\nimport resources.lib.kodi.library as library\n+import resources.lib.kodi.nfo as nfo\nclass LibraryActionExecutor(object):\n@@ -21,33 +22,46 @@ class LibraryActionExecutor(object):\[email protected]_video_id(path_offset=1)\ndef export(self, videoid):\n\"\"\"Export an item to the Kodi library\"\"\"\n- library.execute_library_tasks(videoid, library.export_item,\n- common.get_local_string(30018))\n+ nfo_settings = nfo.NFOSettings()\n+ nfo_settings.show_export_dialog(videoid.mediatype)\n+ library.execute_library_tasks(videoid,\n+ library.export_item,\n+ common.get_local_string(30018),\n+ nfo_settings=nfo_settings)\[email protected]_video_id(path_offset=1)\ndef remove(self, videoid):\n\"\"\"Remove an item from the Kodi library\"\"\"\nif ui.ask_for_removal_confirmation():\n- library.execute_library_tasks(videoid, library.remove_item,\n+ library.execute_library_tasks(videoid,\n+ library.remove_item,\ncommon.get_local_string(30030))\ncommon.refresh_container()\[email protected]_video_id(path_offset=1)\ndef update(self, videoid):\n\"\"\"Update an item in the Kodi library\"\"\"\n- library.execute_library_tasks(videoid, library.update_item,\n- common.get_local_string(30061))\n+ nfo_settings = nfo.NFOSettings()\n+ nfo_settings.show_export_dialog(videoid.mediatype)\n+ library.execute_library_tasks(videoid,\n+ library.update_item,\n+ common.get_local_string(30061),\n+ nfo_settings=nfo_settings)\ncommon.refresh_container()\[email protected]_video_id(path_offset=1)\ndef export_silent(self, videoid):\n\"\"\"Silently export an item to the Kodi library\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+ list and Kodi library and do no sync, if not explicitly asked to.\n+ Will only ask for NFO export based on user settings\"\"\"\n# pylint: disable=broad-except\n+ nfo_settings = nfo.NFOSettings()\n+ nfo_settings.show_export_dialog(videoid.mediatype, common.get_local_string(30291))\nlibrary.execute_library_tasks_silently(\nvideoid, library.export_item,\n- self.params.get('sync_mylist', False))\n+ self.params.get('sync_mylist', False),\n+ nfo_settings)\[email protected]_video_id(path_offset=1)\ndef remove_silent(self, videoid):\n@@ -58,14 +72,15 @@ class LibraryActionExecutor(object):\nvideoid, library.remove_item,\nself.params.get('sync_mylist', False))\n- @common.inject_video_id(path_offset=1)\n- def update_silent(self, videoid):\n- \"\"\"Silently update an item in the Kodi library\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.update_item,\n- self.params.get('sync_mylist', False))\n+ # Not used for now\n+ # @common.inject_video_id(path_offset=1)\n+ # def update_silent(self, videoid):\n+ # \"\"\"Silently update an item in the Kodi library\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.update_item,\n+ # self.params.get('sync_mylist', False))\ndef initial_mylist_sync(self, pathitems):\n\"\"\"Perform an initial sync of My List and the Kodi library\"\"\"\n@@ -74,14 +89,16 @@ class LibraryActionExecutor(object):\ncommon.get_local_string(30123))\nif not do_it or not g.ADDON.getSettingBool('mylist_library_sync'):\nreturn\n-\ncommon.debug('Performing full sync from My List to Kodi library')\nlibrary.purge()\n+ nfo_settings = nfo.NFOSettings()\n+ nfo_settings.show_export_dialog()\nfor videoid in api.video_list(\napi.list_id_for_type('queue')).videoids:\nlibrary.execute_library_tasks(videoid, library.export_item,\ncommon.get_local_string(30018),\n- sync_mylist=False)\n+ sync_mylist=False,\n+ nfo_settings=nfo_settings)\ndef purge(self, pathitems):\n\"\"\"Delete all previously exported items from the Kodi library\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<settings>\n- <category label=\"30014\">\n+ <category label=\"30014\"><!--Account-->\n<setting id=\"email\" type=\"text\" visible=\"false\" default=\"\"/>\n<setting id=\"password\" type=\"text\" visible=\"false\" default=\"\"/>\n<setting id=\"logout\" type=\"action\" label=\"30017\" action=\"RunPlugin(plugin://plugin.video.netflix/action/logout/)\" option=\"close\"/>\n<setting type=\"sep\"/>\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n</category>\n- <category label=\"30025\">\n+ <category label=\"30025\"><!--Library-->\n<setting id=\"enablelibraryfolder\" type=\"bool\" label=\"30026\" default=\"false\"/>\n<setting id=\"customlibraryfolder\" type=\"folder\" label=\"30027\" enable=\"eq(-1,true)\" default=\"special://profile/addon_data/plugin.video.netflix\" source=\"auto\" option=\"writeable\" subsetting=\"true\"/>\n<setting id=\"mylist_library_sync\" type=\"bool\" label=\"30114\" default=\"false\"/>\n<setting id=\"migrate_library\" type=\"action\" label=\"30140\" action=\"RunPlugin(plugin://plugin.video.netflix/library/migrate/)\"/>\n<setting id=\"customexportname\" type=\"bool\" label=\"No longer in use\" default=\"true\" visible=\"false\"/>\n<setting id=\"invalidate_cache_on_mylist_modify\" type=\"bool\" label=\"No longer in use\" default=\"true\" visible=\"false\"/>\n- <setting label=\"30065\" type=\"lsep\"/>\n+ <setting label=\"30065\" type=\"lsep\"/><!--Auto-Update-->\n<setting id=\"auto_update\" type=\"enum\" label=\"30064\" lvalues=\"30066|30067|30068|30069|30070\" default=\"0\"/>\n<setting id=\"update_time\" type=\"time\" label=\"30071\" visible=\"gt(-1,0)\" default=\"00:00\" subsetting=\"true\"/>\n<setting id=\"wait_idle\" type=\"bool\" label=\"30072\" visible=\"gt(-2,0)\" default=\"false\" subsetting=\"true\"/>\n<setting id=\"schedule_check_interval\" type=\"slider\" label=\"30073\" option=\"int\" range=\"1,30\" visible=\"gt(-3,0)\" default=\"5\" subsetting=\"true\"/>\n<setting id=\"last_update\" type=\"text\" visible=\"false\" default=\"1970-01-01\"/>\n<setting id=\"update_running\" type=\"text\" visible=\"false\" default=\"false\"/>\n+ <setting label=\"30284\" type=\"lsep\"/><!--NFO Files-->\n+ <setting id=\"enable_nfo_export\" type=\"bool\" label=\"30285\" default=\"false\"/>\n+ <setting id=\"export_movie_nfo\" type=\"enum\" label=\"30286\" lvalues=\"21337|20422|30288\" enable=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_tvshow_nfo\" type=\"enum\" label=\"30287\" lvalues=\"21337|20422|30288\" enable=\"eq(-2,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_full_tvshow_nfo\" type=\"bool\" label=\"30293\" enable=\"eq(-3,true)\" default=\"false\" subsetting=\"true\"/>\n</category>\n- <category label=\"30166\">\n+ <category label=\"30166\"><!--Main menu items-->\n<setting id=\"show_menu_mylist\" type=\"bool\" label=\"30167\" default=\"true\"/>\n<setting id=\"menu_sortorder_mylist\" type=\"select\" label=\"30149\" lvalues=\"30150|30151|30152|30153\" visible=\"false\" subsetting=\"true\" default=\"0\"/> <!-- is currently (05-05-2019) no longer supported by the netflix server-->\n<setting id=\"show_menu_continuewatching\" type=\"bool\" label=\"30168\" default=\"true\"/>\n<setting id=\"show_menu_search\" type=\"bool\" label=\"30011\" default=\"true\"/>\n<setting id=\"show_menu_exported\" type=\"bool\" label=\"30048\" default=\"true\"/>\n</category>\n- <category label=\"30037\">\n+ <category label=\"30037\"><!--Views-->\n<setting id=\"customview\" type=\"bool\" label=\"30038\" default=\"false\"/>\n<setting id=\"viewmodeprofiles\" type=\"select\" label=\"30044\" lvalues=\"30162|30142\" default=\"0\" enable=\"eq(-1,true)\"/>\n<setting id=\"viewmodeprofilesid\" type=\"number\" label=\"30143\" visible=\"eq(-1,1) + eq(-2,true)\" enable=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting id=\"viewmodeexported\" type=\"select\" label=\"30161\" lvalues=\"30162|30142\" default=\"0\" enable=\"eq(-19,true)\"/>\n<setting id=\"viewmodeexportedid\" type=\"number\" label=\"30143\" visible=\"eq(-1,1) + eq(-20,true)\" enable=\"eq(-20,true)\" subsetting=\"true\"/>\n</category>\n- <category label=\"30078\">\n+ <category label=\"30078\"><!--Playback-->\n<setting id=\"BookmarkManager_enabled\" type=\"bool\" label=\"30083\" visible=\"false\" default=\"true\"/>\n<setting id=\"StreamContinuityManager_enabled\" type=\"bool\" label=\"30082\" default=\"true\"/>\n<setting id=\"SectionSkipper_enabled\" type=\"bool\" label=\"30075\" default=\"true\"/>\n<setting id=\"ResumeManager_dialog\" type=\"bool\" label=\"30177\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"forced_subtitle_workaround\" type=\"bool\" label=\"30181\" default=\"true\" />\n</category>\n- <category label=\"30023\">\n+ <category label=\"30023\"><!--Expert-->\n<setting label=\"30115\" type=\"lsep\"/>\n<setting id=\"enable_1080p_unlock\" type=\"bool\" label=\"30136\" default=\"false\" visible=\"false\"/> <!-- Deprecated (broken) -->\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented NFO Export Co-authored-by: Stefano Gottardo <[email protected]>
105,991
24.06.2019 03:01:09
-7,200
c4cb319592f187ee4803c45241234a25d36aed02
Fix export path os.path.join under windows uses a '\' to join, but it can break the names if they contains special characters as '%' Using '/' for join fixes the issue, and xbmc.makeLegalFilename will translate '/' to '\' for pure windows folders
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -275,13 +275,13 @@ def export_item(item_task, library_home):\nlibrary_home, item_task['section'], item_task['destination']))\n_create_destination_folder(destination_folder)\nif item_task['is_strm']:\n- export_filename = xbmc.makeLegalFilename(os.path.join(\n- destination_folder.decode('utf-8'), item_task['filename'] + '.strm'))\n+ export_filename = xbmc.makeLegalFilename('/'.join(\n+ [destination_folder.decode('utf-8'), item_task['filename'] + '.strm']))\n_add_to_library(item_task['videoid'], export_filename)\n_write_strm_file(item_task, export_filename)\nif item_task['nfo_data'] is not None:\n- nfo_filename = xbmc.makeLegalFilename(os.path.join(\n- destination_folder.decode('utf-8'), item_task['filename'] + '.nfo'))\n+ nfo_filename = xbmc.makeLegalFilename('/'.join(\n+ [destination_folder.decode('utf-8'), item_task['filename'] + '.nfo']))\n_write_nfo_file(item_task['nfo_data'], nfo_filename)\ncommon.debug('Exported {}'.format(item_task['title']))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix export path os.path.join under windows uses a '\' to join, but it can break the names if they contains special characters as '%' Using '/' for join fixes the issue, and xbmc.makeLegalFilename will translate '/' to '\' for pure windows folders
105,991
25.06.2019 21:54:08
-7,200
8ac6391b89e413811500936e80c7c2e30b547705
Renumbering of NFO strings
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -744,50 +744,50 @@ msgctxt \"#30181\"\nmsgid \"Disable subtitles if there are no forced subtitles streams (Works only if Kodi Player is set to \\\"Only forced\\\" subtitles)\"\nmsgstr \"\"\n-msgctxt \"#30282\"\n+msgctxt \"#30182\"\nmsgid \"Export NFO files\"\nmsgstr \"\"\n-msgctxt \"#30283\"\n+msgctxt \"#30183\"\nmsgid \"Do you want to export NFO files for the {}?\"\nmsgstr \"\"\n-msgctxt \"#30284\"\n+msgctxt \"#30184\"\nmsgid \"NFO Files\"\nmsgstr \"\"\n-msgctxt \"#30285\"\n+msgctxt \"#30185\"\nmsgid \"Enable NFO files export\"\nmsgstr \"\"\n-msgctxt \"#30286\"\n+msgctxt \"#30186\"\nmsgid \"For Movies\"\nmsgstr \"\"\n-msgctxt \"#30287\"\n+msgctxt \"#30187\"\nmsgid \"For TV Show\"\nmsgstr \"\"\n-msgctxt \"#30288\"\n+msgctxt \"#30188\"\nmsgid \"Ask\"\nmsgstr \"\"\n-msgctxt \"#30289\"\n+msgctxt \"#30189\"\nmsgid \"movie\"\nmsgstr \"\"\n-msgctxt \"#30290\"\n+msgctxt \"#30190\"\nmsgid \"TV show\"\nmsgstr \"\"\n-msgctxt \"#30291\"\n+msgctxt \"#30191\"\nmsgid \"Do you want to export NFO files for the {} added to 'My List'?\"\nmsgstr \"\"\n-msgctxt \"#30292\"\n+msgctxt \"#30192\"\nmsgid \"\\r\\nThese files are used by the provider information scrapers to integrate movies and tv shows info, useful with bonus episodes or director's cut\"\nmsgstr \"\"\n-msgctxt \"#30293\"\n+msgctxt \"#30193\"\nmsgid \"Include all information in NFO files (use only with 'Local Information' scraper)\"\nmsgstr \"\"\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": "@@ -744,50 +744,50 @@ msgctxt \"#30181\"\nmsgid \"Disable subtitles if there are no forced subtitles streams (Works only if Kodi Player is set to \\\"Only forced\\\" subtitles)\"\nmsgstr \"Disabilita i sottotitoli quando non ci sono tracce forzate (Funziona se il Player Kodi viene impostato con sottotitoli \\\"Solo forzati\\\")\"\n-msgctxt \"#30282\"\n+msgctxt \"#30182\"\nmsgid \"Export NFO files\"\nmsgstr \"Esportazione file NFO\"\n-msgctxt \"#30283\"\n+msgctxt \"#30183\"\nmsgid \"Do you want to export NFO files for the {}?\"\nmsgstr \"Vuoi esportare i file NFO per {}?\"\n-msgctxt \"#30284\"\n+msgctxt \"#30184\"\nmsgid \"NFO Files\"\nmsgstr \"File NFO\"\n-msgctxt \"#30285\"\n+msgctxt \"#30185\"\nmsgid \"Enable NFO files export\"\nmsgstr \"Abilita l'esportazione dei file NFO\"\n-msgctxt \"#30286\"\n+msgctxt \"#30186\"\nmsgid \"For Movies\"\nmsgstr \"Per i film\"\n-msgctxt \"#30287\"\n+msgctxt \"#30187\"\nmsgid \"For TV Show\"\nmsgstr \"Per le Serie TV\"\n-msgctxt \"#30288\"\n+msgctxt \"#30188\"\nmsgid \"Ask\"\nmsgstr \"Chiedi\"\n-msgctxt \"#30289\"\n+msgctxt \"#30189\"\nmsgid \"movie\"\nmsgstr \"film\"\n-msgctxt \"#30290\"\n+msgctxt \"#30190\"\nmsgid \"TV show\"\nmsgstr \"serie tv\"\n-msgctxt \"#30291\"\n+msgctxt \"#30191\"\nmsgid \"Do you want to export NFO files for the {} added to 'My List'?\"\nmsgstr \"Vuoi esportare i file NFO per {} aggiunti alla 'Mia lista'?\"\n-msgctxt \"#30292\"\n+msgctxt \"#30192\"\nmsgid \"\\r\\nThese files are used by the provider information scrapers to integrate movies and tv shows info, useful with bonus episodes or director's cut\"\nmsgstr \"\\r\\nQuesti file sono utilizzati dai provider informazioni scrapers per integrare info dei film e serie tv, utili per episodi bonus o director's cut\"\n-msgctxt \"#30293\"\n+msgctxt \"#30193\"\nmsgid \"Include all information in NFO files (use only with 'Local Information' scraper)\"\nmsgstr \"Includi tutte le informazioni nei file NFO (usare solo con scraper 'Local Information')\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/nfo.py", "new_path": "resources/lib/kodi/nfo.py", "diff": "@@ -49,31 +49,31 @@ class NFOSettings:\n\"\"\"Ask to user when export TvShow NFO\"\"\"\nreturn self._enabled and self._export_tvshow_id == 2\n- def show_export_dialog(self, mediatype=None, dialog_message=common.get_local_string(30283)):\n+ def show_export_dialog(self, mediatype=None, dialog_message=common.get_local_string(30183)):\n\"\"\"Ask the user if he wants to export NFO for movies and/or tvshows, this override the default settings\"\"\"\nif not self.export_enabled or (not self.movie_prompt_dialog and not self.tvshow_prompt_dialog):\nreturn\nask_message_typelist = []\nif mediatype == common.VideoId.MOVIE and self.movie_prompt_dialog:\n- ask_message_typelist.append(common.get_local_string(30289))\n+ ask_message_typelist.append(common.get_local_string(30189))\nif mediatype in common.VideoId.TV_TYPES and self.tvshow_prompt_dialog:\n- ask_message_typelist.append(common.get_local_string(30290))\n+ ask_message_typelist.append(common.get_local_string(30190))\nif not mediatype:\n# If 'None' a massive export has been requested (i.e. first library sync, manual sync, my list auto-sync...)\nif self.movie_prompt_dialog:\n- ask_message_typelist.append(common.get_local_string(30289))\n+ ask_message_typelist.append(common.get_local_string(30189))\nif self.tvshow_prompt_dialog:\n- ask_message_typelist.append(common.get_local_string(30290))\n+ ask_message_typelist.append(common.get_local_string(30190))\nif ask_message_typelist:\nmessage = ' {} '.format(common.get_local_string(1397)).join(ask_message_typelist)\n- message = dialog_message.format(message) + common.get_local_string(30292)\n- user_choice = ui.ask_for_confirmation(common.get_local_string(30282), message)\n+ message = dialog_message.format(message) + common.get_local_string(30192)\n+ user_choice = ui.ask_for_confirmation(common.get_local_string(30182), message)\nif len(ask_message_typelist) == 2 and not user_choice:\nself._export_movie_id = 0\nself._export_tvshow_id = 0\n- elif common.get_local_string(30289) in ask_message_typelist and not user_choice:\n+ elif common.get_local_string(30189) in ask_message_typelist and not user_choice:\nself._export_movie_id = 0\n- elif common.get_local_string(30290) in ask_message_typelist and not user_choice:\n+ elif common.get_local_string(30190) in ask_message_typelist and not user_choice:\nself._export_tvshow_id = 0\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -57,7 +57,7 @@ class LibraryActionExecutor(object):\nWill only ask for NFO export based on user settings\"\"\"\n# pylint: disable=broad-except\nnfo_settings = nfo.NFOSettings()\n- nfo_settings.show_export_dialog(videoid.mediatype, common.get_local_string(30291))\n+ nfo_settings.show_export_dialog(videoid.mediatype, common.get_local_string(30191))\nlibrary.execute_library_tasks_silently(\nvideoid, library.export_item,\nself.params.get('sync_mylist', False),\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"schedule_check_interval\" type=\"slider\" label=\"30073\" option=\"int\" range=\"1,30\" visible=\"gt(-3,0)\" default=\"5\" subsetting=\"true\"/>\n<setting id=\"last_update\" type=\"text\" visible=\"false\" default=\"1970-01-01\"/>\n<setting id=\"update_running\" type=\"text\" visible=\"false\" default=\"false\"/>\n- <setting label=\"30284\" type=\"lsep\"/><!--NFO Files-->\n- <setting id=\"enable_nfo_export\" type=\"bool\" label=\"30285\" default=\"false\"/>\n- <setting id=\"export_movie_nfo\" type=\"enum\" label=\"30286\" lvalues=\"21337|20422|30288\" enable=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n- <setting id=\"export_tvshow_nfo\" type=\"enum\" label=\"30287\" lvalues=\"21337|20422|30288\" enable=\"eq(-2,true)\" default=\"1\" subsetting=\"true\"/>\n- <setting id=\"export_full_tvshow_nfo\" type=\"bool\" label=\"30293\" enable=\"eq(-3,true)\" default=\"false\" 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\" enable=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_tvshow_nfo\" type=\"enum\" label=\"30187\" lvalues=\"21337|20422|30188\" enable=\"eq(-2,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_full_tvshow_nfo\" type=\"bool\" label=\"30193\" enable=\"eq(-3,true)\" default=\"false\" subsetting=\"true\"/>\n</category>\n<category label=\"30166\"><!--Main menu items-->\n<setting id=\"show_menu_mylist\" type=\"bool\" label=\"30167\" default=\"true\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Renumbering of NFO strings
106,046
26.06.2019 21:09:22
-7,200
388fd74b82dd5439271afc947cd6bb465bb22e56
Cleanup get chunked response
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -241,9 +241,9 @@ class MSLHandler(object):\[email protected]_execution(immediate=True)\ndef _chunked_request(self, endpoint, request_data, esn):\n\"\"\"Do a POST request and process the chunked response\"\"\"\n- return self._process_chunked_response(\n- self._post(endpoint,\n- self.request_builder.msl_request(request_data, esn)))\n+ chunked_response = self._process_chunked_response(\n+ self._post(endpoint, self.request_builder.msl_request(request_data, esn)))\n+ return chunked_response['result']\[email protected]_execution(immediate=True)\ndef _post(self, endpoint, request_data):\n@@ -284,14 +284,10 @@ def _process_json_response(response):\ndef _raise_if_error(decoded_response):\n- common.debug('decoded_response: ' + str(decoded_response))\n- if 'errordata' in decoded_response:\n+ if ('error' or 'errordata') in decoded_response:\ncommon.error('Full MSL error information:')\ncommon.error(json.dumps(decoded_response))\nraise MSLError(_get_error_details(decoded_response))\n- if isinstance(decoded_response, list):\n- if decoded_response[0].get('error'):\n- raise MSLError(_get_error_details(decoded_response[0]))\nreturn decoded_response\n@@ -300,11 +296,8 @@ def _get_error_details(decoded_response):\nreturn json.loads(\nbase64.standard_b64decode(\ndecoded_response['errordata']))['errormsg']\n- elif decoded_response.get('result', {}).get('errorDisplayMessage'):\n- return decoded_response['result']['errorDisplayMessage']\n- elif decoded_response.get('result', {}).get('errorDetails'):\n- return decoded_response['result']['errorDetails']\n- elif decoded_response.get('error', {}).get('errorDisplayMessage'):\n+ if 'error' in decoded_response:\n+ if decoded_response['error'].get('errorDisplayMessage'):\nreturn decoded_response['error']['errorDisplayMessage']\nreturn 'Unhandled error check log.'\n@@ -346,16 +339,7 @@ def _decrypt_chunks(chunks, crypto):\nelse:\ndecrypted_payload += data\n- decrypted_payload = json.loads(decrypted_payload)\n- if 'result' in decrypted_payload:\n- return decrypted_payload['result']\n-\n- decrypted_payload = decrypted_payload[1]['payload']\n- if 'json' in decrypted_payload:\n- return decrypted_payload['json']['result']\n- else:\n- decrypted_payload = base64.standard_b64decode(decrypted_payload['data'])\n- return json.JSONDecoder().decode(decrypted_payload)\n+ return json.loads(decrypted_payload)\ndef has_1080p(manifest):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Cleanup get chunked response
106,046
29.06.2019 17:10:48
-7,200
3287f4a92c0cd6b306cd9d19aecb4a94c1d8c05e
Version bump (14.6)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.5\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.6\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.14.6 (2019-06-29)\n+-Improved Library Management that include:\n+-Fixed TvShow not removed from library\n+-Scan with faster processing with large library\n+-Fixed TvShow directory not deleted when a TvShow was removed from library\n+-Fixed STRM filename to be fully compatible with NFS from Windows\n+-Faster database fetching through API using filters\n+-Fixed progress bar while exporting/removing items to library\n+-Other improvements:\n+-Implemented exporting of NFO files for the scrapers\n+-Fixed return to main menu after a research\n+-Fixed workaround 'forced only subtitle', now works also on slow systems\n+-Updated French, Italian, Polish languages\n+-Other small fixes\n+\nv0.14.5 (2019-06-19)\n-Fixed Login error due to Netflix API changes\n-Fixed return to main menu after a research\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (14.6)
106,046
29.06.2019 17:48:28
-7,200
e832d6f1911ac1545a57a3824bc523d5c3317882
Dropout UniversalAnalytics we no need to measure users activity with google analytics
[ { "change_type": "MODIFY", "old_path": ".codeclimate.yml", "new_path": ".codeclimate.yml", "diff": "@@ -19,7 +19,6 @@ ratings:\nexclude_paths:\n- \"docs\"\n- \"resources/test/\"\n- - \"resources/lib/UniversalAnalytics/\"\n- \"resources/language/\"\n- \"resources/media/\"\n- \"resources/skins/\"\n" }, { "change_type": "MODIFY", "old_path": "makefile", "new_path": "makefile", "diff": "@@ -39,8 +39,8 @@ clean-coverage:\nlint:\nflake8 --filename=$(FLAKE_FILES)\n- pylint $(PYLINT_FILES) --ignore=test,UniversalAnalytics || exit 0\n- pylint $(PYLINT_FILES) --ignore=test,UniversalAnalytics --output-format=html > $(LINT_REPORT_FILE)\n+ pylint $(PYLINT_FILES) --ignore=test || exit 0\n+ pylint $(PYLINT_FILES) --ignore=test --output-format=html > $(LINT_REPORT_FILE)\nradon cc $(RADON_FILES)\ndennis-cmd lint $(I18N_FILES)\nrst-lint docs/index.rst --level=severe\n" }, { "change_type": "DELETE", "old_path": "resources/lib/UniversalAnalytics/HTTPLog.py", "new_path": null, "diff": "-#!/usr/bin/python\n-###############################################################################\n-# Formatting filter for urllib2's HTTPHandler(debuglevel=1) output\n-# Copyright (c) 2013, Analytics Pros\n-#\n-# This project is free software, distributed under the BSD license.\n-# Analytics Pros offers consulting and integration services if your firm needs\n-# assistance in strategy, implementation, or auditing existing work.\n-###############################################################################\n-\n-\n-import sys, re, os\n-from cStringIO import StringIO\n-\n-\n-\n-class BufferTranslator(object):\n- \"\"\" Provides a buffer-compatible interface for filtering buffer content.\n- \"\"\"\n- parsers = []\n-\n- def __init__(self, output):\n- self.output = output\n- self.encoding = getattr(output, 'encoding', None)\n-\n- def write(self, content):\n- content = self.translate(content)\n- self.output.write(content)\n-\n-\n- @staticmethod\n- def stripslashes(content):\n- return content.decode('string_escape')\n-\n- @staticmethod\n- def addslashes(content):\n- return content.encode('string_escape')\n-\n- def translate(self, line):\n- for pattern, method in self.parsers:\n- match = pattern.match(line)\n- if match:\n- return method(match)\n-\n- return line\n-\n-\n-\n-class LineBufferTranslator(BufferTranslator):\n- \"\"\" Line buffer implementation supports translation of line-format input\n- even when input is not already line-buffered. Caches input until newlines\n- occur, and then dispatches translated input to output buffer.\n- \"\"\"\n- def __init__(self, *a, **kw):\n- self._linepending = []\n- super(LineBufferTranslator, self).__init__(*a, **kw)\n-\n- def write(self, _input):\n- lines = _input.splitlines(True)\n- for i in range(0, len(lines)):\n- last = i\n- if lines[i].endswith('\\n'):\n- prefix = len(self._linepending) and ''.join(self._linepending) or ''\n- self.output.write(self.translate(prefix + lines[i]))\n- del self._linepending[0:]\n- last = -1\n-\n- if last >= 0:\n- self._linepending.append(lines[ last ])\n-\n-\n- def __del__(self):\n- if len(self._linepending):\n- self.output.write(self.translate(''.join(self._linepending)))\n-\n-\n-class HTTPTranslator(LineBufferTranslator):\n- \"\"\" Translates output from |urllib2| HTTPHandler(debuglevel = 1) into\n- HTTP-compatible, readible text structures for human analysis.\n- \"\"\"\n-\n- RE_LINE_PARSER = re.compile(r'^(?:([a-z]+):)\\s*(\\'?)([^\\r\\n]*)\\2(?:[\\r\\n]*)$')\n- RE_LINE_BREAK = re.compile(r'(\\r?\\n|(?:\\\\r)?\\\\n)')\n- RE_HTTP_METHOD = re.compile(r'^(POST|GET|HEAD|DELETE|PUT|TRACE|OPTIONS)')\n- RE_PARAMETER_SPACER = re.compile(r'&([a-z0-9]+)=')\n-\n- @classmethod\n- def spacer(cls, line):\n- return cls.RE_PARAMETER_SPACER.sub(r' &\\1= ', line)\n-\n- def translate(self, line):\n-\n- parsed = self.RE_LINE_PARSER.match(line)\n-\n- if parsed:\n- value = parsed.group(3)\n- stage = parsed.group(1)\n-\n- if stage == 'send': # query string is rendered here\n- return '\\n# HTTP Request:\\n' + self.stripslashes(value)\n- elif stage == 'reply':\n- return '\\n\\n# HTTP Response:\\n' + self.stripslashes(value)\n- elif stage == 'header':\n- return value + '\\n'\n- else:\n- return value\n-\n-\n- return line\n-\n-\n-def consume(outbuffer = None): # Capture standard output\n- sys.stdout = HTTPTranslator(outbuffer or sys.stdout)\n- return sys.stdout\n-\n-\n-if __name__ == '__main__':\n- consume(sys.stdout).write(sys.stdin.read())\n- print '\\n'\n-\n-# vim: set nowrap tabstop=4 shiftwidth=4 softtabstop=0 expandtab textwidth=0 filetype=python foldmethod=indent foldcolumn=4\n" }, { "change_type": "DELETE", "old_path": "resources/lib/UniversalAnalytics/LICENSE", "new_path": null, "diff": "-- BSD 3-Clause license -\n-\n-Copyright (c) 2013, Analytics Pros\n-All rights reserved.\n-\n-Redistribution and use in source and binary forms, with or without modification,\n-are permitted provided that the following conditions are met:\n-\n-* Redistributions of source code must retain the above copyright notice, this\n- list of conditions and the following disclaimer.\n-\n-* Redistributions in binary form must reproduce the above copyright notice, this\n- list of conditions and the following disclaimer in the documentation and/or\n- other materials provided with the distribution.\n-\n-* Neither the name of Analytics Pros nor the names of its contributors may be\n- used to endorse or promote products derived from this software without\n- specific prior written permission.\n-\n-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n-ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n-ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n" }, { "change_type": "DELETE", "old_path": "resources/lib/UniversalAnalytics/Tracker.py", "new_path": null, "diff": "-###############################################################################\n-# Universal Analytics for Python\n-# Copyright (c) 2013, Analytics Pros\n-#\n-# This project is free software, distributed under the BSD license.\n-# Analytics Pros offers consulting and integration services if your firm needs\n-# assistance in strategy, implementation, or auditing existing work.\n-###############################################################################\n-\n-from urllib2 import urlopen, build_opener, install_opener\n-from urllib2 import Request, HTTPSHandler\n-from urllib2 import URLError, HTTPError\n-from urllib import urlencode\n-\n-import random\n-import datetime\n-import time\n-import uuid\n-import hashlib\n-import socket\n-\n-\n-\n-def generate_uuid(basedata = None):\n- \"\"\" Provides a _random_ UUID with no input, or a UUID4-format MD5 checksum of any input data provided \"\"\"\n- if basedata is None:\n- return str(uuid.uuid4())\n- elif isinstance(basedata, basestring):\n- checksum = hashlib.md5(basedata).hexdigest()\n- return '%8s-%4s-%4s-%4s-%12s' % (checksum[0:8], checksum[8:12], checksum[12:16], checksum[16:20], checksum[20:32])\n-\n-\n-class Time(datetime.datetime):\n- \"\"\" Wrappers and convenience methods for processing various time representations \"\"\"\n-\n- @classmethod\n- def from_unix(cls, seconds, milliseconds = 0):\n- \"\"\" Produce a full |datetime.datetime| object from a Unix timestamp \"\"\"\n- base = list(time.gmtime(seconds))[0:6]\n- base.append(milliseconds * 1000) # microseconds\n- return cls(* base)\n-\n- @classmethod\n- def to_unix(cls, timestamp):\n- \"\"\" Wrapper over time module to produce Unix epoch time as a float \"\"\"\n- if not isinstance(timestamp, datetime.datetime):\n- raise TypeError, 'Time.milliseconds expects a datetime object'\n- base = time.mktime(timestamp.timetuple())\n- return base\n-\n- @classmethod\n- def milliseconds_offset(cls, timestamp, now = None):\n- \"\"\" Offset time (in milliseconds) from a |datetime.datetime| object to now \"\"\"\n- if isinstance(timestamp, (int, float)):\n- base = timestamp\n- else:\n- base = cls.to_unix(timestamp)\n- base = base + (timestamp.microsecond / 1000000)\n- if now is None:\n- now = time.time()\n- return (now - base) * 1000\n-\n-\n-\n-class HTTPRequest(object):\n- \"\"\" URL Construction and request handling abstraction.\n- This is not intended to be used outside this module.\n-\n- Automates mapping of persistent state (i.e. query parameters)\n- onto transcient datasets for each query.\n- \"\"\"\n-\n- endpoint = 'https://www.google-analytics.com/collect'\n-\n-\n- @staticmethod\n- def debug():\n- \"\"\" Activate debugging on urllib2 \"\"\"\n- handler = HTTPSHandler(debuglevel = 1)\n- opener = build_opener(handler)\n- install_opener(opener)\n-\n- # Store properties for all requests\n- def __init__(self, user_agent = None, *args, **opts):\n- self.user_agent = user_agent or 'Analytics Pros - Universal Analytics (Python)'\n-\n-\n- @classmethod\n- def fixUTF8(cls, data): # Ensure proper encoding for UA's servers...\n- \"\"\" Convert all strings to UTF-8 \"\"\"\n- for key in data:\n- if isinstance(data[ key ], basestring):\n- data[ key ] = data[ key ].encode('utf-8')\n- return data\n-\n-\n-\n- # Apply stored properties to the given dataset & POST to the configured endpoint\n- def send(self, data):\n- request = Request(\n- self.endpoint + '?' + urlencode(self.fixUTF8(data)),\n- headers = {\n- 'User-Agent': self.user_agent\n- }\n- )\n- self.open(request)\n-\n- def open(self, request):\n- try:\n- return urlopen(request)\n- except HTTPError as e:\n- return False\n- except URLError as e:\n- self.cache_request(request)\n- return False\n-\n- def cache_request(self, request):\n- # TODO: implement a proper caching mechanism here for re-transmitting hits\n- # record = (Time.now(), request.get_full_url(), request.get_data(), request.headers)\n- pass\n-\n-\n-\n-\n-class HTTPPost(HTTPRequest):\n-\n- # Apply stored properties to the given dataset & POST to the configured endpoint\n- def send(self, data):\n- request = Request(\n- self.endpoint,\n- data = urlencode(self.fixUTF8(data)),\n- headers = {\n- 'User-Agent': self.user_agent\n- }\n- )\n- self.open(request)\n-\n-\n-\n-\n-\n-\n-class Tracker(object):\n- \"\"\" Primary tracking interface for Universal Analytics \"\"\"\n- params = None\n- parameter_alias = {}\n- valid_hittypes = ('pageview', 'event', 'social', 'screenview', 'transaction', 'item', 'exception', 'timing')\n-\n-\n- @classmethod\n- def alias(cls, typemap, base, *names):\n- \"\"\" Declare an alternate (humane) name for a measurement protocol parameter \"\"\"\n- cls.parameter_alias[ base ] = (typemap, base)\n- for i in names:\n- cls.parameter_alias[ i ] = (typemap, base)\n-\n- @classmethod\n- def coerceParameter(cls, name, value = None):\n- if isinstance(name, basestring) and name[0] == '&':\n- return name[1:], str(value)\n- elif name in cls.parameter_alias:\n- typecast, param_name = cls.parameter_alias.get(name)\n- return param_name, typecast(value)\n- else:\n- raise KeyError, 'Parameter \"{0}\" is not recognized'.format(name)\n-\n-\n- def payload(self, data):\n- for key, value in data.iteritems():\n- try:\n- yield self.coerceParameter(key, value)\n- except KeyError:\n- continue\n-\n-\n-\n- option_sequence = {\n- 'pageview': [ (basestring, 'dp') ],\n- 'event': [ (basestring, 'ec'), (basestring, 'ea'), (basestring, 'el'), (int, 'ev') ],\n- 'social': [ (basestring, 'sn'), (basestring, 'sa'), (basestring, 'st') ],\n- 'timing': [ (basestring, 'utc'), (basestring, 'utv'), (basestring, 'utt'), (basestring, 'utl') ]\n- }\n-\n- @classmethod\n- def consume_options(cls, data, hittype, args):\n- \"\"\" Interpret sequential arguments related to known hittypes based on declared structures \"\"\"\n- opt_position = 0\n- data[ 't' ] = hittype # integrate hit type parameter\n- if hittype in cls.option_sequence:\n- for expected_type, optname in cls.option_sequence[ hittype ]:\n- if opt_position < len(args) and isinstance(args[opt_position], expected_type):\n- data[ optname ] = args[ opt_position ]\n- opt_position += 1\n-\n-\n-\n-\n- @classmethod\n- def hittime(cls, timestamp = None, age = None, milliseconds = None):\n- \"\"\" Returns an integer represeting the milliseconds offset for a given hit (relative to now) \"\"\"\n- if isinstance(timestamp, (int, float)):\n- return int(Time.milliseconds_offset(Time.from_unix(timestamp, milliseconds = milliseconds)))\n- if isinstance(timestamp, datetime.datetime):\n- return int(Time.milliseconds_offset(timestamp))\n- if isinstance(age, (int, float)):\n- return int(age * 1000) + (milliseconds or 0)\n-\n-\n-\n- @property\n- def account(self):\n- return self.params.get('tid', None)\n-\n-\n- def __init__(self, account, name = None, client_id = None, hash_client_id = False, user_id = None, user_agent = None, use_post = True):\n-\n- if use_post is False:\n- self.http = HTTPRequest(user_agent = user_agent)\n- else:\n- self.http = HTTPPost(user_agent = user_agent)\n-\n- self.params = { 'v': 1, 'tid': account }\n-\n- if client_id is None:\n- client_id = generate_uuid()\n-\n- self.params[ 'cid' ] = client_id\n-\n- self.hash_client_id = hash_client_id\n-\n- if user_id is not None:\n- self.params[ 'uid' ] = user_id\n-\n-\n- def set_timestamp(self, data):\n- \"\"\" Interpret time-related options, apply queue-time parameter as needed \"\"\"\n- if 'hittime' in data: # an absolute timestamp\n- data['qt'] = self.hittime(timestamp = data.pop('hittime', None))\n- if 'hitage' in data: # a relative age (in seconds)\n- data['qt'] = self.hittime(age = data.pop('hitage', None))\n-\n-\n- def send(self, hittype, *args, **data):\n- \"\"\" Transmit HTTP requests to Google Analytics using the measurement protocol \"\"\"\n-\n- if hittype not in self.valid_hittypes:\n- raise KeyError('Unsupported Universal Analytics Hit Type: {0}'.format(repr(hittype)))\n-\n- self.set_timestamp(data)\n- self.consume_options(data, hittype, args)\n-\n- for item in args: # process dictionary-object arguments of transcient data\n- if isinstance(item, dict):\n- for key, val in self.payload(item):\n- data[ key ] = val\n-\n- for k, v in self.params.iteritems(): # update only absent parameters\n- if k not in data:\n- data[ k ] = v\n-\n-\n- data = dict(self.payload(data))\n-\n- if self.hash_client_id:\n- data[ 'cid' ] = generate_uuid(data[ 'cid' ])\n-\n- # Transmit the hit to Google...\n- self.http.send(data)\n-\n-\n-\n-\n- # Setting persistent attibutes of the session/hit/etc (inc. custom dimensions/metrics)\n- def set(self, name, value = None):\n- if isinstance(name, dict):\n- for key, value in name.iteritems():\n- try:\n- param, value = self.coerceParameter(key, value)\n- self.params[param] = value\n- except KeyError:\n- pass\n- elif isinstance(name, basestring):\n- try:\n- param, value = self.coerceParameter(name, value)\n- self.params[param] = value\n- except KeyError:\n- pass\n-\n-\n-\n- def __getitem__(self, name):\n- param, value = self.coerceParameter(name, None)\n- return self.params.get(param, None)\n-\n- def __setitem__(self, name, value):\n- param, value = self.coerceParameter(name, value)\n- self.params[param] = value\n-\n- def __delitem__(self, name):\n- param, value = self.coerceParameter(name, None)\n- if param in self.params:\n- del self.params[param]\n-\n-def safe_unicode(obj):\n- \"\"\" Safe convertion to the Unicode string version of the object \"\"\"\n- try:\n- return unicode(obj)\n- except UnicodeDecodeError:\n- return obj.decode('utf-8')\n-\n-\n-# Declaring name mappings for Measurement Protocol parameters\n-MAX_CUSTOM_DEFINITIONS = 200\n-MAX_EC_LISTS = 11 # 1-based index\n-MAX_EC_PRODUCTS = 11 # 1-based index\n-MAX_EC_PROMOTIONS = 11 # 1-based index\n-\n-Tracker.alias(int, 'v', 'protocol-version')\n-Tracker.alias(safe_unicode, 'cid', 'client-id', 'clientId', 'clientid')\n-Tracker.alias(safe_unicode, 'tid', 'trackingId', 'account')\n-Tracker.alias(safe_unicode, 'uid', 'user-id', 'userId', 'userid')\n-Tracker.alias(safe_unicode, 'uip', 'user-ip', 'userIp', 'ipaddr')\n-Tracker.alias(safe_unicode, 'ua', 'userAgent', 'userAgentOverride', 'user-agent')\n-Tracker.alias(safe_unicode, 'dp', 'page', 'path')\n-Tracker.alias(safe_unicode, 'dt', 'title', 'pagetitle', 'pageTitle' 'page-title')\n-Tracker.alias(safe_unicode, 'dl', 'location')\n-Tracker.alias(safe_unicode, 'dh', 'hostname')\n-Tracker.alias(safe_unicode, 'sc', 'sessioncontrol', 'session-control', 'sessionControl')\n-Tracker.alias(safe_unicode, 'dr', 'referrer', 'referer')\n-Tracker.alias(int, 'qt', 'queueTime', 'queue-time')\n-Tracker.alias(safe_unicode, 't', 'hitType', 'hittype')\n-Tracker.alias(int, 'aip', 'anonymizeIp', 'anonIp', 'anonymize-ip')\n-\n-\n-# Campaign attribution\n-Tracker.alias(safe_unicode, 'cn', 'campaign', 'campaignName', 'campaign-name')\n-Tracker.alias(safe_unicode, 'cs', 'source', 'campaignSource', 'campaign-source')\n-Tracker.alias(safe_unicode, 'cm', 'medium', 'campaignMedium', 'campaign-medium')\n-Tracker.alias(safe_unicode, 'ck', 'keyword', 'campaignKeyword', 'campaign-keyword')\n-Tracker.alias(safe_unicode, 'cc', 'content', 'campaignContent', 'campaign-content')\n-Tracker.alias(safe_unicode, 'ci', 'campaignId', 'campaignID', 'campaign-id')\n-\n-# Technical specs\n-Tracker.alias(safe_unicode, 'sr', 'screenResolution', 'screen-resolution', 'resolution')\n-Tracker.alias(safe_unicode, 'vp', 'viewport', 'viewportSize', 'viewport-size')\n-Tracker.alias(safe_unicode, 'de', 'encoding', 'documentEncoding', 'document-encoding')\n-Tracker.alias(int, 'sd', 'colors', 'screenColors', 'screen-colors')\n-Tracker.alias(safe_unicode, 'ul', 'language', 'user-language', 'userLanguage')\n-\n-# Mobile app\n-Tracker.alias(safe_unicode, 'an', 'appName', 'app-name', 'app')\n-Tracker.alias(safe_unicode, 'cd', 'contentDescription', 'screenName', 'screen-name', 'content-description')\n-Tracker.alias(safe_unicode, 'av', 'appVersion', 'app-version', 'version')\n-Tracker.alias(safe_unicode, 'aid', 'appID', 'appId', 'application-id', 'app-id', 'applicationId')\n-Tracker.alias(safe_unicode, 'aiid', 'appInstallerId', 'app-installer-id')\n-\n-# Ecommerce\n-Tracker.alias(safe_unicode, 'ta', 'affiliation', 'transactionAffiliation', 'transaction-affiliation')\n-Tracker.alias(safe_unicode, 'ti', 'transaction', 'transactionId', 'transaction-id')\n-Tracker.alias(float, 'tr', 'revenue', 'transactionRevenue', 'transaction-revenue')\n-Tracker.alias(float, 'ts', 'shipping', 'transactionShipping', 'transaction-shipping')\n-Tracker.alias(float, 'tt', 'tax', 'transactionTax', 'transaction-tax')\n-Tracker.alias(safe_unicode, 'cu', 'currency', 'transactionCurrency', 'transaction-currency') # Currency code, e.g. USD, EUR\n-Tracker.alias(safe_unicode, 'in', 'item-name', 'itemName')\n-Tracker.alias(float, 'ip', 'item-price', 'itemPrice')\n-Tracker.alias(float, 'iq', 'item-quantity', 'itemQuantity')\n-Tracker.alias(safe_unicode, 'ic', 'item-code', 'sku', 'itemCode')\n-Tracker.alias(safe_unicode, 'iv', 'item-variation', 'item-category', 'itemCategory', 'itemVariation')\n-\n-# Events\n-Tracker.alias(safe_unicode, 'ec', 'event-category', 'eventCategory', 'category')\n-Tracker.alias(safe_unicode, 'ea', 'event-action', 'eventAction', 'action')\n-Tracker.alias(safe_unicode, 'el', 'event-label', 'eventLabel', 'label')\n-Tracker.alias(int, 'ev', 'event-value', 'eventValue', 'value')\n-Tracker.alias(int, 'ni', 'noninteractive', 'nonInteractive', 'noninteraction', 'nonInteraction')\n-\n-\n-# Social\n-Tracker.alias(safe_unicode, 'sa', 'social-action', 'socialAction')\n-Tracker.alias(safe_unicode, 'sn', 'social-network', 'socialNetwork')\n-Tracker.alias(safe_unicode, 'st', 'social-target', 'socialTarget')\n-\n-# Exceptions\n-Tracker.alias(safe_unicode, 'exd', 'exception-description', 'exceptionDescription', 'exDescription')\n-Tracker.alias(int, 'exf', 'exception-fatal', 'exceptionFatal', 'exFatal')\n-\n-# User Timing\n-Tracker.alias(safe_unicode, 'utc', 'timingCategory', 'timing-category')\n-Tracker.alias(safe_unicode, 'utv', 'timingVariable', 'timing-variable')\n-Tracker.alias(int, 'utt', 'time', 'timingTime', 'timing-time')\n-Tracker.alias(safe_unicode, 'utl', 'timingLabel', 'timing-label')\n-Tracker.alias(float, 'dns', 'timingDNS', 'timing-dns')\n-Tracker.alias(float, 'pdt', 'timingPageLoad', 'timing-page-load')\n-Tracker.alias(float, 'rrt', 'timingRedirect', 'timing-redirect')\n-Tracker.alias(safe_unicode, 'tcp', 'timingTCPConnect', 'timing-tcp-connect')\n-Tracker.alias(safe_unicode, 'srt', 'timingServerResponse', 'timing-server-response')\n-\n-# Custom dimensions and metrics\n-for i in range(0,200):\n- Tracker.alias(safe_unicode, 'cd{0}'.format(i), 'dimension{0}'.format(i))\n- Tracker.alias(int, 'cm{0}'.format(i), 'metric{0}'.format(i))\n-\n-# Enhanced Ecommerce\n-Tracker.alias(str, 'pa') # Product action\n-Tracker.alias(str, 'tcc') # Coupon code\n-Tracker.alias(unicode, 'pal') # Product action list\n-Tracker.alias(int, 'cos') # Checkout step\n-Tracker.alias(str, 'col') # Checkout step option\n-\n-Tracker.alias(str, 'promoa') # Promotion action\n-\n-for product_index in range(1, MAX_EC_PRODUCTS):\n- Tracker.alias(str, 'pr{0}id'.format(product_index)) # Product SKU\n- Tracker.alias(unicode, 'pr{0}nm'.format(product_index)) # Product name\n- Tracker.alias(unicode, 'pr{0}br'.format(product_index)) # Product brand\n- Tracker.alias(unicode, 'pr{0}ca'.format(product_index)) # Product category\n- Tracker.alias(unicode, 'pr{0}va'.format(product_index)) # Product variant\n- Tracker.alias(str, 'pr{0}pr'.format(product_index)) # Product price\n- Tracker.alias(int, 'pr{0}qt'.format(product_index)) # Product quantity\n- Tracker.alias(str, 'pr{0}cc'.format(product_index)) # Product coupon code\n- Tracker.alias(int, 'pr{0}ps'.format(product_index)) # Product position\n-\n- for custom_index in range(MAX_CUSTOM_DEFINITIONS):\n- Tracker.alias(str, 'pr{0}cd{1}'.format(product_index, custom_index)) # Product custom dimension\n- Tracker.alias(int, 'pr{0}cm{1}'.format(product_index, custom_index)) # Product custom metric\n-\n- for list_index in range(1, MAX_EC_LISTS):\n- Tracker.alias(str, 'il{0}pi{1}id'.format(list_index, product_index)) # Product impression SKU\n- Tracker.alias(unicode, 'il{0}pi{1}nm'.format(list_index, product_index)) # Product impression name\n- Tracker.alias(unicode, 'il{0}pi{1}br'.format(list_index, product_index)) # Product impression brand\n- Tracker.alias(unicode, 'il{0}pi{1}ca'.format(list_index, product_index)) # Product impression category\n- Tracker.alias(unicode, 'il{0}pi{1}va'.format(list_index, product_index)) # Product impression variant\n- Tracker.alias(int, 'il{0}pi{1}ps'.format(list_index, product_index)) # Product impression position\n- Tracker.alias(int, 'il{0}pi{1}pr'.format(list_index, product_index)) # Product impression price\n-\n- for custom_index in range(MAX_CUSTOM_DEFINITIONS):\n- Tracker.alias(str, 'il{0}pi{1}cd{2}'.format(list_index, product_index, custom_index)) # Product impression custom dimension\n- Tracker.alias(int, 'il{0}pi{1}cm{2}'.format(list_index, product_index, custom_index)) # Product impression custom metric\n-\n-for list_index in range(1, MAX_EC_LISTS):\n- Tracker.alias(unicode, 'il{0}nm'.format(list_index)) # Product impression list name\n-\n-for promotion_index in range(1, MAX_EC_PROMOTIONS):\n- Tracker.alias(str, 'promo{0}id'.format(promotion_index)) # Promotion ID\n- Tracker.alias(unicode, 'promo{0}nm'.format(promotion_index)) # Promotion name\n- Tracker.alias(str, 'promo{0}cr'.format(promotion_index)) # Promotion creative\n- Tracker.alias(str, 'promo{0}ps'.format(promotion_index)) # Promotion position\n-\n-\n-# Shortcut for creating trackers\n-def create(account, *args, **kwargs):\n- return Tracker(account, *args, **kwargs)\n-\n-# vim: set nowrap tabstop=4 shiftwidth=4 softtabstop=0 expandtab textwidth=0 filetype=python foldmethod=indent foldcolumn=4\n" }, { "change_type": "DELETE", "old_path": "resources/lib/UniversalAnalytics/__init__.py", "new_path": null, "diff": "-import Tracker\n\\ No newline at end of file\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Dropout UniversalAnalytics we no need to measure users activity with google analytics
105,991
06.07.2019 13:33:12
-7,200
554595473fa4130e94d04dff8b269690a7fc84ac
Fix settings enabled or visible VP9 can't be enabled if HEVC is enabled HEVC can't be enabled if VP9 is enabled |eq(0,true) allows HEVC or VP9 to be disabled if both are already enabled Export NFO extra settings visibility: hidden if export NFO is false instead of disabled
[ { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"update_running\" type=\"text\" visible=\"false\" default=\"false\"/>\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\" enable=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n- <setting id=\"export_tvshow_nfo\" type=\"enum\" label=\"30187\" lvalues=\"21337|20422|30188\" enable=\"eq(-2,true)\" default=\"1\" subsetting=\"true\"/>\n- <setting id=\"export_full_tvshow_nfo\" type=\"bool\" label=\"30193\" enable=\"eq(-3,true)\" default=\"false\" subsetting=\"true\"/>\n+ <setting id=\"export_movie_nfo\" type=\"enum\" label=\"30186\" lvalues=\"21337|20422|30188\" visible=\"eq(-1,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_tvshow_nfo\" type=\"enum\" label=\"30187\" lvalues=\"21337|20422|30188\" visible=\"eq(-2,true)\" default=\"1\" subsetting=\"true\"/>\n+ <setting id=\"export_full_tvshow_nfo\" type=\"bool\" label=\"30193\" visible=\"eq(-3,true)\" default=\"false\" subsetting=\"true\"/>\n</category>\n<category label=\"30166\"><!--Main menu items-->\n<setting id=\"show_menu_mylist\" type=\"bool\" label=\"30167\" default=\"true\"/>\n<setting label=\"30115\" type=\"lsep\"/>\n<setting id=\"enable_1080p_unlock\" type=\"bool\" label=\"30136\" default=\"false\" visible=\"false\"/> <!-- Deprecated (broken) -->\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n- <setting id=\"enable_vp9_profiles\" type=\"bool\" label=\"30137\" default=\"true\"/>\n- <setting id=\"enable_hevc_profiles\" type=\"bool\" label=\"30060\" default=\"false\"/>\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_hdr_profiles\" type=\"bool\" label=\"30098\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"enable_dolbyvision_profiles\" type=\"bool\" label=\"30099\" default=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting id=\"enable_force_hdcp\" type=\"bool\" label=\"30081\" default=\"false\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix settings enabled or visible - VP9 can't be enabled if HEVC is enabled - HEVC can't be enabled if VP9 is enabled |eq(0,true) allows HEVC or VP9 to be disabled if both are already enabled - Export NFO extra settings visibility: hidden if export NFO is false instead of disabled
106,046
08.07.2019 20:37:50
-7,200
0f298d2352379c0551bd76543cdbf8621f87e1cb
Fixed error when numbers of items are equal to response_size
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/pathops.py", "new_path": "resources/lib/common/pathops.py", "diff": "@@ -63,3 +63,16 @@ def _branch(path, search_space, default):\nreturn {k: get_multiple_paths([k] + path[1:], search_space, default)\nfor k in path[0]\nif k in search_space}\n+\n+\n+def check_path_exists(path, search_space):\n+ \"\"\"Return True if the path exists in search_space\"\"\"\n+ if not isinstance(search_space, dict):\n+ return False\n+ if path[0] in search_space:\n+ if len(path) > 1:\n+ current_value = search_space.get(path[0])\n+ return check_path_exists(path[1:], current_value)\n+ else:\n+ return True\n+ return False\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -289,7 +289,12 @@ class NetflixSession(object):\nfor n_req in range(number_of_requests):\npath_response = self._path_request(_set_range_selector(paths, range_start, range_end))\n- if len(path_response) != 0:\n+ if len(path_response) == 0:\n+ break\n+ if not common.check_path_exists(length_args, path_response):\n+ # It may happen that the number of items to be received is equal to the number of the response_size\n+ # so a second round will be performed, which will return an empty list\n+ break\ncommon.merge_dicts(path_response, merged_response)\nresponse_count = response_length(path_response, *length_args)\nif response_count >= response_size:\n@@ -302,8 +307,6 @@ class NetflixSession(object):\nelse:\n# There are no other elements to request\nbreak\n- else:\n- break\nif perpetual_range_start > 0:\nprevious_start = perpetual_range_start - (response_size * number_of_requests)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed error when numbers of items are equal to response_size
105,991
08.07.2019 22:25:08
-7,200
ef54626f73f8bc2062e639c5cf360b4f66d99e3e
Update languages Add PT_BR to (Thanks Lower Remove not more necessary text in Update Addon Provider Update Report-Msgid-Bugs-To Update PO-Revision-Date
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.de_de/strings.po", "new_path": "resources/language/resource.language.de_de/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Sebastian Golasch <[email protected]>\\n\"\n\"Language-Team: German\\n\"\n\"MIME-Version: 1.0\\n\"\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": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Stefano Gottardo <>\\n\"\n\"Language-Team: English\\n\"\n\"MIME-Version: 1.0\\n\"\n@@ -565,7 +565,7 @@ msgid \"Enable 1080p Unlock (not recommended for Android)\"\nmsgstr \"\"\nmsgctxt \"#30137\"\n-msgid \"Enable VP9 profiles (not use with HEVC, disable if it causes artifacts)\"\n+msgid \"Enable VP9 profiles (disable if it causes artifacts)\"\nmsgstr \"\"\nmsgctxt \"#30138\"\n@@ -709,7 +709,7 @@ msgid \"Popular on Netflix\"\nmsgstr \"\"\nmsgctxt \"#30173\"\n-msgid \"NETFLIX ORIGINALS\"\n+msgid \"Netflix Originals\"\nmsgstr \"\"\nmsgctxt \"#30174\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.es_es/strings.po", "new_path": "resources/language/resource.language.es_es/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2018-06-02 19:13+0200\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: danielchc\\n\"\n\"Language-Team: Spanish\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.fi_fi/strings.po", "new_path": "resources/language/resource.language.fi_fi/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Sebastian Golasch <[email protected]>\\n\"\n\"Language-Team: Finnish\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.he_il/strings.po", "new_path": "resources/language/resource.language.he_il/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-10-17 17:37+0300\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: A. Dambledore\\n\"\n\"Language-Team: Eng2Heb\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.hr_hr/strings.po", "new_path": "resources/language/resource.language.hr_hr/strings.po", "diff": "# Croatian translation for Kodi Media Center Netfilx addon\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: gogo\\n\"\n\"Language-Team: Croatian\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.ko_kr/strings.po", "new_path": "resources/language/resource.language.ko_kr/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Allen Choi<[email protected]>\\n\"\n\"Language-Team: Korean\\n\"\n\"MIME-Version: 1.0\\n\"\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": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Sebastian Golasch <[email protected]>\\n\"\n\"Language-Team: Dutch\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.pt_pt/strings.po", "new_path": "resources/language/resource.language.pt_pt/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2018-06-14 13:37+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Gustavo Silva <[email protected]>\\n\"\n\"Language-Team: Portuguese\\n\"\n\"MIME-Version: 1.0\\n\"\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.sv_sv/strings.po", "new_path": "resources/language/resource.language.sv_sv/strings.po", "diff": "# Kodi Media Center language file\n# Addon Name: Netflix\n# Addon id: plugin.video.netflix\n-# Addon Provider: libdev + jojo + asciidisco\n+# Addon Provider: libdev + jojo + asciidisco + caphm + CastagnaIT\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n-\"Report-Msgid-Bugs-To: https://github.com/asciidisco/plugin.video.netflix\\n\"\n+\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2017-07-24 16:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n\"Last-Translator: Sebastian Golasch <[email protected]>\\n\"\n\"Language-Team: Swedish\\n\"\n\"MIME-Version: 1.0\\n\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Update languages https://github.com/CastagnaIT/plugin.video.netflix/issues/124 - Add PT_BR #30181 to #30193 (Thanks @MediaBrasil) - Lower #30173 - Remove not more necessary text in #30137 - Update Addon Provider - Update Report-Msgid-Bugs-To - Update PO-Revision-Date
105,991
14.07.2019 01:31:56
-7,200
9a4f3243094dc54a8886ae42c8f48f0db115fa87
Fix Playback services frozen Sending 'noop' action allows the modal window to close correctly, and the service to keep running
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/xmldialogs.py", "new_path": "resources/lib/kodi/ui/xmldialogs.py", "diff": "@@ -11,7 +11,7 @@ import xbmcgui\nACTION_PLAYER_STOP = 13\nOS_MACHINE = machine()\n-CMD_AUTOCLOSE_DIALOG = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n+CMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),' \\\n'{:02d}:{:02d},silent)'\n@@ -25,7 +25,7 @@ def show_modal_dialog(dlg_class, xml, path, **kwargs):\nminutes = kwargs.get('minutes', 0)\nseconds = kwargs.get('seconds', 0)\nif minutes > 0 or seconds > 0:\n- xbmc.executebuiltin(CMD_AUTOCLOSE_DIALOG.format(minutes, seconds))\n+ xbmc.executebuiltin(CMD_CLOSE_DIALOG_BY_NOOP.format(minutes, seconds))\ndlg.doModal()\n@@ -50,6 +50,10 @@ class Skip(xbmcgui.WindowXMLDialog):\nxbmc.Player().seekTime(self.skip_to)\nself.close()\n+ def onAction(self, action):\n+ if action.getId() == 999: # action noop\n+ self.close()\n+\nclass SaveStreamSettings(xbmcgui.WindowXMLDialog):\n\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix Playback services frozen https://github.com/CastagnaIT/plugin.video.netflix/issues/130 Sending 'noop' action allows the modal window to close correctly, and the service to keep running
106,046
14.07.2019 19:11:17
-7,200
8c9c6de99483282f6d2f5fede4da7b1e06e87da8
Try to fix 404 Client Error: Not Found for url
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -316,7 +316,6 @@ class NetflixSession(object):\nmerged_response['_perpetual_range_selector'] = {'previous_start': previous_start}\nreturn merged_response\n-\[email protected]_execution(immediate=True)\ndef _path_request(self, paths):\n\"\"\"Execute a path request with static paths\"\"\"\n@@ -361,19 +360,22 @@ class NetflixSession(object):\nreturn self._post(component, **kwargs)\ndef _get(self, component, **kwargs):\n- return self._request(\n+ return self._request_call(\nmethod=self.session.get,\ncomponent=component,\n**kwargs)\ndef _post(self, component, **kwargs):\n- return self._request(\n+ return self._request_call(\nmethod=self.session.post,\ncomponent=component,\n**kwargs)\[email protected]_execution(immediate=True)\n- def _request(self, method, component, **kwargs):\n+ def _request_call(self, method, component, **kwargs):\n+ return self._request(method, component, None, **kwargs)\n+\n+ def _request(self, method, component, session_refreshed, **kwargs):\nurl = (_api_url(component, self.session_data['api_data'])\nif URLS[component]['is_api_call']\nelse _document_url(component))\n@@ -392,6 +394,14 @@ class NetflixSession(object):\ncommon.debug('Request took {}s'.format(time.clock() - start))\ncommon.debug('Request returned statuscode {}'\n.format(response.status_code))\n+ if response.status_code == 404 and not session_refreshed:\n+ # It may happen that netflix updates the build_identifier version\n+ # when you are watching a video or browsing the menu,\n+ # this causes the api address to change, and return 'url not found' error\n+ # So let's try updating the session data (just once)\n+ common.debug('Try refresh session data to update build_identifier version')\n+ if self._refresh_session_data():\n+ return self._request(method, component, True, **kwargs)\nresponse.raise_for_status()\nreturn (_raise_api_error(response.json() if response.content else {})\nif URLS[component]['is_api_call']\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Try to fix 404 Client Error: Not Found for url
106,046
15.07.2019 21:30:53
-7,200
9799fec0f8e33efd111f83ff9702d2911a6f8a94
Added stream resolution limit
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -7,7 +7,7 @@ msgstr \"\"\n\"Project-Id-Version: plugin.video.netflix\\n\"\n\"Report-Msgid-Bugs-To: https://github.com/CastagnaIT/plugin.video.netflix\\n\"\n\"POT-Creation-Date: 2017-07-24 16:15+0000\\n\"\n-\"PO-Revision-Date: 2019-07-08 22:15+0000\\n\"\n+\"PO-Revision-Date: 2019-07-15 20:40+0000\\n\"\n\"Last-Translator: Stefano Gottardo <>\\n\"\n\"Language-Team: English\\n\"\n\"MIME-Version: 1.0\\n\"\n@@ -791,3 +791,8 @@ msgstr \"\"\nmsgctxt \"#30193\"\nmsgid \"Include all information in NFO files (use only with 'Local Information' scraper)\"\nmsgstr \"\"\n+\n+msgctxt \"#30194\"\n+msgid \"Limit video stream resolution to\"\n+msgstr \"\"\n+\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/converter.py", "new_path": "resources/lib/services/msl/converter.py", "diff": "@@ -75,13 +75,42 @@ def _convert_video_track(video_track, period, init_length, protection, drm_strea\ncontentType='video')\nif protection:\n_add_protection_info(adaptation_set, **protection)\n+\n+ limit_res = _limit_video_resolution(video_track['streams'], drm_streams)\n+\nfor downloadable in video_track['streams']:\nif downloadable['isDrm'] != drm_streams:\ncontinue\n+ if limit_res:\n+ if int(downloadable['res_h']) > limit_res:\n+ continue\n_convert_video_downloadable(\ndownloadable, adaptation_set, init_length)\n+def _limit_video_resolution(video_tracks, drm_streams):\n+ \"\"\"Limit max video resolution to user choice\"\"\"\n+ max_resolution = g.ADDON.getSettingString('stream_max_resolution')\n+ if max_resolution != '--':\n+ if max_resolution == 'SD 480p':\n+ res_limit = 480\n+ elif max_resolution == 'SD 576p':\n+ res_limit = 576\n+ elif max_resolution == 'HD 720p':\n+ res_limit = 720\n+ elif max_resolution == 'Full HD 1080p':\n+ res_limit = 1080\n+ elif max_resolution == 'UHD 4K':\n+ res_limit = 4096\n+ # At least an equal or lower resolution must exist otherwise disable the imposed limit\n+ for downloadable in video_tracks:\n+ if downloadable['isDrm'] != drm_streams:\n+ continue\n+ if int(downloadable['res_h']) <= res_limit:\n+ return res_limit\n+ return None\n+\n+\ndef _add_protection_info(adaptation_set, pssh, keyid):\nif keyid:\nprotection = ET.SubElement(\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "</category>\n<category label=\"30023\"><!--Expert-->\n<setting label=\"30115\" type=\"lsep\"/>\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_1080p_unlock\" type=\"bool\" label=\"30136\" default=\"false\" visible=\"false\"/> <!-- Deprecated (broken) -->\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" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added stream resolution limit Co-authored-by: Jaker MX <[email protected]> Co-authored-by: Smeulf <[email protected]>
105,991
18.07.2019 01:36:46
-7,200
3a4c32be9fd1c9e925d8b6481fcf524b93b2c63d
Fix auto login disabled issue Previously, when auto login was disabled, it was necessary to restart the add-on to see profiles again. Disabling disc cache for the home directory when auto login is active avoid restarting. Auto login can't be enabled from settings anymore.
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -39,7 +39,7 @@ class DirectoryBuilder(object):\ncommon.debug('Performing auto-login for selected profile {}'\n.format(profile_id))\napi.activate_profile(profile_id)\n- self.home()\n+ self.home(None, False)\nelse:\nself.profiles()\n@@ -51,12 +51,12 @@ class DirectoryBuilder(object):\n_handle_endofdirectory(False)\[email protected]_execution(immediate=False)\n- def home(self, pathitems=None):\n+ def home(self, pathitems=None, cache_to_disc=True):\n\"\"\"Show home listing\"\"\"\n# pylint: disable=unused-argument\ncommon.debug('Showing root video lists')\nlistings.build_main_menu_listing(api.root_lists())\n- _handle_endofdirectory(False)\n+ _handle_endofdirectory(False, cache_to_disc)\[email protected]_execution(immediate=False)\ndef video_list(self, pathitems):\n@@ -199,6 +199,9 @@ def _display_search_results(pathitems, perpetual_range_start, dir_update_listing\nxbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=False)\n-def _handle_endofdirectory(dir_update_listing):\n+def _handle_endofdirectory(dir_update_listing, cache_to_disc=True):\n# If dir_update_listing=True overwrite the history list, so we can get back to the main page\n- xbmcplugin.endOfDirectory(g.PLUGIN_HANDLE, succeeded=True, updateListing=dir_update_listing)\n+ xbmcplugin.endOfDirectory(g.PLUGIN_HANDLE,\n+ succeeded=True,\n+ updateListing=dir_update_listing,\n+ cacheToDisc=cache_to_disc)\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"logout\" type=\"action\" label=\"30017\" action=\"RunPlugin(plugin://plugin.video.netflix/action/logout/)\" option=\"close\"/>\n<setting id=\"adultpin_enable\" type=\"action\" label=\"30062\" default=\"False\" action=\"RunPlugin(plugin://plugin.video.netflix/action/toggle_adult_pin/)\" option=\"close\"/>\n<setting label=\"30053\" type=\"lsep\"/>\n- <setting id=\"autologin_enable\" type=\"bool\" label=\"30054\" default=\"false\"/>\n+ <setting id=\"info\" type=\"text\" label=\"30057\" default=\"\" enable=\"false\"/>\n+ <setting id=\"autologin_enable\" type=\"bool\" label=\"30054\" default=\"false\" enable=\"eq(0,true)\"/>\n<setting id=\"autologin_user\" type=\"text\" label=\"30055\" default=\"\" enable=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"autologin_id\" type=\"text\" label=\"30056\" default=\"\" enable=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n- <setting id=\"info\" type=\"text\" label=\"30057\" default=\"\" enable=\"false\" visible=\"eq(-3,true)\"/>\n<setting type=\"sep\"/>\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n</category>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix auto login disabled issue Previously, when auto login was disabled, it was necessary to restart the add-on to see profiles again. Disabling disc cache for the home directory when auto login is active avoid restarting. Auto login can't be enabled from settings anymore.
105,991
27.07.2019 06:26:12
-7,200
f696eda09186c62069729ca4dfd1cc4fa356aea5
Skip xml dialog: Fix exit keys After fixing service frozen, it became impossible to exit the form the dialog. This fixes the issue, and adding ACTION_NAV_BACK allows the remote to work as expected.
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/xmldialogs.py", "new_path": "resources/lib/kodi/ui/xmldialogs.py", "diff": "@@ -8,7 +8,11 @@ from platform import machine\nimport xbmc\nimport xbmcgui\n+ACTION_PREVIOUS_MENU = 10\nACTION_PLAYER_STOP = 13\n+ACTION_NAV_BACK = 92\n+ACTION_NOOP = 999\n+\nOS_MACHINE = machine()\nCMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),' \\\n@@ -36,13 +40,18 @@ class Skip(xbmcgui.WindowXMLDialog):\ndef __init__(self, *args, **kwargs):\nself.skip_to = kwargs['skip_to']\nself.label = kwargs['label']\n+\n+ self.action_exitkeys_id = [ACTION_PREVIOUS_MENU,\n+ ACTION_PLAYER_STOP,\n+ ACTION_NAV_BACK,\n+ ACTION_NOOP]\n+\nif OS_MACHINE[0:5] == 'armv7':\nxbmcgui.WindowXMLDialog.__init__(self)\nelse:\nxbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\ndef onInit(self):\n- self.action_exitkeys_id = [10, 13]\nself.getControl(6012).setLabel(self.label)\ndef onClick(self, controlID):\n@@ -51,7 +60,7 @@ class Skip(xbmcgui.WindowXMLDialog):\nself.close()\ndef onAction(self, action):\n- if action.getId() == 999: # action noop\n+ if action.getId() in self.action_exitkeys_id:\nself.close()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Skip xml dialog: Fix exit keys After fixing service frozen, it became impossible to exit the form the dialog. This fixes the issue, and adding ACTION_NAV_BACK allows the remote to work as expected.
106,040
10.08.2019 20:53:43
-7,200
3e7c164d2bdcb6fb0ef4daec99efb458b63a7632
Fix wrong reference to common.debug() in kodiops The plugin was exiting with an error ("NameError: global name 'common' is not defined") when writing debug output for AdjustLocale.
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -185,5 +185,5 @@ def _adjust_locale(locale_code, lang_code_without_country_exists):\nif locale_code in locale_conversion_table:\nreturn locale_conversion_table[locale_code]\nelse:\n- common.debug('AdjustLocale - missing mapping conversion for locale: {}'.format(locale_code))\n+ debug('AdjustLocale - missing mapping conversion for locale: {}'.format(locale_code))\nreturn locale_code\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix wrong reference to common.debug() in kodiops The plugin was exiting with an error ("NameError: global name 'common' is not defined") when writing debug output for AdjustLocale.
106,046
11.08.2019 15:32:45
-7,200
8cacee0fb629a6c2c46ba310784e42aa03a496d3
Added en-GB to the mapping conversion for locale
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/kodiops.py", "new_path": "resources/lib/common/kodiops.py", "diff": "@@ -169,14 +169,16 @@ def fix_locale_languages(data_list):\ndef _adjust_locale(locale_code, lang_code_without_country_exists):\n\"\"\"\nLocale conversion helper\n- Conversion table to prevent Kodi to display es-ES as Spanish - Spanish, pt-BR as Portuguese - Breton, and so on\n+ Conversion table to prevent Kodi to display\n+ es-ES as Spanish - Spanish, pt-BR as Portuguese - Breton, and so on\n\"\"\"\nlocale_conversion_table = {\n'es-ES': 'es-Spain',\n'pt-BR': 'pt-Brazil',\n'fr-CA': 'fr-Canada',\n'ar-EG': 'ar-Egypt',\n- 'nl-BE': 'nl-Belgium'\n+ 'nl-BE': 'nl-Belgium',\n+ 'en-GB': 'en-UnitedKingdom'\n}\nlanguage_code = locale_code[0:2]\nif not lang_code_without_country_exists:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added en-GB to the mapping conversion for locale
106,046
14.08.2019 15:43:14
-7,200
8a50ba8a797699df5322445835f9f200396599fb
Fixed KeyError 'lists' to VideoList
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/data_types.py", "new_path": "resources/lib/api/data_types.py", "diff": "@@ -64,6 +64,12 @@ class VideoList(object):\ndef __init__(self, path_response, list_id=None):\nself.perpetual_range_selector = path_response.get('_perpetual_range_selector')\nself.data = path_response\n+ has_data = True if path_response.get('lists') else False\n+ self.videos = {}\n+ self.artitem = None\n+ self.contained_titles = None\n+ self.videoids = None\n+ if has_data:\nself.id = common.VideoId(\nvideoid=(list_id\nif list_id\n@@ -77,10 +83,6 @@ class VideoList(object):\nself.videoids = _get_videoids(self.videos)\nexcept KeyError:\nself.videoids = None\n- else:\n- self.artitem = None\n- self.contained_titles = None\n- self.videoids = None\ndef __getitem__(self, key):\nreturn _check_sentinel(self.data['lists'][self.id.value][key])\n@@ -98,16 +100,18 @@ class VideoListSorted(object):\nself.perpetual_range_selector = path_response.get('_perpetual_range_selector')\nself.data = path_response\nself.context_name = context_name\n- data_present = True if (context_id and path_response.get(context_name)\n+ has_data = True if (context_id and path_response.get(context_name)\nand path_response[context_name].get(context_id)) or \\\n(not context_id and path_response.get(context_name)) else False\n- if data_present:\n+ self.data_lists = {}\n+ self.videos = {}\n+ self.artitem = None\n+ self.contained_titles = None\n+ self.videoids = None\n+ if has_data:\nself.data_lists = path_response[context_name][context_id][req_sort_order_type] \\\nif context_id else path_response[context_name][req_sort_order_type]\nself.videos = OrderedDict(resolve_refs(self.data_lists, self.data))\n- else:\n- self.data_lists = {}\n- self.videos = {}\nif self.videos:\nself.artitem = next(self.videos.itervalues())\nself.contained_titles = _get_titles(self.videos)\n@@ -115,10 +119,6 @@ class VideoListSorted(object):\nself.videoids = _get_videoids(self.videos)\nexcept KeyError:\nself.videoids = None\n- else:\n- self.artitem = None\n- self.contained_titles = None\n- self.videoids = None\ndef __getitem__(self, key):\nreturn _check_sentinel(self.data_lists[key])\n@@ -134,8 +134,12 @@ class SearchVideoList(object):\ndef __init__(self, path_response):\nself.perpetual_range_selector = path_response.get('_perpetual_range_selector')\nself.data = path_response\n- have_data = 'search' in path_response\n- if have_data:\n+ has_data = 'search' in path_response\n+ self.videos = {}\n+ self.videoids = None\n+ self.artitem = None\n+ self.contained_titles = None\n+ if has_data:\nself.title = common.get_local_string(30100).format(self.data['search']['byTerm'].keys()[0][1:])\nself.videos = OrderedDict(resolve_refs(self.data['search']['byReference'].values()[0], self.data))\nself.videoids = _get_videoids(self.videos)\n@@ -143,10 +147,6 @@ class SearchVideoList(object):\nself.contained_titles = _get_titles(self.videos)\nelse:\ncommon.debug('SearchVideoList - No data in path_response')\n- self.videos = {}\n- self.videoids = None\n- self.artitem = None\n- self.contained_titles = None\ndef __getitem__(self, key):\nreturn _check_sentinel(self.data['search'][key])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed KeyError 'lists' to VideoList
106,046
28.07.2019 02:17:27
-7,200
9f0e2c8eff16131fd7c9c4a9b40e033e348c7694
Fixed file exists function
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/fileops.py", "new_path": "resources/lib/common/fileops.py", "diff": "@@ -29,9 +29,9 @@ def file_exists(filename, data_path=g.DATA_PATH):\n\"\"\"\nChecks if a given file exists\n:param filename: The filename\n- :return: True if so\n+ :return: True if exists\n\"\"\"\n- return os.path.exists(data_path + filename)\n+ return xbmcvfs.exists(xbmc.translatePath(os.path.join(data_path, filename)))\ndef save_file(filename, content, mode='w'):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed file exists function
106,046
21.07.2019 15:26:02
-7,200
be1bd3bc9ae644a3fed5b228b43937b2d0798a19
Added file copy
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/fileops.py", "new_path": "resources/lib/common/fileops.py", "diff": "@@ -34,6 +34,20 @@ def file_exists(filename, data_path=g.DATA_PATH):\nreturn xbmcvfs.exists(xbmc.translatePath(os.path.join(data_path, filename)))\n+def copy_file(from_path, to_path):\n+ \"\"\"\n+ Copy a file to destination\n+ :param from_path: File path to copy\n+ :param to_path: Destination file path\n+ :return: True if copied\n+ \"\"\"\n+ try:\n+ return xbmcvfs.copy(xbmc.translatePath(from_path),\n+ xbmc.translatePath(to_path))\n+ finally:\n+ pass\n+\n+\ndef save_file(filename, content, mode='w'):\n\"\"\"\nSaves the given content under given filename\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added file copy
106,046
21.07.2019 15:27:41
-7,200
3c0fd60f97c1932c1edd25438eca1c524df1b550
Added addon data path
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -190,7 +190,8 @@ class GlobalVariables(object):\nself.VERSION = self.ADDON.getAddonInfo('version')\nself.DEFAULT_FANART = self.ADDON.getAddonInfo('fanart')\nself.ICON = self.ADDON.getAddonInfo('icon')\n- self.DATA_PATH = self.ADDON.getAddonInfo('profile')\n+ self.ADDON_DATA_PATH = self.ADDON.getAddonInfo('path') # Addon folder\n+ self.DATA_PATH = self.ADDON.getAddonInfo('profile') # Addon user data folder\nself.CACHE_PATH = os.path.join(self.DATA_PATH, 'cache')\nself.COOKIE_PATH = os.path.join(self.DATA_PATH, 'COOKIE')\nself.CACHE_TTL = self.ADDON.getSettingInt('cache_ttl') * 60\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added addon data path
106,046
28.07.2019 02:30:13
-7,200
2f6f41af3cbe1b38e0d9615e9cb233ab71676081
Added database instances to globals
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -215,6 +215,17 @@ class GlobalVariables(object):\nself.TIME_TRACE_ENABLED = self.ADDON.getSettingBool('enable_timing')\nself.IPC_OVER_HTTP = self.ADDON.getSettingBool('enable_ipc_over_http')\n+ import resources.lib.database.db_local as db_local\n+ self.LOCAL_DB = db_local.NFLocalDatabase()\n+ import resources.lib.database.db_shared as db_shared\n+ import resources.lib.database.db_utils as db_utils\n+ # TODO: xml settings to specify a custom path\n+ # need to study how better apply to client/service\n+ temp_hardcoded_path = xbmc.translatePath(os.path.join(g.DATA_PATH,\n+ 'database',\n+ db_utils.SHARED_DB_FILENAME))\n+ self.SHARED_DB = db_shared.NFSharedDatabase(temp_hardcoded_path)\n+\ntry:\nos.mkdir(self.DATA_PATH)\nexcept OSError:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added database instances to globals
106,046
28.07.2019 02:32:53
-7,200
bb00c79f24c911eda849727c2b6bb3e173c661f6
Added is_less_version utils
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -271,10 +271,15 @@ def is_edge_esn(esn):\ndef is_minimum_version(version, min_version):\n- \"\"\"Rrturn True if version is equal or greater to min_version\"\"\"\n+ \"\"\"Return True if version is equal or greater to min_version\"\"\"\nreturn map(int, version.split('.')) >= map(int, min_version.split('.'))\n+def is_less_version(version, max_version):\n+ \"\"\"Return True if version is less to max_version\"\"\"\n+ return map(int, version.split('.')) < map(int, max_version.split('.'))\n+\n+\ndef make_list(arg):\n\"\"\"Return a list with arg as its member or arg if arg is already a list.\nReturns an empty list if arg is None\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added is_less_version utils
106,046
10.08.2019 10:57:47
-7,200
b7cb5e0ccf54d3b0832c1ef49af84bdb0e44b9a1
Implemented version upgrade controller
[ { "change_type": "MODIFY", "old_path": "addon.py", "new_path": "addon.py", "diff": "@@ -19,6 +19,7 @@ from resources.lib.globals import g\ng.init_globals(sys.argv)\nimport resources.lib.common as common\n+import resources.lib.upgrade_controller as upgrade_ctrl\nimport resources.lib.api.shakti as api\nimport resources.lib.kodi.ui as ui\nimport resources.lib.navigation as nav\n@@ -86,6 +87,7 @@ if __name__ == '__main__':\nsuccess = False\ntry:\n+ upgrade_ctrl.check_addon_upgrade()\ng.initial_addon_configuration()\nroute(filter(None, g.PATH.split('/')))\nsuccess = True\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/database/db_update.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Database update functions\"\"\"\n+from __future__ import unicode_literals\n+\n+import resources.lib.common as common\n+import resources.lib.database.db_base as db_base\n+import resources.lib.database.db_utils as db_utils\n+\n+\n+def run_local_db_updates(db_version, db_new_version):\n+ \"\"\"Perform database actions for a db version change\"\"\"\n+ # The changes must be left in sequence to allow cascade operations on non-updated databases\n+ if common.is_less_version(db_version, '0.2'):\n+ pass\n+ if common.is_less_version(db_version, '0.3'):\n+ pass\n+ g.LOCAL_DB.set_value('db_version', db_new_version)\n+\n+\n+def run_shared_db_updates(db_version, db_new_version):\n+ \"\"\"Perform database actions for a db version change\"\"\"\n+ # The changes must be left in sequence to allow cascade operations on non-updated databases\n+ if common.is_less_version(db_version, '0.2'):\n+ pass\n+ if common.is_less_version(db_version, '0.3'):\n+ pass\n+ g.LOCAL_DB.set_value('db_version', db_new_version)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/upgrade_controller.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Check if the addon has been updated and make necessary changes\"\"\"\n+from __future__ import unicode_literals\n+\n+import resources.lib.common as common\n+\n+from resources.lib.globals import g\n+from resources.lib.database.db_update import run_local_db_updates, run_shared_db_updates\n+\n+\n+def check_addon_upgrade():\n+ \"\"\"Check addon upgrade and perform necessary update operations\"\"\"\n+ # Upgrades that require user interaction or to be performed outside of the service\n+ addon_previous_ver = g.LOCAL_DB.get_value('addon_previous_version', None)\n+ addon_current_ver = g.VERSION\n+ if addon_current_ver != addon_previous_ver:\n+ _perform_addon_changes(addon_previous_ver, addon_current_ver)\n+\n+\n+def check_service_upgrade():\n+ \"\"\"Check service upgrade and perform necessary update operations\"\"\"\n+ # Upgrades to be performed before starting the service\n+ # Database upgrade\n+ local_db_version = g.LOCAL_DB.get_value('local_db_version', '0.1')\n+ shared_db_version = g.LOCAL_DB.get_value('shared_db_version', '0.1')\n+ _perform_local_db_changes(local_db_version)\n+ _perform_shared_db_changes(shared_db_version)\n+ # Perform service changes\n+ service_previous_ver = g.LOCAL_DB.get_value('service_previous_version', None)\n+ service_current_ver = g.VERSION\n+ if service_current_ver != service_previous_ver:\n+ _perform_service_changes(service_previous_ver, service_current_ver)\n+\n+\n+def _perform_addon_changes(previous_ver, current_ver):\n+ \"\"\"Perform actions for an version bump\"\"\"\n+ common.debug('Initialize addon upgrade operations, from version {} to {})'\n+ .format(previous_ver, current_ver))\n+ # <Do something here>\n+ # Always leave this to last - After the operations set current version\n+ g.LOCAL_DB.set_value('addon_previous_version', current_ver)\n+\n+\n+def _perform_service_changes(previous_ver, current_ver):\n+ \"\"\"Perform actions for an version bump\"\"\"\n+ common.debug('Initialize service upgrade operations, from version {} to {})'\n+ .format(previous_ver, current_ver))\n+ # <Do something here>\n+ # Always leave this to last - After the operations set current version\n+ g.LOCAL_DB.set_value('service_previous_version', current_ver)\n+\n+\n+def _perform_local_db_changes(db_version):\n+ \"\"\"Perform database actions for a db version change\"\"\"\n+ db_new_version = '0.1'\n+ if db_version != db_new_version:\n+ common.debug('Initialization of local database updates from version {} to {})'\n+ .format(db_version, db_new_version))\n+ run_local_db_updates(db_version, db_new_version)\n+ g.LOCAL_DB.set_value('local_db_version', db_new_version)\n+\n+\n+def _perform_shared_db_changes(db_version):\n+ \"\"\"Perform database actions for a db version change\"\"\"\n+ db_new_version = '0.1'\n+ if db_version != db_new_version:\n+ common.debug('Initialization of shared database updates from version {} to {})'\n+ .format(db_version, db_new_version))\n+ run_shared_db_updates(db_version, db_new_version)\n+ g.LOCAL_DB.set_value('shared_db_version', db_new_version)\n" }, { "change_type": "MODIFY", "old_path": "service.py", "new_path": "service.py", "diff": "@@ -22,6 +22,7 @@ g.init_globals(sys.argv)\nimport resources.lib.common as common\nimport resources.lib.services as services\nimport resources.lib.kodi.ui as ui\n+import resources.lib.upgrade_controller as upgrade_ctrl\nclass NetflixService(object):\n@@ -109,4 +110,5 @@ class NetflixService(object):\nif __name__ == '__main__':\n+ upgrade_ctrl.check_service_upgrade()\nNetflixService().run()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented version upgrade controller
106,046
28.07.2019 19:17:18
-7,200
ffb2e0fd5beccab5f7a0761d3f6829c47c91c212
Refactor credentials, profiles, session data to use db
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -59,12 +59,6 @@ def login():\nreturn True\[email protected]_execution(immediate=False)\n-def profiles():\n- \"\"\"Retrieve the list of available user profiles\"\"\"\n- return common.make_call('list_profiles')\n-\n-\[email protected]_execution(immediate=False)\[email protected]_output(g, cache.CACHE_COMMON, fixed_identifier='root_lists')\ndef root_lists():\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -9,24 +9,33 @@ from collections import OrderedDict\nimport resources.lib.common as common\n+from resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nfrom .paths import resolve_refs\nfrom .exceptions import (InvalidProfilesError, InvalidAuthURLError,\n- InvalidMembershipStatusError, WebsiteParsingError)\n+ WebsiteParsingError)\n-PAGE_ITEMS = [\n- 'models/userInfo/data/authURL',\n+PAGE_ITEMS_INFO = [\n+ 'models/userInfo/data/name',\n'models/userInfo/data/guid',\n'models/userInfo/data/countryOfSignup',\n'models/userInfo/data/membershipStatus',\n+ 'models/userInfo/data/isTestAccount',\n+ 'models/userInfo/data/deviceTypeId',\n+ 'models/userInfo/data/isAdultVerified',\n+ 'models/userInfo/data/pinEnabled',\n'models/serverDefs/data/BUILD_IDENTIFIER',\n- 'models/serverDefs/data/ICHNAEA_ROOT',\n- 'models/serverDefs/data/API_ROOT',\n- 'models/playerModel/data/config/ui/initParams/apiUrl',\n'models/esnGeneratorModel/data/esn',\n'models/memberContext/data/geo/preferredLocale'\n]\n+PAGE_ITEMS_API_URL = {\n+ 'auth_url': 'models/userInfo/data/authURL',\n+ # 'ichnaea_log': 'models/serverDefs/data/ICHNAEA_ROOT', can be for XSS attacks?\n+ 'api_endpoint_root_url': 'models/serverDefs/data/API_ROOT',\n+ 'api_endpoint_url': 'models/playerModel/data/config/ui/initParams/apiUrl'\n+}\n+\nJSON_REGEX = r'netflix\\.%s\\s*=\\s*(.*?);\\s*</script>'\nAVATAR_SUBPATH = ['images', 'byWidth', '320', 'value']\n@@ -38,47 +47,55 @@ def extract_session_data(content):\nthe session relevant data from the HTML page\n\"\"\"\ncommon.debug('Extracting session data...')\n- profiles, active_profile = extract_profiles(\n- extract_json(content, 'falcorCache'))\n- user_data = extract_userdata(content)\n-\n- if user_data.get('preferredLocale'):\n- g.PERSISTENT_STORAGE['locale_id'] = user_data.get('preferredLocale').get('id','en-US')\n-\n+ falcor_cache = extract_json(content, 'falcorCache')\n+ react_context = extract_json(content, 'reactContext')\n+ extract_profiles(falcor_cache)\n+ user_data = extract_userdata(react_context)\n+ api_data = extract_api_data(react_context)\n+ # Save only some info of the current profile from user data\n+ g.LOCAL_DB.set_value('build_identifier', user_data.get('BUILD_IDENTIFIER'), TABLE_SESSION)\n+ g.LOCAL_DB.set_value('esn', generate_esn(user_data), TABLE_SESSION)\n+ g.LOCAL_DB.set_value('locale_id', user_data.get('preferredLocale').get('id', 'en-US'))\n+ # Save api urls\n+ for key, path in api_data.items():\n+ g.LOCAL_DB.set_value(key, path, TABLE_SESSION)\nif user_data.get('membershipStatus') != 'CURRENT_MEMBER':\ncommon.debug(user_data)\n# Ignore this for now\n# raise InvalidMembershipStatusError(user_data.get('membershipStatus'))\n- return {\n- 'profiles': profiles,\n- 'active_profile': active_profile,\n- 'user_data': user_data,\n- 'esn': generate_esn(user_data),\n- 'api_data': _parse_api_data(user_data)\n- }\[email protected]_execution(immediate=True)\ndef extract_profiles(falkor_cache):\n\"\"\"Extract profile information from Netflix website\"\"\"\n- profiles = {}\n- active_profile = None\ntry:\nprofiles_list = OrderedDict(resolve_refs(falkor_cache['profilesList'], falkor_cache))\n+ _delete_non_existing_profiles(profiles_list)\n+ sort_order = 0\nfor guid, profile in profiles_list.items():\ncommon.debug('Parsing profile {}'.format(guid))\navatar_url = _get_avatar(falkor_cache, profile)\nprofile = profile['summary']['value']\n- profile['avatar'] = avatar_url\n- if profile.get('isActive'):\n- active_profile = guid\n- profiles[list(profiles_list.keys()).index(guid)] = (guid, profile)\n+ is_active = profile.pop('isActive')\n+ g.LOCAL_DB.set_profile(guid, is_active, sort_order)\n+ g.SHARED_DB.set_profile(guid, None, sort_order)\n+ for key, value in 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\nexcept Exception:\ncommon.error(traceback.format_exc())\ncommon.error('Falkor cache: {}'.format(falkor_cache))\nraise InvalidProfilesError\n- return profiles, active_profile\n+\n+def _delete_non_existing_profiles(profiles_list):\n+ list_guid = g.LOCAL_DB.get_guid_profiles()\n+ for guid in list_guid:\n+ if guid not in profiles_list.keys():\n+ common.debug('Deleting non-existing profile {}'.format(guid))\n+ g.LOCAL_DB.delete_profile(guid)\n+ g.SHARED_DB.delete_profile(guid)\ndef _get_avatar(falkor_cache, profile):\n@@ -92,33 +109,39 @@ def _get_avatar(falkor_cache, profile):\[email protected]_execution(immediate=True)\n-def extract_userdata(content):\n+def extract_userdata(react_context):\n\"\"\"Extract essential userdata from the reactContext of the webpage\"\"\"\ncommon.debug('Extracting userdata from webpage')\nuser_data = {}\n- react_context = extract_json(content, 'reactContext')\nfor path in ([path_item for path_item in path.split('/')]\n- for path in PAGE_ITEMS):\n+ for path in PAGE_ITEMS_INFO):\ntry:\n- user_data.update({path[-1]: common.get_path(path, react_context)})\n- common.debug('Extracted {}'.format(path))\n+ extracted_value = {path[-1]: common.get_path(path, react_context)}\n+ user_data.update(extracted_value)\n+ common.debug('Extracted {}'.format(extracted_value))\nexcept (AttributeError, KeyError):\ncommon.debug('Could not extract {}'.format(path))\n-\n- return assert_valid_auth_url(user_data)\n+ return user_data\n-def _parse_api_data(user_data):\n- return {api_item: user_data[api_item]\n- for api_item in (\n- item.split('/')[-1]\n- for item in PAGE_ITEMS\n- if ('serverDefs' in item) or ('initParams/apiUrl' in item))}\n+def extract_api_data(react_context):\n+ \"\"\"Extract api urls from the reactContext of the webpage\"\"\"\n+ common.debug('Extracting api urls from webpage')\n+ api_data = {}\n+ for key, value in PAGE_ITEMS_API_URL.items():\n+ path = [path_item for path_item in value.split('/')]\n+ try:\n+ extracted_value = {key: common.get_path(path, react_context)}\n+ api_data.update(extracted_value)\n+ common.debug('Extracted {}'.format(extracted_value))\n+ except (AttributeError, KeyError):\n+ common.debug('Could not extract {}'.format(path))\n+ return assert_valid_auth_url(api_data)\ndef assert_valid_auth_url(user_data):\n\"\"\"Raise an exception if user_data does not contain a valid authURL\"\"\"\n- if len(user_data.get('authURL', '')) != 42:\n+ if len(user_data.get('auth_url', '')) != 42:\nraise InvalidAuthURLError('authURL is invalid')\nreturn user_data\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/credentials.py", "new_path": "resources/lib/common/credentials.py", "diff": "@@ -5,7 +5,7 @@ from __future__ import unicode_literals\nfrom resources.lib.globals import g\nfrom resources.lib.api.exceptions import MissingCredentialsError\n-from .logging import debug\n+from .logging import debug, error\n__BLOCK_SIZE__ = 32\n__CRYPT_KEY__ = None\n@@ -79,31 +79,19 @@ def get_credentials():\nRetrieve stored account credentials.\n:return: The stored account credentials or an empty dict if none exist.\n\"\"\"\n- email = g.ADDON.getSetting('email')\n- password = g.ADDON.getSetting('password')\n+ email = g.LOCAL_DB.get_value('account_email')\n+ password = g.LOCAL_DB.get_value('account_password')\nverify_credentials(email and password)\ntry:\nreturn {\n'email': decrypt_credential(email),\n'password': decrypt_credential(password)\n}\n- except ValueError:\n- return migrate_credentials(email, password)\n-\n-\n-def migrate_credentials(encrypted_email, encrypted_password):\n- \"\"\"Try to decrypt stored credentials with the old unsafe secret and update\n- them to new safe format\"\"\"\n- unsafe_secret = 'UnsafeStaticSecret'.encode()\n- try:\n- email = decrypt_credential(encrypted_email, secret=unsafe_secret)\n- password = decrypt_credential(encrypted_password, secret=unsafe_secret)\n- except ValueError:\n+ except Exception:\n+ import traceback\n+ error(traceback.format_exc())\nraise MissingCredentialsError(\n'Existing credentials could not be decrypted')\n- set_credentials(email, password)\n- debug('Migrated old unsafely stored credentials to new safe format')\n- return {'email': email, 'password': password}\ndef set_credentials(email, password):\n@@ -112,18 +100,14 @@ def set_credentials(email, password):\nDoes nothing if either email or password are not supplied.\n\"\"\"\nif email and password:\n- g.SETTINGS_MONITOR_IGNORE = True\n- g.ADDON.setSetting('email', encrypt_credential(email))\n- g.ADDON.setSetting('password', encrypt_credential(password))\n- g.SETTINGS_MONITOR_IGNORE = False\n+ g.LOCAL_DB.set_value('account_email', encrypt_credential(email))\n+ g.LOCAL_DB.set_value('account_password', encrypt_credential(password))\ndef purge_credentials():\n\"\"\"Delete the stored credentials\"\"\"\n- g.SETTINGS_MONITOR_IGNORE = True\n- g.ADDON.setSetting('email', '')\n- g.ADDON.setSetting('password', '')\n- g.SETTINGS_MONITOR_IGNORE = False\n+ g.LOCAL_DB.set_value('account_email', None)\n+ g.LOCAL_DB.set_value('account_password', None)\ndef verify_credentials(credential):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/ipc.py", "new_path": "resources/lib/common/ipc.py", "diff": "@@ -71,7 +71,7 @@ def make_http_call(callname, data):\ndebug('Handling HTTP IPC call to {}'.format(callname))\n# don't use proxy for localhost\nurl = 'http://127.0.0.1:{}/{}'.format(\n- g.ADDON.getSetting('ns_service_port'), callname)\n+ g.LOCAL_DB.get_value('ns_service_port', 8001), callname)\nurllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler({})))\ntry:\nresult = json.loads(\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -39,9 +39,7 @@ def find_episode_metadata(videoid, metadata):\ndef select_port(service):\n\"\"\"Select a port for a server and store it in the settings\"\"\"\nport = select_unused_port()\n- g.SETTINGS_MONITOR_IGNORE = True\n- g.ADDON.setSetting('{}_service_port'.format(service.lower()), str(port))\n- g.SETTINGS_MONITOR_IGNORE = False\n+ g.LOCAL_DB.set_value('{}_service_port'.format(service.lower()), port)\ninfo('[{}] Picked Port: {}'.format(service, port))\nreturn port\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -358,20 +358,6 @@ class GlobalVariables(object):\nself.CACHE.add(cache.CACHE_LIBRARY, 'library', self._library,\nttl=cache.TTL_INFINITE, to_disk=True)\n- def get_esn(self):\n- \"\"\"Get the ESN from settings\"\"\"\n- return self.ADDON.getSetting('esn')\n-\n- def set_esn(self, esn):\n- \"\"\"\n- Set the ESN in settings if it hasn't been set yet.\n- Return True if the new ESN has been set, False otherwise\n- \"\"\"\n- if not self.get_esn() and esn:\n- self.ADDON.setSetting('esn', esn)\n- return True\n- return False\n-\ndef get_edge_esn(self):\n\"\"\"Get a previously generated edge ESN from the settings or generate\na new one if none exists\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/listings.py", "new_path": "resources/lib/kodi/listings.py", "diff": "@@ -66,30 +66,34 @@ def _activate_view(partial_setting_id):\n@custom_viewmode(g.VIEW_PROFILES)\[email protected]_execution(immediate=False)\n-def build_profiles_listing(profiles):\n+def build_profiles_listing():\n\"\"\"Builds the profiles list Kodi screen\"\"\"\ntry:\nfrom HTMLParser import HTMLParser\nexcept ImportError:\nfrom html.parser import HTMLParser\nhtml_parser = HTMLParser()\n+ directory_items = []\n+ active_guid_profile = g.LOCAL_DB.get_active_profile_guid()\n+ for guid in g.LOCAL_DB.get_guid_profiles():\n+ directory_items.append(_create_profile_item(guid,\n+ (guid == active_guid_profile),\n+ html_parser))\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\n- directory_items = []\n- for index, (guid, profile) in sorted(profiles.items()):\n- directory_items.append(_create_profile_item(guid, profile, html_parser))\nfinalize_directory(directory_items, g.CONTENT_IMAGES)\n-def _create_profile_item(profile_guid, profile, html_parser):\n+def _create_profile_item(profile_guid, is_active, html_parser):\n\"\"\"Create a tuple that can be added to a Kodi directory that represents\na profile as listed in the profiles listing\"\"\"\n- profile_name = profile.get('profileName', '')\n+ profile_name = g.LOCAL_DB.get_profile_config('profileName', '', guid=profile_guid)\nunescaped_profile_name = html_parser.unescape(profile_name)\nenc_profile_name = profile_name.encode('utf-8')\nlist_item = list_item_skeleton(\n- label=unescaped_profile_name, icon=profile.get('avatar'))\n- list_item.select(profile.get('isActive', False))\n+ label=unescaped_profile_name,\n+ icon=g.LOCAL_DB.get_profile_config('avatar', '', guid=profile_guid))\n+ list_item.select(is_active)\nautologin_url = common.build_url(\npathitems=['save_autologin', profile_guid],\nparams={'autologin_user': enc_profile_name},\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -47,7 +47,7 @@ class DirectoryBuilder(object):\n\"\"\"Show profiles listing\"\"\"\n# pylint: disable=unused-argument\ncommon.debug('Showing profiles listing')\n- listings.build_profiles_listing(api.profiles())\n+ listings.build_profiles_listing()\n_handle_endofdirectory(False)\[email protected]_execution(immediate=False)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -89,7 +89,7 @@ def get_inputstream_listitem(videoid):\n\"\"\"Return a listitem that has all inputstream relevant properties set\nfor playback of the given video_id\"\"\"\nservice_url = SERVICE_URL_FORMAT.format(\n- port=g.ADDON.getSetting('msl_service_port'))\n+ port=g.LOCAL_DB.get_value('msl_service_port', 8000))\nmanifest_path = MANIFEST_PATH_FORMAT.format(videoid=videoid.value)\nlist_item = xbmcgui.ListItem(path=service_url + manifest_path,\noffscreen=True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -15,6 +15,7 @@ from functools import wraps\nimport requests\nimport xbmcaddon\n+from resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n@@ -79,7 +80,7 @@ class MSLHandler(object):\ndef perform_key_handshake(self, data=None):\n\"\"\"Perform a key handshake and initialize crypto keys\"\"\"\n# pylint: disable=unused-argument\n- esn = data or g.get_esn()\n+ esn = data or g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\nif not esn:\ncommon.info('Cannot perform key handshake, missing ESN')\nreturn False\n@@ -106,7 +107,7 @@ class MSLHandler(object):\n:param viewable_id: The id of of the viewable\n:return: MPD XML Manifest or False if no success\n\"\"\"\n- manifest = self._load_manifest(viewable_id, g.get_esn())\n+ manifest = self._load_manifest(viewable_id, g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\n# Disable 1080p Unlock for now, as it is broken due to Netflix changes\n# if (g.ADDON.getSettingBool('enable_1080p_unlock') and\n# not g.ADDON.getSettingBool('enable_vp9_profiles') and\n@@ -159,7 +160,7 @@ class MSLHandler(object):\n'url': '/manifest',\n'id': id,\n'esn': esn,\n- 'languages': [g.PERSISTENT_STORAGE['locale_id']],\n+ 'languages': [g.LOCAL_DB.get_value('locale_id')],\n'uiVersion': 'shakti-v5bca5cd3',\n'clientVersion': '6.0013.315.051',\n'params': {\n@@ -214,8 +215,8 @@ class MSLHandler(object):\n'version': 2,\n'url': self.last_license_url,\n'id': id,\n- 'esn': g.get_esn(),\n- 'languages': [g.PERSISTENT_STORAGE['locale_id']],\n+ 'esn': g.LOCAL_DB.get_value('esn', table=TABLE_SESSION),\n+ 'languages': [g.LOCAL_DB.get_value('locale_id')],\n'uiVersion': 'shakti-v5bca5cd3',\n'clientVersion': '6.0013.315.051',\n'params': [{\n@@ -228,7 +229,8 @@ class MSLHandler(object):\n}\nresponse = self._chunked_request(ENDPOINTS['license'],\n- license_request_data, g.get_esn())\n+ license_request_data,\n+ g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\nreturn response[0]['licenseResponseBase64']\[email protected]_execution(immediate=True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/request_builder.py", "new_path": "resources/lib/services/msl/request_builder.py", "diff": "@@ -73,7 +73,7 @@ class MSLRequestBuilder(object):\n'handshake': is_handshake,\n'nonreplayable': False,\n'capabilities': {\n- 'languages': [g.PERSISTENT_STORAGE.get('locale_id', 'en-US')],\n+ 'languages': [g.LOCAL_DB.get_value('locale_id')],\n'compressionalgos': [compression] if compression else []\n},\n'recipient': 'Netflix',\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -11,6 +11,7 @@ import requests\nimport xbmc\n+from resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.common.cookies as cookies\n@@ -71,11 +72,9 @@ class NetflixSession(object):\n\"\"\"Use SSL verification when performing requests\"\"\"\ndef __init__(self):\n- self._session_data = None\nself.slots = [\nself.login,\nself.logout,\n- self.list_profiles,\nself.activate_profile,\nself.path_request,\nself.perpetual_path_request,\n@@ -95,29 +94,16 @@ class NetflixSession(object):\nreturn urlsafe_b64encode(\ncommon.get_credentials().get('email', 'NoMail'))\n- @property\n- def session_data(self):\n- \"\"\"The session data extracted from the Netflix webpage.\n- Contains profiles, active_profile, root_lolomo, user_data, esn\n- and api_data\"\"\"\n- return self._session_data\n-\n- @session_data.setter\n- def session_data(self, new_session_data):\n- self._session_data = new_session_data\n+ def update_session_data(self):\nself.session.headers.update(\n- {'x-netflix.request.client.user.guid':\n- new_session_data['active_profile']})\n+ {'x-netflix.request.client.user.guid': g.LOCAL_DB.get_active_profile_guid()})\ncookies.save(self.account_hash, self.session.cookies)\n- _update_esn(self.session_data['esn'])\n+ _update_esn(g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\n@property\ndef auth_url(self):\n- \"\"\"Valid authURL. Raises InvalidAuthURLError if it isn't known.\"\"\"\n- try:\n- return self.session_data['user_data']['authURL']\n- except (AttributeError, KeyError) as exc:\n- raise website.InvalidAuthURLError(exc)\n+ \"\"\"Return authentication url\"\"\"\n+ return g.LOCAL_DB.get_value('auth_url', table=TABLE_SESSION)\[email protected]_execution(immediate=True)\ndef _init_session(self):\n@@ -127,9 +113,6 @@ class NetflixSession(object):\ncommon.info('Session closed')\nexcept AttributeError:\npass\n- # Do not use property setter for session_data because self.session may\n- # be None at this point\n- self._session_data = {}\nself.session = requests.session()\nself.session.headers.update({\n'User-Agent': common.get_user_agent(),\n@@ -152,7 +135,7 @@ class NetflixSession(object):\[email protected]_execution(immediate=True)\ndef _is_logged_in(self):\n- \"\"\"Check if the user is logged in\"\"\"\n+ \"\"\"Check if the user is logged in and if so refresh session data\"\"\"\nreturn (self.session.cookies or\n(self._load_cookies() and self._refresh_session_data()))\n@@ -162,8 +145,8 @@ class NetflixSession(object):\n# pylint: disable=broad-except\ntry:\n# If we can get session data, cookies are still valid\n- self.session_data = website.extract_session_data(\n- self._get('profiles'))\n+ website.extract_session_data(self._get('profiles'))\n+ self.update_session_data()\nexcept Exception:\ncommon.debug(traceback.format_exc())\ncommon.info('Failed to refresh session data, login expired')\n@@ -195,13 +178,14 @@ class NetflixSession(object):\ndef _login(self):\n\"\"\"Perform account login\"\"\"\ntry:\n- auth_url = website.extract_userdata(\n- self._get('profiles'))['authURL']\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+ auth_url = website.extract_api_data(react_context)['auth_url']\ncommon.debug('Logging in...')\nlogin_response = self._post(\n'login',\ndata=_login_payload(common.get_credentials(), auth_url))\n- session_data = website.extract_session_data(login_response)\n+ website.extract_session_data(login_response)\nexcept Exception:\ncommon.debug(traceback.format_exc())\nself.session.cookies.clear()\n@@ -209,7 +193,7 @@ class NetflixSession(object):\ncommon.info('Login successful')\nui.show_notification(common.get_local_string(30109))\n- self.session_data = session_data\n+ self.update_session_data()\[email protected]_return_call\[email protected]_execution(immediate=True)\n@@ -225,22 +209,13 @@ class NetflixSession(object):\nxbmc.executebuiltin('XBMC.Container.Update(path,replace)') # Clean path history\nxbmc.executebuiltin('XBMC.ActivateWindow(Home)')\n- @common.addonsignals_return_call\n- @needs_login\n- def list_profiles(self):\n- \"\"\"Retrieve a list of all profiles in the user's account\"\"\"\n- try:\n- return self.session_data['profiles']\n- except (AttributeError, KeyError) as exc:\n- raise website.InvalidProfilesError(exc)\n-\[email protected]_return_call\n@needs_login\[email protected]_execution(immediate=True)\ndef activate_profile(self, guid):\n\"\"\"Set the profile identified by guid as active\"\"\"\ncommon.debug('Activating profile {}'.format(guid))\n- if guid == self.session_data['active_profile']:\n+ if guid == g.LOCAL_DB.get_active_profile_guid():\ncommon.debug('Profile {} is already active'.format(guid))\nreturn False\nself._get(\n@@ -250,7 +225,9 @@ class NetflixSession(object):\n'switchProfileGuid': guid,\n'_': int(time.time()),\n'authURL': self.auth_url})\n- self._refresh_session_data()\n+ g.LOCAL_DB.switch_active_profile(guid)\n+ self.update_session_data()\n+ # self._refresh_session_data()\ncommon.debug('Successfully activated profile {}'.format(guid))\nreturn True\n@@ -292,7 +269,8 @@ class NetflixSession(object):\nif len(path_response) == 0:\nbreak\nif not common.check_path_exists(length_args, path_response):\n- # It may happen that the number of items to be received is equal to the number of the response_size\n+ # It may happen that the number of items to be received\n+ # is equal to the number of the response_size\n# so a second round will be performed, which will return an empty list\nbreak\ncommon.merge_dicts(path_response, merged_response)\n@@ -301,7 +279,8 @@ class NetflixSession(object):\nrange_start += response_size\nif n_req == (number_of_requests - 1):\nmerged_response['_perpetual_range_selector'] = {'next_start': range_start}\n- common.debug('{} has other elements, added _perpetual_range_selector item'.format(response_type))\n+ common.debug('{} has other elements, added _perpetual_range_selector item'\n+ .format(response_type))\nelse:\nrange_end = range_start + request_size\nelse:\n@@ -376,7 +355,7 @@ class NetflixSession(object):\nreturn self._request(method, component, None, **kwargs)\ndef _request(self, method, component, session_refreshed, **kwargs):\n- url = (_api_url(component, self.session_data['api_data'])\n+ url = (_api_url(component)\nif URLS[component]['is_api_call']\nelse _document_url(component))\ncommon.debug(\n@@ -457,18 +436,29 @@ def _document_url(component):\nreturn BASE_URL + URLS[component]['endpoint']\n-def _api_url(component, api_data):\n+def _api_url(component):\nreturn '{baseurl}{componenturl}'.format(\n- baseurl=api_data['apiUrl'],\n+ baseurl=g.LOCAL_DB.get_value('api_endpoint_url', table=TABLE_SESSION),\ncomponenturl=URLS[component]['endpoint'])\ndef _update_esn(esn):\n\"\"\"Return True if the esn has changed on Session initialization\"\"\"\n- if g.set_esn(esn):\n+ if _set_esn(esn):\ncommon.send_signal(signal=common.Signals.ESN_CHANGED, data=esn)\n+def _set_esn(esn):\n+ \"\"\"\n+ Set the ESN in settings if it hasn't been set yet.\n+ Return True if the new ESN has been set, False otherwise\n+ \"\"\"\n+ if not g.LOCAL_DB.get_value('esn', table=TABLE_SESSION) and esn:\n+ g.LOCAL_DB.set_value('esn', esn, table=TABLE_SESSION)\n+ return True\n+ return False\n+\n+\ndef _raise_api_error(decoded_response):\nif decoded_response.get('status', 'success') == 'error':\nraise APIError(decoded_response.get('message'))\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<settings>\n<category label=\"30014\"><!--Account-->\n- <setting id=\"email\" type=\"text\" visible=\"false\" default=\"\"/>\n- <setting id=\"password\" type=\"text\" visible=\"false\" default=\"\"/>\n<setting id=\"logout\" type=\"action\" label=\"30017\" action=\"RunPlugin(plugin://plugin.video.netflix/action/logout/)\" option=\"close\"/>\n<setting id=\"adultpin_enable\" type=\"action\" label=\"30062\" default=\"False\" action=\"RunPlugin(plugin://plugin.video.netflix/action/toggle_adult_pin/)\" option=\"close\"/>\n<setting label=\"30053\" type=\"lsep\"/>\n<setting id=\"esn\" type=\"text\" label=\"30034\" value=\"\" default=\"\"/>\n<setting id=\"hidden_esn\" visible=\"false\" value=\"\" />\n<setting id=\"tracking_id\" value=\"\" visible=\"false\"/> <!-- Not implemented -->\n- <setting id=\"msl_service_port\" value=\"8000\" visible=\"false\"/>\n- <setting id=\"ns_service_port\" value=\"8001\" visible=\"false\"/>\n<setting id=\"show_update_db\" type=\"bool\" default=\"false\" visible=\"false\"/>\n<setting label=\"30117\" type=\"lsep\"/>\n<setting id=\"cache_ttl\" type=\"slider\" option=\"int\" range=\"0,10,525600\" label=\"30084\" default=\"10\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor credentials, profiles, session data to use db
106,046
28.07.2019 02:44:05
-7,200
5c922dbbaa91b7743b969916000d2100258c3b37
Removed menu items no longer used
[ { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"purge_library\" type=\"action\" label=\"30125\" action=\"RunPlugin(plugin://plugin.video.netflix/library/purge/)\"/>\n<setting id=\"migrate_library\" type=\"action\" label=\"30140\" action=\"RunPlugin(plugin://plugin.video.netflix/library/migrate/)\"/>\n<setting id=\"customexportname\" type=\"bool\" label=\"No longer in use\" default=\"true\" visible=\"false\"/>\n- <setting id=\"invalidate_cache_on_mylist_modify\" type=\"bool\" label=\"No longer in use\" default=\"true\" visible=\"false\"/>\n<setting label=\"30065\" type=\"lsep\"/><!--Auto-Update-->\n<setting id=\"auto_update\" type=\"enum\" label=\"30064\" lvalues=\"30066|30067|30068|30069|30070\" default=\"0\"/>\n<setting id=\"update_time\" type=\"time\" label=\"30071\" visible=\"gt(-1,0)\" default=\"00:00\" subsetting=\"true\"/>\n<category label=\"30023\"><!--Expert-->\n<setting label=\"30115\" type=\"lsep\"/>\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_1080p_unlock\" type=\"bool\" label=\"30136\" default=\"false\" visible=\"false\"/> <!-- Deprecated (broken) -->\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_timing\" type=\"bool\" label=\"30134\" 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\"/>\n- <setting id=\"enable_tracking\" type=\"bool\" label=\"30032\" default=\"true\" visible=\"false\"/> <!-- Not implemented -->\n<setting id=\"esn\" type=\"text\" label=\"30034\" value=\"\" default=\"\"/>\n- <setting id=\"hidden_esn\" visible=\"false\" value=\"\" />\n- <setting id=\"tracking_id\" value=\"\" visible=\"false\"/> <!-- Not implemented -->\n- <setting id=\"show_update_db\" type=\"bool\" default=\"false\" visible=\"false\"/>\n<setting label=\"30117\" type=\"lsep\"/>\n<setting id=\"cache_ttl\" type=\"slider\" option=\"int\" range=\"0,10,525600\" label=\"30084\" default=\"10\"/>\n<setting id=\"cache_metadata_ttl\" type=\"slider\" option=\"int\" range=\"0,1,365\" label=\"30085\" default=\"30\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Removed menu items no longer used
106,046
28.07.2019 18:04:28
-7,200
7d80a7e2316333e76705fa425be43bd4078b5ea4
Added remove_html_tags to utils
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -296,6 +296,12 @@ def convert_seconds_to_hms_str(time):\nreturn '{:02d}:{:02d}:{:02d}'.format(h, m, s)\n+def remove_html_tags(raw_html):\n+ h = re.compile('<.*?>')\n+ text = re.sub(h, '', raw_html)\n+ return text\n+\n+\ndef get_system_platform():\nplatform = \"unknown\"\nif xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.android'):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added remove_html_tags to utils
106,046
28.07.2019 18:13:44
-7,200
0b5176d0eed2789614b732d73136639765b5e1fa
Implemented management of login errors This include also a basic validator used when addon starts this allows to manage credential verification even when we do not using a method within of nfsession
[ { "change_type": "MODIFY", "old_path": "addon.py", "new_path": "addon.py", "diff": "@@ -29,7 +29,7 @@ import resources.lib.navigation.player as player\nimport resources.lib.navigation.actions as actions\nimport resources.lib.navigation.library as library\n-from resources.lib.api.exceptions import NotLoggedInError\n+from resources.lib.api.exceptions import (NotLoggedInError, MissingCredentialsError)\nNAV_HANDLERS = {\ng.MODE_DIRECTORY: directory.DirectoryBuilder,\n@@ -50,11 +50,12 @@ def lazy_login(func):\nreturn func(*args, **kwargs)\nexcept NotLoggedInError:\ncommon.debug('Tried to perform an action without being logged in')\n- if api.login():\n+ try:\n+ api.login()\ncommon.debug('Now that we\\'re logged in, let\\'s try again')\nreturn func(*args, **kwargs)\n- else:\n- common.debug('Login failed or canceled, abort initial action')\n+ except MissingCredentialsError:\n+ # Aborted from user or left an empty field\nxbmcplugin.endOfDirectory(handle=g.PLUGIN_HANDLE,\nsucceeded=False)\nreturn lazy_login_wrapper\n@@ -78,6 +79,21 @@ def route(pathitems):\ng.REQUEST_PARAMS)\n+def 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+ # only works in conjunction with nfsession and also performs other checks\n+ if not common.check_credentials():\n+ try:\n+ if not api.login():\n+ # Wrong login try again\n+ return check_valid_credentials()\n+ except MissingCredentialsError:\n+ # Aborted from user or left an empty field\n+ return False\n+ return True\n+\n+\nif __name__ == '__main__':\n# pylint: disable=broad-except\n# Initialize variables in common module scope\n@@ -89,6 +105,7 @@ if __name__ == '__main__':\ntry:\nupgrade_ctrl.check_addon_upgrade()\ng.initial_addon_configuration()\n+ if check_valid_credentials():\nroute(filter(None, g.PATH.split('/')))\nsuccess = True\nexcept common.BackendNotReady:\n" }, { "change_type": "MODIFY", "old_path": "resources/language/resource.language.de_de/strings.po", "new_path": "resources/language/resource.language.de_de/strings.po", "diff": "@@ -445,8 +445,8 @@ msgid \"Background services started\"\nmsgstr \"Hintergrunddienste gestartet\"\nmsgctxt \"#30112\"\n-msgid \"You need to be logged in to use this function\"\n-msgstr \"Du musst eingeloggt sein um diese Funktion zu benutzen\"\n+msgid \"You need to be logged in to use Netflix\"\n+msgstr \"\"\nmsgctxt \"#30113\"\nmsgid \"Logout successful\"\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": "@@ -465,7 +465,7 @@ msgid \"There is no contents\"\nmsgstr \"\"\nmsgctxt \"#30112\"\n-msgid \"You need to be logged in to use this function\"\n+msgid \"You need to be logged in to use Netflix\"\nmsgstr \"\"\nmsgctxt \"#30113\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/exceptions.py", "new_path": "resources/lib/api/exceptions.py", "diff": "@@ -44,6 +44,11 @@ class LoginFailedError(Exception):\npass\n+class LoginValidateError(Exception):\n+ \"\"\"The login validate has generated an error\"\"\"\n+ pass\n+\n+\nclass NotLoggedInError(Exception):\n\"\"\"The requested operation requires a valid and active login, which\nis not present\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -51,12 +51,15 @@ def login():\ng.CACHE.invalidate()\ntry:\nui.ask_credentials()\n- common.make_call('login')\n- except (MissingCredentialsError, LoginFailedError) as exc:\n- msg = 30009 if isinstance(exc, LoginFailedError) else 30112\n- ui.show_notification(common.get_local_string(msg))\n+ if not common.make_call('login'):\n+ # Login not validated\n+ # ui.show_notification(common.get_local_string(30009))\nreturn False\nreturn True\n+ except MissingCredentialsError:\n+ # Aborted from user or leave an empty field\n+ ui.show_notification(common.get_local_string(30112))\n+ raise MissingCredentialsError\[email protected]_execution(immediate=False)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -12,8 +12,8 @@ import resources.lib.common as common\nfrom resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nfrom .paths import resolve_refs\n-from .exceptions import (InvalidProfilesError, InvalidAuthURLError,\n- WebsiteParsingError)\n+from .exceptions import (InvalidProfilesError, InvalidAuthURLError, InvalidMembershipStatusError,\n+ WebsiteParsingError, LoginValidateError)\nPAGE_ITEMS_INFO = [\n'models/userInfo/data/name',\n@@ -36,6 +36,9 @@ PAGE_ITEMS_API_URL = {\n'api_endpoint_url': 'models/playerModel/data/config/ui/initParams/apiUrl'\n}\n+PAGE_ITEM_ERROR_CODE = 'models/flow/data/fields/errorCode/value'\n+PAGE_ITEM_ERROR_CODE_LIST = 'models\\\\i18nStrings\\\\data\\\\login/login'\n+\nJSON_REGEX = r'netflix\\.%s\\s*=\\s*(.*?);\\s*</script>'\nAVATAR_SUBPATH = ['images', 'byWidth', '320', 'value']\n@@ -146,6 +149,32 @@ def assert_valid_auth_url(user_data):\nreturn user_data\n+def validate_login(content):\n+ react_context = extract_json(content, 'reactContext')\n+ path_code_list = [path_item for path_item in PAGE_ITEM_ERROR_CODE_LIST.split('\\\\')]\n+ path_error_code = [path_item for path_item in PAGE_ITEM_ERROR_CODE.split('/')]\n+ if common.check_path_exists(path_error_code, react_context):\n+ # If the path exists, a login error occurs\n+ try:\n+ error_code_list = common.get_path(path_code_list, react_context)\n+ error_code = common.get_path(path_error_code, react_context)\n+ common.debug('Login not valid, error code {}'.format(error_code))\n+ error_description = common.get_local_string(30102) + error_code\n+ if error_code in error_code_list:\n+ error_description = error_code_list[error_code]\n+ if 'email_' + error_code in error_code_list:\n+ error_description = error_code_list['email_' + error_code]\n+ if 'login_' + error_code in error_code_list:\n+ error_description = error_code_list['login_' + error_code]\n+ return common.remove_html_tags(error_description)\n+ except (AttributeError, KeyError):\n+ common.error(\n+ 'Something is wrong in PAGE_ITEM_ERROR_CODE or PAGE_ITEM_ERROR_CODE_LIST paths.'\n+ 'react_context data may have changed.')\n+ raise LoginValidateError\n+ return None\n+\n+\ndef generate_esn(user_data):\n\"\"\"Generate an ESN if on android or return the one from user_data\"\"\"\nimport subprocess\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/credentials.py", "new_path": "resources/lib/common/credentials.py", "diff": "@@ -94,6 +94,23 @@ def get_credentials():\n'Existing credentials could not be decrypted')\n+# noinspection PyBroadException\n+def check_credentials():\n+ \"\"\"\n+ Check if account credentials exists and can be decrypted.\n+ \"\"\"\n+ email = g.LOCAL_DB.get_value('account_email')\n+ password = g.LOCAL_DB.get_value('account_password')\n+ try:\n+ verify_credentials(email and password)\n+ decrypt_credential(email)\n+ decrypt_credential(password)\n+ return True\n+ except Exception:\n+ pass\n+ return False\n+\n+\ndef set_credentials(email, password):\n\"\"\"\nEncrypt account credentials and save them to the settings.\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -19,7 +19,7 @@ import resources.lib.api.website as website\nimport resources.lib.api.paths as apipaths\nimport resources.lib.kodi.ui as ui\n-from resources.lib.api.exceptions import (NotLoggedInError, LoginFailedError,\n+from resources.lib.api.exceptions import (NotLoggedInError, LoginFailedError, LoginValidateError,\nAPIError, MissingCredentialsError)\nBASE_URL = 'https://www.netflix.com'\n@@ -172,10 +172,10 @@ class NetflixSession(object):\[email protected]_return_call\ndef login(self):\n\"\"\"AddonSignals interface for login function\"\"\"\n- self._login()\n+ return self._login(modal_error_message=True)\[email protected]_execution(immediate=True)\n- def _login(self):\n+ def _login(self, modal_error_message=False):\n\"\"\"Perform account login\"\"\"\ntry:\n# First we get the authentication url without logging in, required for login API call\n@@ -185,15 +185,25 @@ class NetflixSession(object):\nlogin_response = self._post(\n'login',\ndata=_login_payload(common.get_credentials(), auth_url))\n+ validate_msg = website.validate_login(login_response)\n+ if validate_msg:\n+ self.session.cookies.clear()\n+ common.purge_credentials()\n+ if modal_error_message:\n+ ui.show_ok_dialog(common.get_local_string(30008),\n+ validate_msg)\n+ else:\n+ ui.show_notification(common.get_local_string(30009))\n+ return False\nwebsite.extract_session_data(login_response)\n- except Exception:\n- common.debug(traceback.format_exc())\n+ except Exception as exc:\n+ common.error(traceback.format_exc())\nself.session.cookies.clear()\n- raise LoginFailedError\n-\n+ raise exc\ncommon.info('Login successful')\nui.show_notification(common.get_local_string(30109))\nself.update_session_data()\n+ return True\[email protected]_return_call\[email protected]_execution(immediate=True)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented management of login errors This include also a basic validator used when addon starts this allows to manage credential verification even when we do not using a method within of nfsession
106,046
28.07.2019 18:48:34
-7,200
f139de8455b2163c99c5b4219494f2fbcf7b2c45
Fixed logout reset problems After many requests, finally fixed, now users will be able to re-enter their credentials after logout, or exit. Once out, the account profiles will no longer be shown (which was the main problem before)
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -39,11 +39,9 @@ def activate_profile(profile_id):\ndef logout():\n\"\"\"Logout of the current account\"\"\"\n- try:\n- common.make_call('logout')\n+ url = common.build_url(['root'], mode=g.MODE_DIRECTORY)\n+ common.make_call('logout', url)\ng.CACHE.invalidate()\n- except (MissingCredentialsError, NotLoggedInError):\n- ui.show_notification(common.get_local_string(30112))\ndef login():\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -48,7 +48,7 @@ class DirectoryBuilder(object):\n# pylint: disable=unused-argument\ncommon.debug('Showing profiles listing')\nlistings.build_profiles_listing()\n- _handle_endofdirectory(False)\n+ _handle_endofdirectory(False, False)\[email protected]_execution(immediate=False)\ndef home(self, pathitems=None, cache_to_disc=True):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -207,7 +207,7 @@ class NetflixSession(object):\[email protected]_return_call\[email protected]_execution(immediate=True)\n- def logout(self):\n+ def logout(self, url):\n\"\"\"Logout of the current account and reset the session\"\"\"\ncommon.debug('Logging out of current account')\ncookies.delete(self.account_hash)\n@@ -217,7 +217,7 @@ class NetflixSession(object):\nui.show_notification(common.get_local_string(30113))\nself._init_session()\nxbmc.executebuiltin('XBMC.Container.Update(path,replace)') # Clean path history\n- xbmc.executebuiltin('XBMC.ActivateWindow(Home)')\n+ xbmc.executebuiltin('Container.Update({})'.format(url)) # Open root page\[email protected]_return_call\n@needs_login\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed logout reset problems After many requests, finally fixed, now users will be able to re-enter their credentials after logout, or exit. Once out, the account profiles will no longer be shown (which was the main problem before)
106,046
01.08.2019 21:01:21
-7,200
b5d1c42dfc9e159401608f3f7324d3d78da41846
Refactor menu_data to use db Also removed profile_have_mylist_menu in its place is used isKids value of the current profile
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "@@ -17,6 +17,7 @@ SHARED_DB_FILENAME = 'nf_shared.sqlite3'\n# Table mapping: ( Table name, [ columns ] )\nTABLE_APP_CONF = ('AppConfig', ['Name', 'Value'])\nTABLE_SESSION = ('Session', ['Name', 'Value'])\n+TABLE_MENU_DATA = ('MenuData', ['ContextId', 'Value'])\nTABLE_SHARED_APP_CONF = ('SharedAppConfig', ['Name', 'Value'])\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -326,22 +326,9 @@ class GlobalVariables(object):\nself.PERSISTENT_STORAGE['show_menus'] = {}\nif not self.PERSISTENT_STORAGE.get('menu_sortorder'):\nself.PERSISTENT_STORAGE['menu_sortorder'] = {}\n- if not self.PERSISTENT_STORAGE.get('menu_titles'):\n- self.PERSISTENT_STORAGE['menu_titles'] = {}\nif not self.PERSISTENT_STORAGE.get('sub_menus'):\nself.PERSISTENT_STORAGE['sub_menus'] = {}\n- def get_menu_title(self, menu_key, fallback_title=''):\n- \"\"\"\n- Get the menu title from persistent storage,\n- in some situations, such as deleting the persistent file,\n- or context_id/menu_id changed due to netflix changes or addon menu code changes..\n- the list or key may no longer be present\n- \"\"\"\n- if not g.PERSISTENT_STORAGE.get('menu_titles'):\n- return fallback_title\n- return g.PERSISTENT_STORAGE['menu_titles'].get(menu_key, fallback_title)\n-\ndef library(self):\n\"\"\"Get the current library instance\"\"\"\n# pylint: disable=global-statement, attribute-defined-outside-init\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/context_menu.py", "new_path": "resources/lib/kodi/context_menu.py", "diff": "@@ -55,7 +55,7 @@ def generate_context_menu_items(videoid):\nitems.insert(0, _ctx_item('trailer', videoid))\nif videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.SHOW] \\\n- and g.PERSISTENT_STORAGE.get('profile_have_mylist_menu', False):\n+ and not g.LOCAL_DB.get_profile_config('isKids', False):\nlist_action = ('remove_from_list'\nif videoid.value in api.mylist_items()\nelse 'add_to_list')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/listings.py", "new_path": "resources/lib/kodi/listings.py", "diff": "@@ -10,6 +10,7 @@ import xbmc\nimport xbmcgui\nimport xbmcplugin\n+from resources.lib.database.db_utils import (TABLE_MENU_DATA)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n@@ -114,21 +115,22 @@ def build_main_menu_listing(lolomo):\nBuilds the video lists (my list, continue watching, etc.) Kodi screen\n\"\"\"\ndirectory_items = []\n- mylist_menu_exists = False\nfor menu_id, data in g.MAIN_MENU_ITEMS.iteritems():\nshow_in_menu = g.ADDON.getSettingBool('_'.join(('show_menu', menu_id)))\nif show_in_menu:\n+ menu_title = 'Missing menu title'\nif data['lolomo_known']:\n- for list_id, user_list in lolomo.lists_by_context(data['lolomo_contexts'], break_on_first=True):\n- directory_items.append(_create_videolist_item(list_id, user_list, data, static_lists=True))\n- g.PERSISTENT_STORAGE['menu_titles'][menu_id] = user_list['displayName']\n- if \"queue\" in data['lolomo_contexts']:\n- mylist_menu_exists = True\n+ for list_id, user_list in lolomo.lists_by_context(data['lolomo_contexts'],\n+ break_on_first=True):\n+ directory_items.append(_create_videolist_item(list_id,\n+ user_list,\n+ data,\n+ static_lists=True))\n+ menu_title = user_list['displayName']\nelse:\n- menu_title = common.get_local_string(data['label_id']) \\\n- if data['label_id'] is not None else 'Missing menu title'\n- g.PERSISTENT_STORAGE['menu_titles'][menu_id] = menu_title\n+ if data['label_id']:\n+ menu_title = common.get_local_string(data['label_id'])\nmenu_description = common.get_local_string(data['description_id']) \\\nif data['description_id'] is not None else ''\ndirectory_items.append(\n@@ -137,8 +139,7 @@ def build_main_menu_listing(lolomo):\nicon=data['icon'],\ndescription=menu_description),\nTrue))\n- # g.PERSISTENT_STORAGE.commit() performed with the next call to PERSISTENT_STORAGE setitem\n- g.PERSISTENT_STORAGE['profile_have_mylist_menu'] = mylist_menu_exists\n+ g.LOCAL_DB.set_value(menu_id, {'title': menu_title}, TABLE_MENU_DATA)\nfinalize_directory(directory_items, g.CONTENT_FOLDER, title=common.get_local_string(30097))\n@@ -167,13 +168,18 @@ def build_lolomo_listing(lolomo, menu_data, force_videolistbyid=False, exclude_l\nsub_menu_data['lolomo_contexts'] = None\nsub_menu_data['content_type'] = g.CONTENT_SHOW\nsub_menu_data['force_videolistbyid'] = force_videolistbyid\n- sub_menu_data['main_menu'] = menu_data['main_menu'] if menu_data.get('main_menu') else menu_data.copy()\n- g.PERSISTENT_STORAGE['sub_menus'][sel_video_list_id] = sub_menu_data\n- g.PERSISTENT_STORAGE['menu_titles'][sel_video_list_id] = video_list['displayName']\n- directory_items.append(_create_videolist_item(sel_video_list_id, video_list, sub_menu_data))\n- g.PERSISTENT_STORAGE.commit()\n+ sub_menu_data['main_menu'] = menu_data['main_menu']\\\n+ if menu_data.get('main_menu') else menu_data.copy()\n+ sub_menu_data.update({'title': video_list['displayName']})\n+ g.LOCAL_DB.set_value(sel_video_list_id, sub_menu_data, TABLE_MENU_DATA)\n+ directory_items.append(_create_videolist_item(sel_video_list_id,\n+ video_list,\n+ sub_menu_data))\n+ parent_menu_data = g.LOCAL_DB.get_value(menu_data['path'][1],\n+ table=TABLE_MENU_DATA, data_type=dict)\nfinalize_directory(directory_items, menu_data.get('content_type', g.CONTENT_SHOW),\n- title=g.get_menu_title(menu_data['path'][1]), sort_type='sort_label')\n+ title=parent_menu_data['title'],\n+ sort_type='sort_label')\nreturn menu_data.get('view')\n@@ -214,13 +220,18 @@ def build_subgenre_listing(subgenre_list, menu_data):\nsub_menu_data['lolomo_known'] = False\nsub_menu_data['lolomo_contexts'] = None\nsub_menu_data['content_type'] = g.CONTENT_SHOW\n- sub_menu_data['main_menu'] = menu_data['main_menu'] if menu_data.get('main_menu') else menu_data.copy()\n- g.PERSISTENT_STORAGE['sub_menus'][sel_video_list_id] = sub_menu_data\n- g.PERSISTENT_STORAGE['menu_titles'][sel_video_list_id] = subgenre_data['name']\n- directory_items.append(_create_subgenre_item(sel_video_list_id, subgenre_data, sub_menu_data))\n- g.PERSISTENT_STORAGE.commit()\n+ sub_menu_data['main_menu'] = menu_data['main_menu']\\\n+ if menu_data.get('main_menu') else menu_data.copy()\n+ sub_menu_data.update({'title': subgenre_data['name']})\n+ g.LOCAL_DB.set_value(sel_video_list_id, sub_menu_data, TABLE_MENU_DATA)\n+ directory_items.append(_create_subgenre_item(sel_video_list_id,\n+ subgenre_data,\n+ sub_menu_data))\n+ parent_menu_data = g.LOCAL_DB.get_value(menu_data['path'][1],\n+ table=TABLE_MENU_DATA, data_type=dict)\nfinalize_directory(directory_items, menu_data.get('content_type', g.CONTENT_SHOW),\n- title=g.get_menu_title(menu_data['path'][1]), sort_type='sort_label')\n+ title=parent_menu_data['title'],\n+ sort_type='sort_label')\nreturn menu_data.get('view')\n@@ -249,10 +260,10 @@ def build_video_listing(video_list, menu_data, pathitems=None, genre_id=None):\nsub_menu_data['lolomo_known'] = False\nsub_menu_data['lolomo_contexts'] = None\nsub_menu_data['content_type'] = g.CONTENT_SHOW\n- sub_menu_data['main_menu'] = menu_data['main_menu'] if menu_data.get('main_menu') else menu_data.copy()\n- g.PERSISTENT_STORAGE['sub_menus'][menu_id] = sub_menu_data\n- g.PERSISTENT_STORAGE['menu_titles'][menu_id] = common.get_local_string(30089)\n- g.PERSISTENT_STORAGE.commit()\n+ sub_menu_data['main_menu'] = menu_data['main_menu']\\\n+ if menu_data.get('main_menu') else menu_data.copy()\n+ sub_menu_data.update({'title': common.get_local_string(30089)})\n+ g.LOCAL_DB.set_value(menu_id, sub_menu_data, TABLE_MENU_DATA)\ndirectory_items.insert(0,\n(common.build_url(['genres', menu_id, genre_id],\nmode=g.MODE_DIRECTORY),\n@@ -266,8 +277,11 @@ def build_video_listing(video_list, menu_data, pathitems=None, genre_id=None):\nsort_type = 'sort_nothing'\nif menu_data['path'][1] == 'myList':\nsort_type = 'sort_label_ignore_folders'\n+ parent_menu_data = g.LOCAL_DB.get_value(menu_data['path'][1],\n+ table=TABLE_MENU_DATA, data_type=dict)\nfinalize_directory(directory_items, menu_data.get('content_type', g.CONTENT_SHOW),\n- title=g.get_menu_title(menu_data['path'][1]), sort_type=sort_type)\n+ title=parent_menu_data['title'],\n+ sort_type=sort_type)\nreturn menu_data.get('view')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/directory.py", "new_path": "resources/lib/navigation/directory.py", "diff": "@@ -5,6 +5,7 @@ from __future__ import unicode_literals\nimport xbmc\nimport xbmcplugin\n+from resources.lib.database.db_utils import (TABLE_MENU_DATA)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.api.shakti as api\n@@ -63,7 +64,7 @@ class DirectoryBuilder(object):\n\"\"\"Show a video list with a listid request\"\"\"\nmenu_data = g.MAIN_MENU_ITEMS.get(pathitems[1])\nif not menu_data:\n- menu_data = g.PERSISTENT_STORAGE['sub_menus'][pathitems[1]]\n+ menu_data = g.LOCAL_DB.get_value(pathitems[1], table=TABLE_MENU_DATA, data_type=dict)\nif g.is_known_menu_context(pathitems[2]):\nlist_id = api.list_id_for_type(menu_data['lolomo_contexts'][0])\nlistings.build_video_listing(api.video_list(list_id), menu_data)\n@@ -78,7 +79,7 @@ class DirectoryBuilder(object):\n\"\"\"Show a video list with a sorted request\"\"\"\nmenu_data = g.MAIN_MENU_ITEMS.get(pathitems[1])\nif not menu_data:\n- menu_data = g.PERSISTENT_STORAGE['sub_menus'][pathitems[1]]\n+ menu_data = g.LOCAL_DB.get_value(pathitems[1], table=TABLE_MENU_DATA, data_type=dict)\nmainmenu_data = menu_data.copy()\n# If the menu is a sub-menu, we get the parameters of the main menu\nif menu_data.get('main_menu'):\n@@ -120,7 +121,7 @@ class DirectoryBuilder(object):\n\"\"\"Show video lists for a genre\"\"\"\nmenu_data = g.MAIN_MENU_ITEMS.get(pathitems[1])\nif not menu_data:\n- menu_data = g.PERSISTENT_STORAGE['sub_menus'][pathitems[1]]\n+ menu_data = g.LOCAL_DB.get_value(pathitems[1], table=TABLE_MENU_DATA, data_type=dict)\n# pathitems indexes: 0 function name, 1 menu id, 2 optional id\nif len(pathitems) < 3:\nlolomo = api.root_lists()\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor menu_data to use db Also removed profile_have_mylist_menu in its place is used isKids value of the current profile
106,046
06.08.2019 20:35:32
-7,200
9e5465c2c83f89ed2906ca2c97da3c08033bd775
Added db_shared library methods
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_base.py", "new_path": "resources/lib/database/db_base.py", "diff": "@@ -50,7 +50,7 @@ def sql_connect():\nreturn time_execution_decorator\n-class NFBaseDatabase:\n+class NFBaseDatabase(object):\ndef __init__(self, db_file_path=db_utils.get_local_db_path()):\nself.conn = None\nself.db_file_path = db_file_path\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "from __future__ import unicode_literals\nimport resources.lib.common as common\n+import resources.lib.database.db_base as db_base\nimport resources.lib.database.db_local as db_local\nimport resources.lib.database.db_utils as db_utils\nclass NFSharedDatabase(db_local.NFLocalDatabase):\n- pass\n+ def get_value(self, key, default_value=None, table=db_utils.TABLE_SHARED_APP_CONF,\n+ data_type=None):\n+ return super(NFSharedDatabase, self).get_value(key, default_value, table, data_type)\n+\n+ def get_values(self, key, default_value=None, table=db_utils.TABLE_SHARED_APP_CONF):\n+ return super(NFSharedDatabase, self).get_values(key, default_value, table)\n+\n+ def set_value(self, key, value, table=db_utils.TABLE_SHARED_APP_CONF):\n+ super(NFSharedDatabase, self).set_value(key, value, table)\n+\n+ def delete_key(self, key, table=db_utils.TABLE_SHARED_APP_CONF):\n+ super(NFSharedDatabase, self).delete_key(key, table)\n+\n+ @db_base.sql_connect()\n+ def get_movie_filepath(self, movieid, default_value=None):\n+ \"\"\"Get movie filepath for given id\"\"\"\n+ query = 'SELECT FilePath FROM VideoLibMovies WHERE MovieID = ?'\n+ cur = self._execute_query(query, (movieid,))\n+ result = cur.fetchone()\n+ return result[0] if result else default_value\n+\n+ @db_base.sql_connect()\n+ def get_episode_filepath(self, tvshowid, seasonid, episodeid, default_value=None):\n+ \"\"\"Get movie filepath for given id\"\"\"\n+ query =\\\n+ ('SELECT FilePath FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'WHERE VideoLibSeasons.TvShowID = ? AND '\n+ 'VideoLibSeasons.SeasonID = ? AND '\n+ 'VideoLibEpisodes.EpisodeID = ?')\n+ cur = self._execute_query(query, (tvshowid, seasonid, episodeid))\n+ result = cur.fetchone()\n+ return result[0] if result is not None else default_value\n+\n+ @db_base.sql_connect()\n+ def get_random_episode_filepath_from_tvshow(self, tvshowid, default_value=None):\n+ \"\"\"Get random episode filepath of a show of a given id\"\"\"\n+ query =\\\n+ ('SELECT FilePath FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'WHERE VideoLibSeasons.TvShowID = ? '\n+ 'ORDER BY RANDOM() LIMIT 1')\n+ cur = self._execute_query(query, (tvshowid,))\n+ result = cur.fetchone()\n+ return result[0] if result is not None else default_value\n+\n+ @db_base.sql_connect()\n+ def get_random_episode_filepath_from_season(self, tvshowid, seasonid, default_value=None):\n+ \"\"\"Get random episode filepath of a show of a given id\"\"\"\n+ query =\\\n+ ('SELECT FilePath FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'WHERE VideoLibSeasons.TvShowID = ? AND VideoLibSeasons.SeasonID = ? '\n+ 'ORDER BY RANDOM() LIMIT 1')\n+ cur = self._execute_query(query, (tvshowid, seasonid))\n+ result = cur.fetchone()\n+ return result[0] if result is not None else default_value\n+\n+ @db_base.sql_connect()\n+ def get_all_video_id_list(self):\n+ \"\"\"Get all the ids of movies and tvshows contained in the library\"\"\"\n+ self.conn.row_factory = lambda cursor, row: row[0]\n+ query = ('SELECT MovieID FROM VideoLibMovies '\n+ 'UNION '\n+ 'SELECT TvShowID FROM VideoLibTvShows')\n+ cur = self._execute_query(query)\n+ result = cur.fetchall()\n+ return result\n+\n+ @db_base.sql_connect()\n+ def get_tvshows_id_list(self, enum_vid_prop=None, prop_value=None):\n+ \"\"\"\n+ Get all the ids of tvshows contained in the library\n+ :param enum_vid_prop: Optional: use db_utils.VidLibProp\n+ :param prop_value: Optional: value as filter\n+ :return: list of tvshows ids\n+ \"\"\"\n+ self.conn.row_factory = lambda cursor, row: row[0]\n+ if enum_vid_prop and prop_value:\n+ query = ('SELECT TvShowID FROM VideoLibTvShows'\n+ 'WHERE ' + enum_vid_prop.value + ' = ?')\n+ cur = self._execute_query(query, (str(prop_value),))\n+ else:\n+ query = 'SELECT TvShowID FROM VideoLibTvShows'\n+ cur = self._execute_query(query)\n+ result = cur.fetchall()\n+ return result\n+\n+ @db_base.sql_connect()\n+ def get_movies_id_list(self):\n+ \"\"\"Get all the ids of movies contained in the library\"\"\"\n+ self.conn.row_factory = lambda cursor, row: row[0]\n+ query = 'SELECT MovieID FROM VideoLibMovies'\n+ cur = self._execute_query(query)\n+ result = cur.fetchall()\n+ return result\n+\n+ @db_base.sql_connect()\n+ def movie_id_exists(self, movieid):\n+ \"\"\"Return True if a movie id exists\"\"\"\n+ query = 'SELECT EXISTS(SELECT 1 FROM VideoLibMovies WHERE MovieID = ?)'\n+ cur = self._execute_query(query, (movieid,))\n+ return bool(cur.fetchone()[0])\n+\n+ @db_base.sql_connect()\n+ def tvshow_id_exists(self, tvshowid):\n+ \"\"\"Return True if a tvshow id exists\"\"\"\n+ query = 'SELECT EXISTS(SELECT 1 FROM VideoLibTvShows WHERE TvShowID = ?)'\n+ cur = self._execute_query(query, (tvshowid,))\n+ return bool(cur.fetchone()[0])\n+\n+ @db_base.sql_connect()\n+ def season_id_exists(self, tvshowid, seasonid):\n+ \"\"\"Return True if a tvshow season id exists\"\"\"\n+ query =\\\n+ ('SELECT EXISTS('\n+ 'SELECT 1 FROM VideoLibSeasons '\n+ 'INNER JOIN VideoLibTvShows ON VideoLibSeasons.TvShowID = VideoLibTvShows.TvShowID '\n+ 'WHERE VideoLibTvShows.TvShowID = ? AND VideoLibSeasons.SeasonID = ?)')\n+ cur = self._execute_query(query, (tvshowid, seasonid))\n+ return bool(cur.fetchone()[0])\n+\n+ @db_base.sql_connect()\n+ def episode_id_exists(self, tvshowid, seasonid, episodeid):\n+ \"\"\"Return True if a tvshow episode id exists\"\"\"\n+ query =\\\n+ ('SELECT EXISTS('\n+ 'SELECT 1 FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'INNER JOIN VideoLibTvShows ON VideoLibSeasons.TvShowID = VideoLibTvShows.TvShowID '\n+ 'WHERE VideoLibTvShows.TvShowID = ? AND '\n+ 'VideoLibSeasons.SeasonID = ? AND '\n+ 'VideoLibEpisodes.EpisodeID = ?)')\n+ cur = self._execute_query(query, (tvshowid, seasonid, episodeid))\n+ return bool(cur.fetchone()[0])\n+\n+ @db_base.sql_connect()\n+ def set_movie(self, movieid, file_path, nfo_export):\n+ \"\"\"Update or insert a movie\"\"\"\n+ # Update or insert approach, if there is no updated row then insert new one\n+ update_query = ('UPDATE VideoLibMovies SET FilePath = ?, NfoExport = ? '\n+ 'WHERE MovieID = ?')\n+ cur = self._execute_query(update_query, (file_path, nfo_export, movieid))\n+ if cur.rowcount == 0:\n+ insert_query =\\\n+ 'INSERT INTO VideoLibMovies (MovieID, FilePath, NfoExport) VALUES (?, ?, ?)'\n+ self._execute_non_query(insert_query, (movieid, file_path, nfo_export))\n+\n+ @db_base.sql_connect()\n+ def set_tvshow(self, tvshowid, nfo_export, exclude_update):\n+ \"\"\"Update or insert a tvshow\"\"\"\n+ # Update or insert approach, if there is no updated row then insert new one\n+ update_query = ('UPDATE VideoLibTvShows SET NfoExport = ?, ExcludeUpdate = ? '\n+ 'WHERE TvShowID = ?')\n+ cur = self._execute_query(update_query, (str(nfo_export), str(exclude_update), tvshowid))\n+ if cur.rowcount == 0:\n+ insert_query =\\\n+ ('INSERT INTO VideoLibTvShows (TvShowID, NfoExport, ExcludeUpdate) '\n+ 'VALUES (?, ?, ?)')\n+ self._execute_non_query(insert_query, (tvshowid, str(nfo_export), str(exclude_update)))\n+\n+ @db_base.sql_connect()\n+ def insert_season(self, tvshowid, seasonid):\n+ \"\"\"Insert a season if not exists\"\"\"\n+ if not self.season_id_exists(tvshowid, seasonid):\n+ insert_query = ('INSERT INTO VideoLibSeasons (TvShowID, SeasonID) '\n+ 'VALUES (?, ?)')\n+ self._execute_non_query(insert_query, (tvshowid, seasonid))\n+\n+ @db_base.sql_connect()\n+ def insert_episode(self, tvshowid, seasonid, episodeid, file_path):\n+ \"\"\"Insert a episode if not exists\"\"\"\n+ if not self.episode_id_exists(tvshowid, seasonid, episodeid):\n+ insert_query = ('INSERT INTO VideoLibEpisodes (SeasonID, EpisodeID, FilePath) '\n+ 'VALUES (?, ?, ?)')\n+ self._execute_non_query(insert_query, (seasonid, episodeid, file_path))\n+\n+ @db_base.sql_connect()\n+ def delete_movie(self, movieid):\n+ \"\"\"Delete a movie from database\"\"\"\n+ query = 'DELETE FROM VideoLibMovies WHERE MovieID = ?'\n+ self._execute_query(query, (movieid,))\n+\n+ @db_base.sql_connect()\n+ def delete_tvshow(self, tvshowid):\n+ \"\"\"Delete a tvshow from database\"\"\"\n+ query = 'DELETE FROM VideoLibTvShows WHERE TvShowID = ?'\n+ self._execute_query(query, (tvshowid,))\n+\n+ @db_base.sql_connect()\n+ def delete_season(self, tvshowid, seasonid):\n+ \"\"\"Delete a season from database\"\"\"\n+ query = 'DELETE FROM VideoLibSeasons WHERE TvShowID = ? AND SeasonID = ?'\n+ self._execute_query(query, (tvshowid, seasonid))\n+ # if there are no other seasons, delete the tvshow\n+ query = 'SELECT EXISTS(SELECT 1 FROM VideoLibSeasons WHERE TvShowID = ?)'\n+ cur = self._execute_query(query, (tvshowid,))\n+ if not bool(cur.fetchone()[0]):\n+ self.delete_tvshow(tvshowid)\n+\n+ @db_base.sql_connect()\n+ def delete_episode(self, tvshowid, seasonid, episodeid):\n+ \"\"\"Delete a episode from database\"\"\"\n+ query = 'DELETE FROM VideoLibEpisodes WHERE SeasonID = ? AND EpisodeID = ?'\n+ self._execute_query(query, (seasonid, episodeid))\n+ # if there are no other episodes, delete the season\n+ query = 'SELECT EXISTS(SELECT 1 FROM VideoLibEpisodes WHERE SeasonID = ?)'\n+ cur = self._execute_query(query, (seasonid,))\n+ if not bool(cur.fetchone()[0]):\n+ self.delete_season(tvshowid, seasonid)\n+\n+ @db_base.sql_connect()\n+ def get_tvshow_property(self, tvshowid, enum_vid_prop, default_value=None, data_type=None):\n+ \"\"\"\n+ Read the value of the specified property\n+ :param tvshowid: id of tvshow\n+ :param enum_vid_prop: Use a enum value of db_utils.VidLibProp\n+ :param default_value: When key do not exist return this default value\n+ :param data_type: OPTIONAL Used to set data type conversion only when default_value is None\n+ :return: the property value\n+ \"\"\"\n+ query = 'SELECT ' + enum_vid_prop.value + ' FROM VideoLibTvShows WHERE TvShowID = ?'\n+ cur = self._execute_query(query, (tvshowid,))\n+ result = cur.fetchone()\n+ if default_value is not None:\n+ data_type = type(default_value)\n+ elif data_type is None:\n+ data_type = str\n+ return common.convert_from_string(result[0], data_type) \\\n+ if result is not None else default_value\n+\n+ @db_base.sql_connect()\n+ def set_tvshow_property(self, tvshowid, enum_vid_prop, value):\n+ update_query = ('UPDATE VideoLibTvShows '\n+ 'SET ' + enum_vid_prop.value + ' = ? WHERE TvShowID = ?')\n+ value = common.convert_to_string(value)\n+ cur = self._execute_query(update_query, (value, tvshowid))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "from __future__ import unicode_literals\nimport os\n-\nimport xbmc\n-\nimport resources.lib.common as common\n+from enum import Enum\nfrom resources.lib.globals import g\n@@ -21,6 +20,13 @@ TABLE_MENU_DATA = ('MenuData', ['ContextId', 'Value'])\nTABLE_SHARED_APP_CONF = ('SharedAppConfig', ['Name', 'Value'])\n+# Enum mapping the video library columns of the tables\n+class VidLibProp(Enum):\n+ exclude_update = 'ExcludeUpdate'\n+ nfo_export = 'NfoExport'\n+ file_path = 'FilePath'\n+\n+\ndef get_local_db_path():\nreturn xbmc.translatePath(os.path.join(g.DATA_PATH, 'database', LOCAL_DB_FILENAME))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added db_shared library methods
106,046
04.08.2019 19:06:26
-7,200
06dd116ec5e1884ef5d78a56caa95e4e9038854b
Refactor library to use db
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/context_menu.py", "new_path": "resources/lib/kodi/context_menu.py", "diff": "@@ -78,23 +78,20 @@ def _generate_library_ctx_items(videoid):\nif videoid.mediatype == common.VideoId.SUPPLEMENTAL:\nreturn library_actions\n- if g.ADDON.getSettingInt('auto_update') and videoid.mediatype == common.VideoId.SHOW:\n- if library.is_in_library(videoid):\n- library_actions = ['remove', 'update', 'exportnewepisodes']\n+ is_in_library = library.is_in_library(videoid)\n+ library_actions = ['remove', 'update'] if is_in_library else ['export']\n+\n+ if g.ADDON.getSettingInt('auto_update') and \\\n+ videoid.mediatype in [common.VideoId.SEASON, common.VideoId.EPISODE]:\n+ library_actions = []\n+\n+ if videoid.mediatype == common.VideoId.SHOW and is_in_library:\n+ library_actions.append('exportnewepisodes')\nif library.show_excluded_from_auto_update(videoid):\nlibrary_actions.append('includeinautoupdate')\nelse:\nlibrary_actions.append('excludefromautoupdate')\n- else:\n- library_actions = ['export']\n- elif (not g.ADDON.getSettingInt('auto_update')) or videoid.mediatype == common.VideoId.MOVIE:\n- if library.is_in_library(videoid):\n- library_actions = ['remove', 'update']\n- if videoid.mediatype == common.VideoId.SHOW:\n- library_actions.append('exportnewepisodes')\n- else:\n- library_actions = ['export']\nreturn [_ctx_item(action, videoid) for action in library_actions]\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "from __future__ import unicode_literals\nimport os\n-import re\nimport random\n-\n+import re\n+import xml.etree.ElementTree as ET\nfrom datetime import datetime, timedelta\nfrom functools import wraps\nimport xbmc\nimport xbmcvfs\n-from resources.lib.globals import g\n-import resources.lib.common as common\nimport resources.lib.api.shakti as api\n-import resources.lib.kodi.ui as ui\n+import resources.lib.common as common\nimport resources.lib.kodi.nfo as nfo\n-\n-import xml.etree.ElementTree as ET\n-\n+import resources.lib.kodi.ui as ui\n+from resources.lib.database.db_utils import (VidLibProp)\n+from resources.lib.globals import g\nLIBRARY_HOME = 'library'\nFOLDER_MOVIES = 'movies'\n@@ -45,8 +43,8 @@ def get_item(videoid):\nKodi DBID and mediatype\"\"\"\n# pylint: disable=broad-except\ntry:\n- library_entry, entry_type = _get_library_entry(videoid)\n- return _get_item(entry_type, library_entry['file'])\n+ file_path, media_type = _get_library_entry(videoid)\n+ return _get_item(media_type, file_path)\nexcept (KeyError, AttributeError, IndexError, ItemNotFound):\nraise ItemNotFound(\n'The video with id {} is not present in the Kodi library'\n@@ -55,29 +53,27 @@ def get_item(videoid):\[email protected]_execution(immediate=False)\ndef _get_library_entry(videoid):\n- \"\"\"Get the first leaf-entry for videoid from the library.\n- For shows and seasons this will return the first contained episode\"\"\"\n- if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\n- return (common.get_path(videoid.to_list(), g.library()),\n- videoid.mediatype)\n+ if videoid.mediatype == common.VideoId.MOVIE:\n+ file_path = g.SHARED_DB.get_movie_filepath(videoid.value)\n+ media_type = videoid.mediatype\n+ elif videoid.mediatype == common.VideoId.EPISODE:\n+ file_path = g.SHARED_DB.get_episode_filepath(videoid.tvshowid,\n+ videoid.seasonid,\n+ videoid.episodeid)\n+ media_type = videoid.mediatype\nelif videoid.mediatype == common.VideoId.SHOW:\n- return (\n- _any_child_library_entry(\n- _any_child_library_entry(g.library()[videoid.tvshowid])),\n- common.VideoId.EPISODE)\n+ file_path = g.SHARED_DB.get_random_episode_filepath_from_tvshow(videoid.value)\n+ media_type = common.VideoId.EPISODE\nelif videoid.mediatype == common.VideoId.SEASON:\n- return (\n- _any_child_library_entry(\n- g.library()[videoid.tvshowid][videoid.seasonid]),\n- common.VideoId.EPISODE)\n+ file_path = g.SHARED_DB.get_random_episode_filepath_from_season(videoid.tvshowid,\n+ videoid.seasonid)\n+ media_type = common.VideoId.EPISODE\nelse:\n# Items of other mediatype are never in library\nraise ItemNotFound\n-\n-\n-def _any_child_library_entry(library_entry):\n- \"\"\"Return a random library entry that is a child of library_entry\"\"\"\n- return common.any_value_except(library_entry, ['videoid', 'nfo_export', 'exclude_from_update'])\n+ if file_path is None:\n+ raise ItemNotFound\n+ return file_path, media_type\[email protected]_execution(immediate=False)\n@@ -102,30 +98,37 @@ def _get_item(mediatype, filename):\ndef list_contents():\n- \"\"\"Return a list of all top-level video IDs (movies, shows)\n+ \"\"\"Return a list of all video IDs (movies, shows)\ncontained in the library\"\"\"\n- return g.library().keys()\n+ return g.SHARED_DB.get_all_video_id_list()\ndef is_in_library(videoid):\n\"\"\"Return True if the video is in the local Kodi library, else False\"\"\"\n- return common.get_path_safe(videoid.to_list(), g.library()) is not None\n+ if videoid.mediatype == common.VideoId.MOVIE:\n+ return g.SHARED_DB.movie_id_exists(videoid.value)\n+ elif videoid.mediatype == common.VideoId.SHOW:\n+ return g.SHARED_DB.tvshow_id_exists(videoid.value)\n+ elif videoid.mediatype == common.VideoId.SEASON:\n+ return g.SHARED_DB.season_id_exists(videoid.tvshowid,\n+ videoid.seasonid)\n+ elif videoid.mediatype == common.VideoId.EPISODE:\n+ return g.SHARED_DB.episode_id_exists(videoid.tvshowid,\n+ videoid.seasonid,\n+ videoid.episodeid)\n+ else:\n+ raise common.InvalidVideoId('videoid {} type not implemented'.format(videoid))\ndef show_excluded_from_auto_update(videoid):\n- \"\"\"\n- Return true if the videoid is excluded from auto update\n- \"\"\"\n- if videoid.value in g.library().keys():\n- return g.library()[videoid.value].get('exclude_from_update', False)\n- return False\n+ \"\"\"Return true if the videoid is excluded from auto-update\"\"\"\n+ return g.SHARED_DB.get_tvshow_property(videoid.value, VidLibProp.exclude_update, False)\[email protected]_execution(immediate=False)\ndef exclude_show_from_auto_update(videoid, exclude):\n- if videoid.value in g.library().keys():\n- g.library()[videoid.value]['exclude_from_update'] = exclude\n- g.save_library()\n+ \"\"\"Set if a tvshow is excluded from auto-update\"\"\"\n+ g.SHARED_DB.set_tvshow_property(videoid.value, VidLibProp.exclude_update, exclude)\ndef update_kodi_library(library_operation):\n@@ -187,11 +190,16 @@ def _remove_from_kodi_library(videoid):\[email protected]_execution(immediate=False)\ndef purge():\n- \"\"\"Purge all items exported to Kodi library and delete internal library\n- database\"\"\"\n- common.debug('Purging library: {}'.format(g.library()))\n- for library_item in g.library().values():\n- execute_library_tasks(library_item['videoid'], remove_item,\n+ \"\"\"Purge all items exported to Kodi library and delete internal library database\"\"\"\n+ common.debug('Purging internal database and kodi library')\n+ for videoid_value in g.SHARED_DB.get_movies_id_list():\n+ videoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])\n+ execute_library_tasks(videoid, remove_item,\n+ common.get_local_string(30030),\n+ sync_mylist=False)\n+ for videoid_value in g.SHARED_DB.get_tvshows_id_list():\n+ videoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n+ execute_library_tasks(videoid, remove_item,\ncommon.get_local_string(30030),\nsync_mylist=False)\n@@ -293,31 +301,31 @@ def _create_item_task(title, section, videoid, destination, filename, nfo_data=N\ndef _create_new_episodes_tasks(videoid, metadata):\ntasks = []\n- library_node = g.library()\nfor season in metadata[0]['seasons']:\n- # If the season is missing, build task for the season\n- if str(season['id']) not in library_node[str(videoid.value)]:\n- tasks += _compile_season_tasks(\n- videoid=videoid.derive_season(season['id']),\n- show=metadata[0],\n- season=season,\n- nfo_settings=nfo.NFOSettings(library_node[str(videoid.value)]\n- .get('nfo_export', False))\n- )\n- common.debug('Auto exporting season {}'.format(season['id']))\n- else:\n- # We enumerate episodes and try to find any missing one\n+ nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value, VidLibProp.nfo_export, False)\n+ nfo_settings = nfo.NFOSettings(nfo_export)\n+\n+ if 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 str(episode['id']) not in library_node[videoid.value][str(season['id'])]:\n+ if not g.SHARED_DB.episode_id_exists(videoid.value, season['id'], episode['id']):\ntasks.append(_create_episode_task(\nvideoid=videoid.derive_season(season['id']).derive_episode(episode['id']),\nepisode=episode,\nseason=season,\nshow=metadata[0],\n- nfo_settings=nfo.NFOSettings(library_node[str(videoid.value)]\n- .get('nfo_export', False))\n+ nfo_settings=nfo_settings\n))\ncommon.debug('Auto exporting episode {}'.format(episode['id']))\n+ else:\n+ # The season does not exist, build task for the season\n+ tasks += _compile_season_tasks(\n+ videoid=videoid.derive_season(season['id']),\n+ show=metadata[0],\n+ season=season,\n+ nfo_settings=nfo_settings\n+ )\n+ common.debug('Auto exporting season {}'.format(season['id']))\nreturn tasks\n@@ -369,21 +377,13 @@ def _write_nfo_file(nfo_data, nfo_filename):\ndef _add_to_library(videoid, export_filename, nfo_export):\n\"\"\"Add an exported file to the library\"\"\"\n- library_node = g.library()\n- for depth, id_item in enumerate(videoid.to_list()):\n- if id_item not in library_node:\n- # No entry yet at this level, create a new one and assign\n- # it an appropriate videoid for later reference\n- parent_video_id = videoid.derive_parent(depth)\n- library_node[id_item] = {\n- 'videoid': parent_video_id}\n- if parent_video_id.mediatype == common.VideoId.SHOW:\n- library_node[id_item]['nfo_export'] = nfo_export\n- library_node[id_item]['exclude_from_update'] = False\n- library_node = library_node[id_item]\n- library_node['file'] = export_filename\n- library_node['videoid'] = videoid\n- g.save_library()\n+ if videoid.mediatype == common.VideoId.EPISODE:\n+ g.SHARED_DB.set_tvshow(videoid.tvshowid, nfo_export, False)\n+ g.SHARED_DB.insert_season(videoid.tvshowid, videoid.seasonid)\n+ g.SHARED_DB.insert_episode(videoid.tvshowid, videoid.seasonid, videoid.value,\n+ export_filename.decode(\"utf-8\"))\n+ elif videoid.mediatype == common.VideoId.MOVIE:\n+ g.SHARED_DB.set_movie(videoid.value, export_filename.decode(\"utf-8\"), nfo_export)\[email protected]_execution(immediate=False)\n@@ -393,44 +393,52 @@ def remove_item(item_task, library_home=None):\nif item_task['is_strm']: # We don't take care of a tvshow.nfo task if we are running an update\ncommon.debug('Removing {} from library'.format(item_task['title']))\nif not is_in_library(item_task['videoid']):\n- common.warn('cannot remove {}, item not in library'\n+ common.warn('cannot remove {}, item not in database library'\n.format(item_task['title']))\nreturn\n- id_path = item_task['videoid'].to_list()\n- exported_filename = xbmc.translatePath(\n- common.get_path(id_path, g.library())['file']).decode(\"utf-8\")\n- parent_folder = os.path.dirname(exported_filename)\n+ videoid = item_task['videoid']\n+ exported_filename = ''\ntry:\n- xbmcvfs.delete(xbmc.translatePath(exported_filename).decode(\"utf-8\"))\n+ file_path, media_type = _get_library_entry(videoid)\n+\n+ exported_filename = xbmc.translatePath(file_path)\n+ parent_folder = xbmc.translatePath(os.path.dirname(exported_filename))\n+\n+ xbmcvfs.delete(exported_filename.decode(\"utf-8\"))\n# Remove the NFO files if exists\n- nfo_file = os.path.splitext(xbmc.translatePath(exported_filename).decode(\"utf-8\"))[0]+'.nfo'\n+ nfo_file = os.path.splitext(exported_filename.decode(\"utf-8\"))[0] + '.nfo'\nif xbmcvfs.exists(nfo_file):\nxbmcvfs.delete(nfo_file)\n- dirs, files = xbmcvfs.listdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\n+ dirs, files = xbmcvfs.listdir(parent_folder.decode(\"utf-8\"))\ntvshow_nfo_file = xbmc.makeLegalFilename(\n- os.path.join(\n- xbmc.translatePath(parent_folder).decode(\"utf-8\"), 'tvshow.nfo'))\n- # Remove tvshow_nfo_file only when is the last file (users have the option of removing even single seasons)\n+ os.path.join(parent_folder.decode(\"utf-8\"), '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:\nxbmcvfs.delete(tvshow_nfo_file)\n# Delete parent folder\n- xbmcvfs.rmdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\n+ xbmcvfs.rmdir(parent_folder.decode(\"utf-8\"))\n# Delete parent folder when empty\nif not dirs and not files:\n- xbmcvfs.rmdir(xbmc.translatePath(parent_folder).decode(\"utf-8\"))\n+ xbmcvfs.rmdir(parent_folder.decode(\"utf-8\"))\n+\n+ _remove_videoid_from_db(videoid)\n+ except ItemNotFound:\n+ common.debug('The video with id {} not exists in the database'.format(videoid))\nexcept Exception:\n- common.debug('Cannot delete {}, file does not exist'\n- .format(exported_filename))\n+ common.debug('Cannot delete {}, file does not exist'.format(exported_filename))\n+\n- # lambda e: (e.keys() == ['videoid']\n- # or all(k in e.keys() for k in ['videoid', 'nfo_export']))\n- # is not working and causes issues.\n- # Reverted.\n- common.remove_path(id_path, g.library(), lambda e: (\n- e.keys() == ['videoid']\n- or len(set(e.keys()) - {'videoid', 'nfo_export'}) == 0\n- or len(set(e.keys()) - {'videoid', 'nfo_export', 'exclude_from_update'}) == 0))\n- g.save_library()\n+def _remove_videoid_from_db(videoid):\n+ \"\"\"Removes records from database in relation to a videoid\"\"\"\n+ if videoid.mediatype == common.VideoId.MOVIE:\n+ g.SHARED_DB.delete_movie(videoid.value)\n+ elif videoid.mediatype == common.VideoId.SHOW:\n+ g.SHARED_DB.delete_tvshow(videoid.value)\n+ elif videoid.mediatype == common.VideoId.SEASON:\n+ g.SHARED_DB.delete_season(videoid.tvshowid, videoid.seasonid)\n+ elif videoid.mediatype == common.VideoId.EPISODE:\n+ g.SHARED_DB.delete_episode(videoid.tvshowid, videoid.seasonid, videoid.episodeid)\ndef update_item(item_task, library_home):\n@@ -440,12 +448,13 @@ def update_item(item_task, library_home):\ndef _export_all_new_episodes_running():\n- update = g.PERSISTENT_STORAGE.get('export_all_new_episodes_running', False)\n+ update = g.SHARED_DB.get_value('library_export_new_episodes_running', False)\nif update:\n- start_time = common.strp(g.PERSISTENT_STORAGE.get('export_all_new_episodes_start_time'),\n- '%Y-%m-%d %H:%M')\n+ start_time = g.SHARED_DB.get_value('library_export_new_episode_start_time',\n+ data_type=datetime)\n+ start_time = common.strp(start_time, '%Y-%m-%d %H:%M')\nif datetime.now() >= start_time + timedelta(hours=6):\n- g.PERSISTENT_STORAGE['export_all_new_episodes_running'] = False\n+ g.SHARED_DB.set_value('library_export_new_episodes_running', False)\ncommon.warn('Canceling previous library update: duration >6 hours')\nelse:\ncommon.debug('Export all new episodes is already running')\n@@ -459,18 +468,16 @@ def export_all_new_episodes():\n\"\"\"\nif not _export_all_new_episodes_running():\ncommon.log('Starting to export new episodes for all tv shows')\n- g.PERSISTENT_STORAGE['export_all_new_episodes_running'] = True\n- g.PERSISTENT_STORAGE['export_all_new_episodes_start_time'] = datetime.now()\\\n- .strftime('%Y-%m-%d %H:%M')\n-\n- for library_item in g.library().values():\n- if library_item['videoid'].mediatype == common.VideoId.SHOW\\\n- and not library_item.get('exclude_from_update', False):\n- export_new_episodes(library_item['videoid'], False)\n+ g.SHARED_DB.set_value('library_export_new_episodes_running', True)\n+ g.SHARED_DB.set_value('library_export_new_episode_start_time', datetime.now())\n+\n+ for videoid_value in g.SHARED_DB.get_tvshows_id_list(VidLibProp.exclude_update, False):\n+ videoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n+ export_new_episodes(videoid, False)\n# add some randomness between show analysis to limit servers load and ban risks\nxbmc.sleep(random.randint(1000, 5001))\n- g.PERSISTENT_STORAGE['export_all_new_episodes_running'] = False\n+ g.SHARED_DB.set_value('library_export_new_episodes_running', False)\ncommon.debug('Notify service to update the library')\ncommon.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "\"\"\"Automatic updates of items exported to the Kodi library\"\"\"\nfrom __future__ import unicode_literals\n-from datetime import date, datetime, timedelta\n+from datetime import datetime, timedelta\nimport AddonSignals\nimport xbmc\n@@ -18,7 +18,6 @@ class LibraryUpdateService(xbmc.Monitor):\n\"\"\"\ndef __init__(self):\n-\n# Export new episodes variables\nself.startidle = 0\n# self.last_schedule_check = datetime.now()\n@@ -40,8 +39,7 @@ class LibraryUpdateService(xbmc.Monitor):\ncommon.debug('Triggering export new episodes')\nxbmc.executebuiltin('XBMC.RunPlugin(plugin://{}/library/exportallnewepisodes/)'\n.format(g.ADDON_ID))\n- g.PERSISTENT_STORAGE['library_auto_update_last_start'] = \\\n- date.today().strftime('%Y-%m-%d')\n+ g.SHARED_DB.set_value('library_auto_update_last_start', datetime.now())\nself.next_schedule = _compute_next_schedule()\ndef is_idle(self):\n@@ -105,9 +103,8 @@ def _compute_next_schedule():\nreturn None\ntime = g.ADDON.getSetting('update_time') or '00:00'\n- last_run = g.PERSISTENT_STORAGE.get(\n- 'library_auto_update_last_start',\n- '1970-01-01')\n+ last_run = g.SHARED_DB.get_value('library_auto_update_last_start',\n+ datetime.now() - timedelta(days=(50*365)))\nlast_run = common.strp('{} {}'.format(last_run, time[0:5]),\n'%Y-%m-%d %H:%M')\nnext_run = last_run + timedelta(days=[0, 1, 2, 5, 7][update_frequency])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor library to use db
106,046
04.08.2019 17:54:51
-7,200
4b5593cc28ce0ed273d9cbf90b798f4655a03b52
Refactor settings_monitor to use db The new "SettingMonitor" table should only be used to verify changes to settings, currently kodi does not offer a better solution
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "@@ -17,6 +17,7 @@ SHARED_DB_FILENAME = 'nf_shared.sqlite3'\nTABLE_APP_CONF = ('AppConfig', ['Name', 'Value'])\nTABLE_SESSION = ('Session', ['Name', 'Value'])\nTABLE_MENU_DATA = ('MenuData', ['ContextId', 'Value'])\n+TABLE_SETTINGS_MONITOR = ('SettingsMonitor', ['Name', 'Value'])\nTABLE_SHARED_APP_CONF = ('SharedAppConfig', ['Name', 'Value'])\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -6,6 +6,7 @@ from __future__ import unicode_literals\nimport xbmc\nimport sys\n+from resources.lib.database.db_utils import (TABLE_SETTINGS_MONITOR)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n@@ -23,30 +24,33 @@ class SettingsMonitor(xbmc.Monitor):\ng.init_globals(sys.argv)\n- ps_changed = False\nshow_menu_changed = False\nsort_order_type_changed = False\nfor menu_id, menu_data in g.MAIN_MENU_ITEMS.iteritems():\n# Check settings changes in show menu\nshow_menu_new_setting = bool(g.ADDON.getSettingBool('_'.join(('show_menu', menu_id))))\n- show_menu_old_setting = g.PERSISTENT_STORAGE['show_menus'].get(menu_id, True)\n+ show_menu_old_setting = g.LOCAL_DB.get_value('menu_{}_show'.format(menu_id),\n+ True,\n+ TABLE_SETTINGS_MONITOR)\nif show_menu_new_setting != show_menu_old_setting:\n- g.PERSISTENT_STORAGE['show_menus'][menu_id] = show_menu_new_setting\n+ g.LOCAL_DB.set_value('menu_{}_show'.format(menu_id),\n+ show_menu_new_setting,\n+ TABLE_SETTINGS_MONITOR)\nshow_menu_changed = True\n- ps_changed = True\n+\n# Check settings changes in sort order of menu\nif menu_data.get('request_context_name'):\nmenu_sortorder_new_setting = int(\ng.ADDON.getSettingInt('_'.join(('menu_sortorder', menu_data['path'][1]))))\n- menu_sortorder_old_setting = g.PERSISTENT_STORAGE['menu_sortorder'].get(menu_id, 0)\n+ menu_sortorder_old_setting = g.LOCAL_DB.get_value('menu_{}_sortorder'.format(menu_id),\n+ 0,\n+ TABLE_SETTINGS_MONITOR)\nif menu_sortorder_new_setting != menu_sortorder_old_setting:\n- g.PERSISTENT_STORAGE['menu_sortorder'][menu_id] = menu_sortorder_new_setting\n+ g.LOCAL_DB.set_value('menu_{}_sortorder'.format(menu_id),\n+ menu_sortorder_new_setting,\n+ TABLE_SETTINGS_MONITOR)\nsort_order_type_changed = True\n- ps_changed = True\n-\n- if ps_changed:\n- g.PERSISTENT_STORAGE.commit()\nif sort_order_type_changed:\n# We remove the cache to allow get the new results in the chosen order\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor settings_monitor to use db The new "SettingMonitor" table should only be used to verify changes to settings, currently kodi does not offer a better solution
106,046
04.08.2019 18:43:57
-7,200
3d336409f02f04f6abf861a4407685c3b95fee80
Refactor SETTINGS_MONITOR_IGNORE to use db
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -183,7 +183,6 @@ class GlobalVariables(object):\nThis is an ugly hack because Kodi doesn't execute statements defined on\nmodule level if reusing a language invoker.\"\"\"\nself._library = None\n- self.SETTINGS_MONITOR_IGNORE = False\nself.COOKIES = {}\nself.ADDON = xbmcaddon.Addon()\nself.ADDON_ID = self.ADDON.getAddonInfo('id')\n@@ -233,6 +232,8 @@ class GlobalVariables(object):\ndb_utils.SHARED_DB_FILENAME))\nself.SHARED_DB = db_shared.NFSharedDatabase(temp_hardcoded_path)\n+ self.settings_monitor_suspended(False) # Reset the value in case of addon crash\n+\ntry:\nos.mkdir(self.DATA_PATH)\nexcept OSError:\n@@ -270,7 +271,8 @@ class GlobalVariables(object):\nif run_initial_config:\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n- self.SETTINGS_MONITOR_IGNORE = True\n+ self.settings_monitor_suspended(True)\n+\nsystem = common.get_system_platform()\ncommon.debug('Running initial addon configuration dialogs on system: {}'.format(system))\nif system in ['osx','ios','xbox']:\n@@ -315,7 +317,24 @@ class GlobalVariables(object):\nself.ADDON.setSettingBool('enable_vp9_profiles', False)\nself.ADDON.setSettingBool('enable_hevc_profiles', False)\nself.ADDON.setSettingBool('run_init_configuration', False)\n- self.SETTINGS_MONITOR_IGNORE = False\n+ self.settings_monitor_suspended(False)\n+\n+ def settings_monitor_suspended(self, suspend):\n+ \"\"\"\n+ Suspends for the necessary time the settings monitor\n+ that otherwise cause the reinitialization of global settings\n+ and possible consequent actions to settings changes or unnecessary checks\n+ \"\"\"\n+ is_suspended = g.LOCAL_DB.get_value('suspend_settings_monitor', False)\n+ if (is_suspended and suspend) or (not is_suspended and not suspend):\n+ return\n+ g.LOCAL_DB.set_value('suspend_settings_monitor', suspend)\n+\n+ def settings_monitor_is_suspended(self):\n+ \"\"\"\n+ Returns True when the setting monitor must be suspended\n+ \"\"\"\n+ return g.LOCAL_DB.get_value('suspend_settings_monitor', False)\ndef init_persistent_storage(self):\n\"\"\"\n@@ -365,7 +384,9 @@ class GlobalVariables(object):\nfor _ in range(0, 30):\nesn.append(random.choice(possible))\nedge_esn = ''.join(esn)\n+ self.settings_monitor_suspended(True)\nself.ADDON.setSetting('edge_esn', edge_esn)\n+ self.settings_monitor_suspended(False)\nreturn edge_esn\ndef is_known_menu_context(self, context):\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/actions.py", "new_path": "resources/lib/navigation/actions.py", "diff": "@@ -26,12 +26,12 @@ class AddonActionExecutor(object):\ndef save_autologin(self, pathitems):\n\"\"\"Save autologin data\"\"\"\ntry:\n- g.SETTINGS_MONITOR_IGNORE = True\n+ g.settings_monitor_suspended(True)\ng.ADDON.setSetting('autologin_user',\nself.params['autologin_user'])\ng.ADDON.setSetting('autologin_id', pathitems[1])\ng.ADDON.setSetting('autologin_enable', 'true')\n- g.SETTINGS_MONITOR_IGNORE = False\n+ g.settings_monitor_suspended(False)\nexcept (KeyError, IndexError):\ncommon.error('Cannot save autologin - invalid params')\ng.CACHE.invalidate()\n@@ -46,9 +46,9 @@ class AddonActionExecutor(object):\nif api.verify_pin(pin):\ncurrent_setting = {'true': True, 'false': False}.get(\ng.ADDON.getSetting('adultpin_enable').lower())\n- g.SETTINGS_MONITOR_IGNORE = True\n+ g.settings_monitor_suspended(True)\ng.ADDON.setSetting('adultpin_enable', str(not current_setting))\n- g.SETTINGS_MONITOR_IGNORE = False\n+ g.settings_monitor_suspended(False)\ng.flush_settings()\nui.show_notification(\ncommon.get_local_string(30107 if current_setting else 30108))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -16,7 +16,7 @@ class SettingsMonitor(xbmc.Monitor):\nxbmc.Monitor.__init__(self)\ndef onSettingsChanged(self):\n- if not g.SETTINGS_MONITOR_IGNORE:\n+ if not g.settings_monitor_is_suspended():\nself._on_change()\ndef _on_change(self):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor SETTINGS_MONITOR_IGNORE to use db
106,046
04.08.2019 18:53:27
-7,200
90930199a74e88aa6460bbad94ada4c3d58cd69b
Completely deleted the PERSISTENT_STORAGE
[ { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -240,7 +240,6 @@ class GlobalVariables(object):\npass\nself._init_cache()\n- self.init_persistent_storage()\ndef _init_cache(self):\nif not os.path.exists(\n@@ -336,25 +335,6 @@ class GlobalVariables(object):\n\"\"\"\nreturn g.LOCAL_DB.get_value('suspend_settings_monitor', False)\n- def init_persistent_storage(self):\n- \"\"\"\n- Save on disk the data to keep in memory,\n- at each screen change kodi reinitializes the addon\n- making it impossible to have persistent variables\n- \"\"\"\n- # This is ugly: Pass the common module into Cache.__init__ to work\n- # around circular import dependencies.\n- import resources.lib.common as common\n- # In PersistentStorage \"save on destroy\" here cause problems because often gets destroyed by various behaviors\n- self.PERSISTENT_STORAGE = common.PersistentStorage(__name__, no_save_on_destroy=True)\n- # If missing create necessary keys\n- if not self.PERSISTENT_STORAGE.get('show_menus'):\n- self.PERSISTENT_STORAGE['show_menus'] = {}\n- if not self.PERSISTENT_STORAGE.get('menu_sortorder'):\n- self.PERSISTENT_STORAGE['menu_sortorder'] = {}\n- if not self.PERSISTENT_STORAGE.get('sub_menus'):\n- self.PERSISTENT_STORAGE['sub_menus'] = {}\n-\ndef library(self):\n\"\"\"Get the current library instance\"\"\"\n# pylint: disable=global-statement, attribute-defined-outside-init\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Completely deleted the PERSISTENT_STORAGE
106,046
04.08.2019 21:47:21
-7,200
edce9df48d72fa82154c4e4b7101f8de3ad5238d
Added create VideoId instance from a dict
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/videoid.py", "new_path": "resources/lib/common/videoid.py", "diff": "@@ -68,6 +68,20 @@ class VideoId(object):\nreturn cls(supplementalid=pathitems[1])\nreturn cls(videoid=pathitems[0])\n+ @classmethod\n+ def from_dict(cls, dict_items):\n+ \"\"\"Create a VideoId instance from a dict items\"\"\"\n+ mediatype = dict_items['mediatype']\n+ if mediatype == VideoId.MOVIE:\n+ return cls(movieid=dict_items['movieid'])\n+ elif mediatype in VideoId.TV_TYPES:\n+ return cls(tvshowid=_path_attr_dict(dict_items, 'tvshowid'),\n+ seasonid=_path_attr_dict(dict_items, 'seasonid'),\n+ episodeid=_path_attr_dict(dict_items, 'episodeid'))\n+ elif mediatype == VideoId.SUPPLEMENTAL:\n+ return cls(supplementalid=dict_items['supplementalid'])\n+ raise InvalidVideoId\n+\n@classmethod\ndef from_videolist_item(cls, video):\n\"\"\"Create a VideoId from a video item contained in a\n@@ -231,6 +245,10 @@ def _path_attr(pathitems, index):\nreturn pathitems[index] if len(pathitems) > index else None\n+def _path_attr_dict(pathitems, key):\n+ return pathitems[key] if key in pathitems else None\n+\n+\ndef inject_video_id(path_offset, pathitems_arg='pathitems',\ninject_remaining_pathitems=False,\ninject_full_pathitems=False):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added create VideoId instance from a dict
106,046
04.08.2019 21:47:38
-7,200
02d80919f8fb12fdcf34f0d91ccc4388f835e782
Refactor stream_continuity to use db
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "@@ -246,3 +246,31 @@ class NFSharedDatabase(db_local.NFLocalDatabase):\n'SET ' + enum_vid_prop.value + ' = ? WHERE TvShowID = ?')\nvalue = common.convert_to_string(value)\ncur = self._execute_query(update_query, (value, tvshowid))\n+\n+ @db_base.sql_connect()\n+ def get_stream_continuity(self, profile_guid, videoid, default_value=None, data_type=None):\n+ \"\"\"Get stream continuity value of a given id stored to current profile\"\"\"\n+ query = 'SELECT Value FROM StreamContinuity WHERE ProfileGuid = ? AND VideoID = ?'\n+ cur = self._execute_query(query, (profile_guid, videoid))\n+ result = cur.fetchone()\n+ if default_value is not None:\n+ data_type = type(default_value)\n+ elif data_type is None:\n+ data_type = str\n+ return common.convert_from_string(result[0], data_type) \\\n+ if result is not None else default_value\n+\n+ @db_base.sql_connect()\n+ def set_stream_continuity(self, profile_guid, videoid, value):\n+ \"\"\"Update or insert a stream continuity value to current profile\"\"\"\n+ # Update or insert approach, if there is no updated row then insert new one\n+ value = common.convert_to_string(value)\n+ update_query = ('UPDATE StreamContinuity '\n+ 'SET Value = ?, DateLastModified = datetime(\\'now\\', \\'localtime\\') '\n+ 'WHERE ProfileGuid = ? AND VideoID = ?')\n+ cur = self._execute_query(update_query, (value, profile_guid, videoid))\n+ if cur.rowcount == 0:\n+ insert_query = ('INSERT INTO StreamContinuity '\n+ '(ProfileGuid, VideoID, Value, DateLastModified) '\n+ 'VALUES (?, ?, ?, datetime(\\'now\\', \\'localtime\\'))')\n+ self._execute_non_query(insert_query, (profile_guid, videoid, value))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/stream_continuity.py", "new_path": "resources/lib/services/playback/stream_continuity.py", "diff": "\"\"\"\nRemember and restore audio stream / subtitle settings between individual\n-episodes of a tv show\n+episodes of a tv show or movie\n\"\"\"\nfrom __future__ import unicode_literals\n@@ -47,17 +47,17 @@ class StreamContinuityManager(PlaybackActionManager):\nself.resume = {}\n@property\n- def show_settings(self):\n- \"\"\"Stored stream settings for the current show\"\"\"\n- return self.storage.get(self.current_videoid, {})\n+ def sc_settings(self):\n+ \"\"\"Stored stream settings for the current videoid\"\"\"\n+\n+ return g.SHARED_DB.get_stream_continuity(g.LOCAL_DB.get_active_profile_guid(),\n+ self.current_videoid.value, {})\ndef _initialize(self, data):\n- if 'tvshowid' in data['videoid']:\n- self.did_restore = False\n- self.current_videoid = data['videoid']['tvshowid']\n- elif 'movieid' in data['videoid']:\n+ videoid = common.VideoId.from_dict(data['videoid'])\n+ if videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\nself.did_restore = False\n- self.current_videoid = data['videoid']['movieid']\n+ self.current_videoid = videoid\nelse:\nself.enabled = False\n@@ -66,7 +66,7 @@ class StreamContinuityManager(PlaybackActionManager):\nfor stype in STREAMS:\nself._set_current_stream(stype, player_state)\nself._restore_stream(stype)\n- if (self.show_settings.get('subtitleenabled', None) is None\n+ if (self.sc_settings.get('subtitleenabled', None) is None\nand g.ADDON.getSettingBool('forced_subtitle_workaround')):\n# Use the workaround only when the user did not change the show subtitle setting\n_show_only_forced_subtitle()\n@@ -93,7 +93,7 @@ class StreamContinuityManager(PlaybackActionManager):\ndef _restore_stream(self, stype):\ncommon.debug('Trying to restore {}...'.format(stype))\nset_stream = STREAMS[stype]['setter']\n- stored_stream = self.show_settings.get(stype)\n+ stored_stream = self.sc_settings.get(stype)\nif (stored_stream is not None and\nself.current_streams[stype] != stored_stream):\n# subtitleenabled is boolean and not a dict\n@@ -105,10 +105,11 @@ class StreamContinuityManager(PlaybackActionManager):\ndef _save_changed_stream(self, stype, stream):\ncommon.debug('Save changed stream {} for {}'.format(stream, stype))\n- new_show_settings = self.show_settings.copy()\n- new_show_settings[stype] = stream\n- self.storage[self.current_videoid] = new_show_settings\n- self.storage.commit()\n+ new_sc_settings = self.sc_settings.copy()\n+ new_sc_settings[stype] = stream\n+ g.SHARED_DB.set_stream_continuity(g.LOCAL_DB.get_active_profile_guid(),\n+ self.current_videoid.value,\n+ new_sc_settings)\ndef __repr__(self):\nreturn ('enabled={}, current_videoid={}'\n@@ -119,11 +120,13 @@ def _show_only_forced_subtitle():\n# When we have \"forced only\" subtitle setting in Kodi Player, Kodi use this behavior:\n# 1) try to select forced subtitle that matches audio language\n# 2) when missing, try to select the first \"regular\" subtitle that matches audio language\n- # This Kodi behavior is totally non sense. If forced is selected you must not view the regular subtitles\n+ # This Kodi behavior is totally non sense.\n+ # If forced is selected you must not view the regular subtitles\n# There is no other solution than to disable the subtitles manually.\nmanifest_data = json.loads(common.load_file('manifest.json'))\ncommon.fix_locale_languages(manifest_data['timedtexttracks'])\naudio_language = common.get_kodi_audio_language()\n- if not any(text_track.get('isForcedNarrative', False) is True and text_track['language'] == audio_language\n+ if not any(text_track.get('isForcedNarrative', False) is True and\n+ text_track['language'] == audio_language\nfor text_track in manifest_data['timedtexttracks']):\nxbmc.Player().showSubtitles(False)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor stream_continuity to use db
106,046
05.08.2019 20:00:42
-7,200
df2f57b6a8612e802d1d6aecf87d11bb1c6e4292
Completely deleted the library cache
[ { "change_type": "MODIFY", "old_path": "resources/lib/cache.py", "new_path": "resources/lib/cache.py", "diff": "@@ -30,10 +30,9 @@ CACHE_SUPPLEMENTAL = 'cache_supplemental'\nCACHE_METADATA = 'cache_metadata'\nCACHE_INFOLABELS = 'cache_infolabels'\nCACHE_ARTINFO = 'cache_artinfo'\n-CACHE_LIBRARY = 'library'\nBUCKET_NAMES = [CACHE_COMMON, CACHE_GENRES, CACHE_SUPPLEMENTAL, CACHE_METADATA,\n- CACHE_INFOLABELS, CACHE_ARTINFO, CACHE_LIBRARY]\n+ CACHE_INFOLABELS, CACHE_ARTINFO]\nBUCKET_LOCKED = 'LOCKED_BY_{:04d}_AT_{}'\n@@ -156,7 +155,7 @@ class Cache(object):\n\"\"\"Return a lock marker for this instance and the current time\"\"\"\n# Return maximum timestamp for library to prevent stale lock\n# overrides which may lead to inconsistencies\n- timestamp = sys.maxint if bucket == CACHE_LIBRARY else int(time())\n+ timestamp = int(time())\nreturn str(BUCKET_LOCKED.format(self.plugin_handle, timestamp))\ndef get(self, bucket, identifier):\n@@ -167,7 +166,6 @@ class Cache(object):\ncache_entry = self._get_from_disk(bucket, identifier)\nself.add(bucket, identifier, cache_entry['content'])\n# Do not verify TTL on cache library, prevents the loss of exported objects\n- if not bucket == CACHE_LIBRARY:\nself.verify_ttl(bucket, identifier, cache_entry)\nreturn cache_entry['content']\n@@ -198,8 +196,6 @@ class Cache(object):\n\"\"\"Clear all cache buckets\"\"\"\n# pylint: disable=global-statement\nfor bucket in BUCKET_NAMES:\n- if bucket == CACHE_LIBRARY:\n- continue\nself.window.clearProperty(_window_property(bucket))\nif bucket in self.buckets:\ndel self.buckets[bucket]\n@@ -210,7 +206,6 @@ class Cache(object):\ndef _invalidate_on_disk(self):\nfor bucket in BUCKET_NAMES:\n- if bucket != CACHE_LIBRARY:\nself.common.delete_folder_contents(\nos.path.join(self.cache_path, bucket))\n@@ -288,11 +283,6 @@ class Cache(object):\nhandle.close()\ndef _entry_filename(self, bucket, identifier):\n- if bucket == CACHE_LIBRARY:\n- # We want a special handling for the library database, so users\n- # dont accidentally delete it when deleting the cache\n- file_loc = [os.path.dirname(self.cache_path), 'library.ndb2']\n- else:\nfile_loc = [self.cache_path, bucket, '{}.cache'.format(identifier)]\nreturn xbmc.translatePath(os.path.join(*file_loc))\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -182,7 +182,6 @@ class GlobalVariables(object):\nNeeds to be called at start of each plugin instance!\nThis is an ugly hack because Kodi doesn't execute statements defined on\nmodule level if reusing a language invoker.\"\"\"\n- self._library = None\nself.COOKIES = {}\nself.ADDON = xbmcaddon.Addon()\nself.ADDON_ID = self.ADDON.getAddonInfo('id')\n@@ -254,12 +253,7 @@ class GlobalVariables(object):\ndef _init_filesystem_cache(self):\n# pylint: disable=broad-except\nfor bucket in cache.BUCKET_NAMES:\n- if bucket != cache.CACHE_LIBRARY:\n- # Library gets special location in DATA_PATH root because\n- # we don't want users accidentally deleting it.\n- xbmcvfs.mkdirs(\n- xbmc.translatePath(\n- os.path.join(self.CACHE_PATH, bucket)))\n+ xbmcvfs.mkdirs(xbmc.translatePath(os.path.join(self.CACHE_PATH, bucket)))\ndef initial_addon_configuration(self):\n\"\"\"\n@@ -335,22 +329,6 @@ class GlobalVariables(object):\n\"\"\"\nreturn g.LOCAL_DB.get_value('suspend_settings_monitor', False)\n- def library(self):\n- \"\"\"Get the current library instance\"\"\"\n- # pylint: disable=global-statement, attribute-defined-outside-init\n- if not self._library:\n- try:\n- self._library = self.CACHE.get(cache.CACHE_LIBRARY, 'library')\n- except cache.CacheMiss:\n- self._library = {}\n- return self._library\n-\n- def save_library(self):\n- \"\"\"Save the library to disk via cache\"\"\"\n- if self._library is not None:\n- self.CACHE.add(cache.CACHE_LIBRARY, 'library', self._library,\n- ttl=cache.TTL_INFINITE, to_disk=True)\n-\ndef get_edge_esn(self):\n\"\"\"Get a previously generated edge ESN from the settings or generate\na new one if none exists\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Completely deleted the library cache
105,991
08.08.2019 20:44:28
-7,200
f1f7352e5bade1d695304b4b32dbb9bffe814d0b
Refactor compile_tasks functions are now divided into subsections and no unecessary calls will be made to the netflix server for metadata when something is removed from the library
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "\"\"\"Local database access and functions\"\"\"\nfrom __future__ import unicode_literals\n+import sqlite3 as sql\n+\nimport resources.lib.common as common\nimport resources.lib.database.db_base as db_base\nimport resources.lib.database.db_local as db_local\n@@ -43,6 +45,35 @@ class NFSharedDatabase(db_local.NFLocalDatabase):\nresult = cur.fetchone()\nreturn result[0] if result is not None else default_value\n+ @db_base.sql_connect()\n+ def get_all_episodes_ids_and_filepath_from_tvshow(self, tvshowid):\n+ \"\"\"Get all episodes IDs and filepaths for given id\"\"\"\n+ self.conn.row_factory = sql.Row\n+ query =\\\n+ ('SELECT VideoLibEpisodes.FilePath, VideoLibSeasons.TvShowID, '\n+ 'VideoLibEpisodes.SeasonID, VideoLibEpisodes.EpisodeID '\n+ 'FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'WHERE VideoLibSeasons.TvShowID = ?')\n+ cur = self._execute_query(query, (tvshowid,))\n+ result = cur.fetchall()\n+ return result\n+\n+ @db_base.sql_connect()\n+ def get_all_episodes_ids_and_filepath_from_season(self, tvshowid, seasonid):\n+ \"\"\"Get all episodes IDs and filepaths for given id\"\"\"\n+ self.conn.row_factory = sql.Row\n+ query =\\\n+ ('SELECT VideoLibEpisodes.FilePath, VideoLibSeasons.TvShowID, '\n+ 'VideoLibEpisodes.SeasonID, VideoLibEpisodes.EpisodeID '\n+ 'FROM VideoLibEpisodes '\n+ 'INNER JOIN VideoLibSeasons ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n+ 'WHERE VideoLibSeasons.TvShowID = ? AND '\n+ 'VideoLibSeasons.SeasonID = ?')\n+ cur = self._execute_query(query, (tvshowid, seasonid))\n+ result = cur.fetchall()\n+ return result\n+\n@db_base.sql_connect()\ndef get_random_episode_filepath_from_tvshow(self, tvshowid, default_value=None):\n\"\"\"Get random episode filepath of a show of a given id\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -133,11 +133,12 @@ def exclude_show_from_auto_update(videoid, exclude):\ndef update_kodi_library(library_operation):\n\"\"\"Decorator that ensures an update of the Kodi libarary\"\"\"\n+\n@wraps(library_operation)\ndef kodi_library_update_wrapper(videoid, task_handler, *args, **kwargs):\n\"\"\"Either trigger an update of the Kodi library or remove the\nitems associated with videoid, depending on the invoked task_handler\"\"\"\n- is_remove = task_handler == remove_item\n+ is_remove = task_handler == [remove_item]\nif is_remove:\n_remove_from_kodi_library(videoid)\nlibrary_operation(videoid, task_handler, *args, **kwargs)\n@@ -146,6 +147,7 @@ def update_kodi_library(library_operation):\n# This prevents a second call to cancel the update\ncommon.debug('Notify service to update the library')\ncommon.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n+\nreturn kodi_library_update_wrapper\n@@ -194,64 +196,80 @@ def purge():\ncommon.debug('Purging internal database and kodi library')\nfor videoid_value in g.SHARED_DB.get_movies_id_list():\nvideoid = common.VideoId.from_path([common.VideoId.MOVIE, videoid_value])\n- execute_library_tasks(videoid, remove_item,\n+ execute_library_tasks(videoid, [remove_item],\ncommon.get_local_string(30030),\nsync_mylist=False)\nfor videoid_value in g.SHARED_DB.get_tvshows_id_list():\nvideoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n- execute_library_tasks(videoid, remove_item,\n+ execute_library_tasks(videoid, [remove_item],\ncommon.get_local_string(30030),\nsync_mylist=False)\[email protected]_execution(immediate=False)\n-def compile_tasks(videoid, nfo_settings=None):\n+def compile_tasks(videoid, task_handler, nfo_settings=None):\n\"\"\"Compile a list of tasks for items based on the videoid\"\"\"\ncommon.debug('Compiling library tasks for {}'.format(videoid))\n+\n+ if task_handler == export_item:\nmetadata = api.metadata(videoid)\nif videoid.mediatype == common.VideoId.MOVIE:\n- return _create_movie_task(videoid, metadata[0], nfo_settings)\n+ return _create_export_movie_task(videoid, metadata[0], nfo_settings)\nelif videoid.mediatype in common.VideoId.TV_TYPES:\n- return _create_tv_tasks(videoid, metadata, nfo_settings)\n+ return _create_export_tv_tasks(videoid, metadata, nfo_settings)\nraise ValueError('Cannot handle {}'.format(videoid))\n+ if task_handler == export_new_item:\n+ metadata = api.metadata(videoid, True)\n+ return _create_new_episodes_tasks(videoid, metadata)\n-def _create_movie_task(videoid, movie, nfo_settings):\n+ if task_handler == remove_item:\n+ if videoid.mediatype == common.VideoId.MOVIE:\n+ return _create_remove_movie_task(videoid)\n+ elif videoid.mediatype == common.VideoId.SHOW:\n+ return _compile_remove_tvshow_tasks(videoid)\n+ elif videoid.mediatype == common.VideoId.SEASON:\n+ return _compile_remove_season_tasks(videoid)\n+ elif videoid.mediatype == common.VideoId.EPISODE:\n+ return _create_remove_episode_task(videoid)\n+\n+\n+def _create_export_movie_task(videoid, movie, nfo_settings):\n\"\"\"Create a task for a movie\"\"\"\n# Reset NFO export to false if we never want movies nfo\nname = '{title} ({year})'.format(title=movie['title'], year=movie['year'])\n- return [_create_item_task(name, FOLDER_MOVIES, videoid, name, name,\n+ return [_create_export_item_task(name, FOLDER_MOVIES, videoid, name, name,\nnfo.create_movie_nfo(movie) if\nnfo_settings and nfo_settings.export_movie_enabled else None)]\n-def _create_tv_tasks(videoid, metadata, nfo_settings):\n+def _create_export_tv_tasks(videoid, metadata, nfo_settings):\n\"\"\"Create tasks for a show, season or episode.\nIf videoid represents a show or season, tasks will be generated for\nall contained seasons and episodes\"\"\"\nif videoid.mediatype == common.VideoId.SHOW:\n- tasks = _compile_show_tasks(videoid, metadata[0], nfo_settings)\n+ tasks = _compile_export_show_tasks(videoid, metadata[0], nfo_settings)\nelif videoid.mediatype == common.VideoId.SEASON:\n- tasks = _compile_season_tasks(videoid,\n+ tasks = _compile_export_season_tasks(videoid,\nmetadata[0],\ncommon.find(int(videoid.seasonid),\n'id',\nmetadata[0]['seasons']),\nnfo_settings)\nelse:\n- tasks = [_create_episode_task(videoid, *metadata, nfo_settings=nfo_settings)]\n+ tasks = [_create_export_episode_task(videoid, *metadata, nfo_settings=nfo_settings)]\nif nfo_settings and nfo_settings.export_full_tvshow:\n# Create tvshow.nfo file\n# In episode metadata, show data is at 3rd position,\n# while it's at first position in show metadata.\n- # Best is to enumerate values to find the correct\n+ # Best is to enumerate values to find the correct key position\nkey_index = -1\nfor i in range(len(metadata)):\nif metadata[i] and metadata[i].get('type', None) == 'show':\nkey_index = i\nif key_index > -1:\n- tasks.append(_create_item_task('tvshow.nfo', FOLDER_TV, videoid,\n+ tasks.append(_create_export_item_task('tvshow.nfo', FOLDER_TV, videoid,\nmetadata[key_index]['title'],\n'tvshow',\nnfo.create_show_nfo(metadata[key_index]),\n@@ -259,34 +277,35 @@ def _create_tv_tasks(videoid, metadata, nfo_settings):\nreturn tasks\n-def _compile_show_tasks(videoid, show, nfo_settings):\n+def _compile_export_show_tasks(videoid, show, nfo_settings):\n\"\"\"Compile a list of task items for all episodes of all seasons\nof a tvshow\"\"\"\n# This nested comprehension is nasty but necessary. It flattens\n# the task lists for each season into one list\nreturn [task for season in show['seasons']\n- for task in _compile_season_tasks(\n+ for task in _compile_export_season_tasks(\nvideoid.derive_season(season['id']), show, season, nfo_settings)]\n-def _compile_season_tasks(videoid, show, season, nfo_settings):\n+def _compile_export_season_tasks(videoid, show, season, nfo_settings):\n\"\"\"Compile a list of task items for all episodes in a season\"\"\"\n- return [_create_episode_task(videoid.derive_episode(episode['id']),\n+ return [_create_export_episode_task(videoid.derive_episode(episode['id']),\nepisode, season, show, nfo_settings)\nfor episode in season['episodes']]\n-def _create_episode_task(videoid, episode, season, show, nfo_settings):\n+def _create_export_episode_task(videoid, episode, season, show, nfo_settings):\n\"\"\"Export a single episode to the library\"\"\"\nfilename = 'S{:02d}E{:02d}'.format(season['seq'], episode['seq'])\ntitle = ' - '.join((show['title'], filename, episode['title']))\n- return _create_item_task(title, FOLDER_TV, videoid, show['title'],\n- filename,\n+ return _create_export_item_task(\n+ title, FOLDER_TV, videoid, show['title'], filename,\nnfo.create_episode_nfo(episode, season, show)\nif nfo_settings and nfo_settings.export_tvshow_enabled else None)\n-def _create_item_task(title, section, videoid, destination, filename, nfo_data=None, is_strm=True):\n+def _create_export_item_task(title, section, videoid, destination, filename, nfo_data=None,\n+ is_strm=True):\n\"\"\"Create a single task item\"\"\"\nreturn {\n'title': title,\n@@ -301,16 +320,20 @@ def _create_item_task(title, section, videoid, destination, filename, nfo_data=N\ndef _create_new_episodes_tasks(videoid, metadata):\ntasks = []\n+ if metadata and 'seasons' in metadata[0]:\nfor season in metadata[0]['seasons']:\n- nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value, VidLibProp.nfo_export, False)\n+ nfo_export = g.SHARED_DB.get_tvshow_property(videoid.value,\n+ VidLibProp.nfo_export, False)\nnfo_settings = nfo.NFOSettings(nfo_export)\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(videoid.value, season['id'], episode['id']):\n- tasks.append(_create_episode_task(\n- videoid=videoid.derive_season(season['id']).derive_episode(episode['id']),\n+ if not g.SHARED_DB.episode_id_exists(\n+ videoid.value, season['id'], episode['id']):\n+ tasks.append(_create_export_episode_task(\n+ videoid=videoid.derive_season(\n+ season['id']).derive_episode(episode['id']),\nepisode=episode,\nseason=season,\nshow=metadata[0],\n@@ -319,7 +342,7 @@ def _create_new_episodes_tasks(videoid, metadata):\ncommon.debug('Auto exporting episode {}'.format(episode['id']))\nelse:\n# The season does not exist, build task for the season\n- tasks += _compile_season_tasks(\n+ tasks += _compile_export_season_tasks(\nvideoid=videoid.derive_season(season['id']),\nshow=metadata[0],\nseason=season,\n@@ -329,6 +352,62 @@ def _create_new_episodes_tasks(videoid, metadata):\nreturn tasks\n+def _create_remove_movie_task(videoid):\n+ filepath = g.SHARED_DB.get_movie_filepath(videoid.value)\n+ title = os.path.splitext(os.path.basename(filepath))[0]\n+ return [_create_remove_item_task(title, filepath, videoid)]\n+\n+\n+def _compile_remove_tvshow_tasks(videoid):\n+ row_results = g.SHARED_DB.get_all_episodes_ids_and_filepath_from_tvshow(videoid.value)\n+ return _create_remove_tv_tasks(row_results)\n+\n+\n+def _compile_remove_season_tasks(videoid):\n+ row_results = g.SHARED_DB.get_all_episodes_ids_and_filepath_from_season(\n+ videoid.tvshowid, videoid.seasonid)\n+ return _create_remove_tv_tasks(row_results)\n+\n+\n+def _create_remove_episode_task(videoid):\n+ filepath = g.SHARED_DB.get_episode_filepath(\n+ videoid.tvshowid, videoid.seasonid, videoid.episodeid)\n+ return [_create_remove_item_task(\n+ _episode_title_from_path(filepath),\n+ filepath, videoid)]\n+\n+\n+def _create_remove_tv_tasks(row_results):\n+ return [_create_remove_item_task(_episode_title_from_path(row[b'FilePath']),\n+ row[b'FilePath'],\n+ common.VideoId.from_dict(\n+ {'mediatype': common.VideoId.SHOW,\n+ 'tvshowid': row[b'TvShowID'],\n+ 'seasonid': row[b'SeasonID'],\n+ 'episodeid': row[b'EpisodeID']}))\n+ for row in row_results]\n+\n+\n+def _create_remove_item_task(title, filepath, videoid):\n+ \"\"\"Create a single task item\"\"\"\n+ return {\n+ 'title': title,\n+ 'filepath': filepath,\n+ 'videoid': videoid\n+ }\n+\n+\n+def _episode_title_from_path(filepath):\n+ fname = os.path.splitext(os.path.basename(filepath))[0]\n+ dir = os.path.split(os.path.split(filepath)[0])[1]\n+ return '{} - {}'.format(dir, fname)\n+\n+\n+# We need to differentiate task_handler for task creation, but we use the same export method\n+def export_new_item(item_task, library_home):\n+ export_item(item_task, library_home)\n+\n+\[email protected]_execution(immediate=False)\ndef export_item(item_task, library_home):\n\"\"\"Create strm file for an item and add it to the library\"\"\"\n@@ -390,20 +469,14 @@ def _add_to_library(videoid, export_filename, nfo_export):\ndef remove_item(item_task, library_home=None):\n\"\"\"Remove an item from the library and delete if from disk\"\"\"\n# pylint: disable=unused-argument, broad-except\n- if item_task['is_strm']: # We don't take care of a tvshow.nfo task if we are running an update\n+\ncommon.debug('Removing {} from library'.format(item_task['title']))\n- if not is_in_library(item_task['videoid']):\n- common.warn('cannot remove {}, item not in database library'\n- .format(item_task['title']))\n- return\n+\n+ exported_filename = xbmc.translatePath(item_task['filepath'])\nvideoid = item_task['videoid']\n- exported_filename = ''\n+ common.debug('VideoId: {}'.format(videoid))\ntry:\n- file_path, media_type = _get_library_entry(videoid)\n-\n- exported_filename = xbmc.translatePath(file_path)\nparent_folder = xbmc.translatePath(os.path.dirname(exported_filename))\n-\nxbmcvfs.delete(exported_filename.decode(\"utf-8\"))\n# Remove the NFO files if exists\nnfo_file = os.path.splitext(exported_filename.decode(\"utf-8\"))[0] + '.nfo'\n@@ -411,7 +484,7 @@ def remove_item(item_task, library_home=None):\nxbmcvfs.delete(nfo_file)\ndirs, files = xbmcvfs.listdir(parent_folder.decode(\"utf-8\"))\ntvshow_nfo_file = xbmc.makeLegalFilename(\n- os.path.join(parent_folder.decode(\"utf-8\"), 'tvshow.nfo'))\n+ '/'.join([parent_folder.decode(\"utf-8\"), '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@@ -433,19 +506,10 @@ def _remove_videoid_from_db(videoid):\n\"\"\"Removes records from database in relation to a videoid\"\"\"\nif videoid.mediatype == common.VideoId.MOVIE:\ng.SHARED_DB.delete_movie(videoid.value)\n- elif videoid.mediatype == common.VideoId.SHOW:\n- g.SHARED_DB.delete_tvshow(videoid.value)\n- elif videoid.mediatype == common.VideoId.SEASON:\n- g.SHARED_DB.delete_season(videoid.tvshowid, videoid.seasonid)\nelif videoid.mediatype == common.VideoId.EPISODE:\ng.SHARED_DB.delete_episode(videoid.tvshowid, videoid.seasonid, videoid.episodeid)\n-def update_item(item_task, library_home):\n- \"\"\"Remove and then re-export an item to the Kodi library\"\"\"\n- remove_item(item_task)\n- export_item(item_task, library_home)\n-\ndef _export_all_new_episodes_running():\nupdate = g.SHARED_DB.get_value('library_export_new_episodes_running', False)\n@@ -491,43 +555,35 @@ def export_new_episodes(videoid, scan=True):\n\"\"\"\nif videoid.mediatype == common.VideoId.SHOW:\ncommon.debug('Exporting new episodes for {}'.format(videoid))\n- # First let's fetch metadata of the show from api\n- metadata = api.metadata(videoid, True)\n- if metadata and 'seasons' in metadata[0]:\n- for task in _create_new_episodes_tasks(videoid, metadata):\n- try:\n- export_item(task, library_path())\n- except Exception:\n- import traceback\n- common.error(traceback.format_exc())\n- common.error('{} of {} failed'\n- .format(export_item.__name__, task['title']))\n-\n+ execute_library_tasks_silently(videoid, [export_new_item], False)\nif scan:\ncommon.debug('Notify service to update the library')\ncommon.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n- else:\n- common.debug('No tv show {} or no season returned from servers'.format(videoid))\nelse:\ncommon.debug('{} is not a tv show, no new episodes will be exported'.format(videoid))\n@update_kodi_library\n-def execute_library_tasks(videoid, task_handler, title, sync_mylist=True, nfo_settings=None):\n+def execute_library_tasks(videoid, task_handlers, title, sync_mylist=True, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and show errors in foreground\"\"\"\n+ for task_handler in task_handlers:\ncommon.execute_tasks(title=title,\n- tasks=compile_tasks(videoid, nfo_settings),\n+ tasks=compile_tasks(videoid, task_handler, nfo_settings),\ntask_handler=task_handler,\nnotify_errors=True,\nlibrary_home=library_path())\n+\n+ # Exclude update operations\n+ if task_handlers != [remove_item, export_item]:\n_sync_mylist(videoid, task_handler, sync_mylist)\n@update_kodi_library\n-def execute_library_tasks_silently(videoid, task_handler, sync_mylist, nfo_settings=None):\n+def execute_library_tasks_silently(videoid, task_handlers, sync_mylist, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and don't show any GUI feedback\"\"\"\n# pylint: disable=broad-except\n- for task in compile_tasks(videoid, nfo_settings):\n+ for task_handler in task_handlers:\n+ for task in compile_tasks(videoid, task_handler, nfo_settings):\ntry:\ntask_handler(task, library_path())\nexcept Exception:\n@@ -535,7 +591,7 @@ def execute_library_tasks_silently(videoid, task_handler, sync_mylist, nfo_setti\ncommon.error(traceback.format_exc())\ncommon.error('{} of {} failed'\n.format(task_handler.__name__, task['title']))\n- if sync_mylist:\n+ if sync_mylist and (task_handlers != [remove_item, export_item]):\n_sync_mylist(videoid, task_handler, sync_mylist)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -25,7 +25,7 @@ class LibraryActionExecutor(object):\nnfo_settings = nfo.NFOSettings()\nnfo_settings.show_export_dialog(videoid.mediatype)\nlibrary.execute_library_tasks(videoid,\n- library.export_item,\n+ [library.export_item],\ncommon.get_local_string(30018),\nnfo_settings=nfo_settings)\n@@ -34,7 +34,7 @@ class LibraryActionExecutor(object):\n\"\"\"Remove an item from the Kodi library\"\"\"\nif ui.ask_for_removal_confirmation():\nlibrary.execute_library_tasks(videoid,\n- library.remove_item,\n+ [library.remove_item],\ncommon.get_local_string(30030))\ncommon.refresh_container()\n@@ -44,7 +44,7 @@ class LibraryActionExecutor(object):\nnfo_settings = nfo.NFOSettings()\nnfo_settings.show_export_dialog(videoid.mediatype)\nlibrary.execute_library_tasks(videoid,\n- library.update_item,\n+ [library.remove_item, library.export_item],\ncommon.get_local_string(30061),\nnfo_settings=nfo_settings)\ncommon.refresh_container()\n@@ -59,7 +59,7 @@ class LibraryActionExecutor(object):\nnfo_settings = nfo.NFOSettings()\nnfo_settings.show_export_dialog(videoid.mediatype, common.get_local_string(30191))\nlibrary.execute_library_tasks_silently(\n- videoid, library.export_item,\n+ videoid, [library.export_item],\nself.params.get('sync_mylist', False),\nnfo_settings)\n@@ -69,7 +69,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+ videoid, [library.remove_item],\nself.params.get('sync_mylist', False))\n# Not used for now\n@@ -79,7 +79,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.update_item,\n+ # videoid, [library.remove_item, library.export_item],\n# self.params.get('sync_mylist', False))\ndef initial_mylist_sync(self, pathitems):\n@@ -95,7 +95,7 @@ class LibraryActionExecutor(object):\nnfo_settings.show_export_dialog()\nfor videoid in api.video_list(\napi.list_id_for_type('queue')).videoids:\n- library.execute_library_tasks(videoid, library.export_item,\n+ library.execute_library_tasks(videoid, [library.export_item],\ncommon.get_local_string(30018),\nsync_mylist=False,\nnfo_settings=nfo_settings)\n@@ -110,7 +110,7 @@ class LibraryActionExecutor(object):\ndef migrate(self, pathitems):\n\"\"\"Migrate exported items from old library format to the new format\"\"\"\nfor videoid in library.get_previously_exported_items():\n- library.execute_library_tasks(videoid, library.export_item,\n+ library.execute_library_tasks(videoid, [library.export_item],\ncommon.get_local_string(30018),\nsync_mylist=False)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Refactor compile_tasks functions are now divided into subsections and no unecessary calls will be made to the netflix server for metadata when something is removed from the library
105,991
08.08.2019 20:48:02
-7,200
4a0632a4815950b6838f59619b5bd0a3f7c1432c
Fixed issue with paths containing % os.path.join it is the cause of issues with paths containing '%' (like for '3 %' tvshow) so instead use: xbmc.makeLegalFilename('/'.join
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -412,8 +412,8 @@ 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 = xbmc.makeLegalFilename(os.path.join(\n- library_home, item_task['section'], item_task['destination']))\n+ destination_folder = xbmc.makeLegalFilename('/'.join(\n+ [library_home, item_task['section'], item_task['destination']]))\n_create_destination_folder(destination_folder)\nif item_task['is_strm']:\nexport_filename = xbmc.makeLegalFilename('/'.join(\n@@ -612,7 +612,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 file in xbmcvfs.listdir(folder)[1]:\n- filepath = os.path.join(folder, file.decode('utf-8'))\n+ filepath = xbmc.makeLegalFilename('/'.join([folder, file.decode('utf-8')]))\nif filepath.endswith('.strm'):\ncommon.debug('Trying to migrate {}'.format(filepath))\ntry:\n@@ -628,8 +628,9 @@ def get_previously_exported_items():\ndef _lib_folders(section):\n- section_dir = xbmc.translatePath(os.path.join(library_path(), section))\n- return [os.path.join(section_dir, folder.decode('utf-8'))\n+ section_dir = xbmc.translatePath(\n+ xbmc.makeLegalFilename('/'.join([library_path(), section])))\n+ return [xbmc.makeLegalFilename('/'.join([section_dir, folder.decode('utf-8')]))\nfor folder\nin xbmcvfs.listdir(section_dir)[0]]\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed issue with paths containing % os.path.join it is the cause of issues with paths containing '%' (like for '3 %' tvshow) so instead use: xbmc.makeLegalFilename('/'.join
106,046
09.08.2019 20:58:54
-7,200
1ed7a1aa1f1262e78a5ff2c35f713ec4b9c3e00a
Reintroduced manual ESN
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -57,7 +57,10 @@ def extract_session_data(content):\napi_data = extract_api_data(react_context)\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- g.LOCAL_DB.set_value('esn', generate_esn(user_data), TABLE_SESSION)\n+ esn_generated = generate_esn(user_data)\n+ if not g.ADDON.getSetting('esn'):\n+ g.LOCAL_DB.set_value('esn', esn_generated, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('esn_generated', esn_generated, TABLE_SESSION)\ng.LOCAL_DB.set_value('locale_id', user_data.get('preferredLocale').get('id', 'en-US'))\n# Save api urls\nfor key, path in api_data.items():\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -6,7 +6,7 @@ from __future__ import unicode_literals\nimport xbmc\nimport sys\n-from resources.lib.database.db_utils import (TABLE_SETTINGS_MONITOR)\n+from resources.lib.database.db_utils import (TABLE_SETTINGS_MONITOR, TABLE_SESSION)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\n@@ -24,6 +24,21 @@ class SettingsMonitor(xbmc.Monitor):\ng.init_globals(sys.argv)\n+ custom_esn = g.ADDON.getSetting('esn')\n+ stored_esn = g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\n+ if custom_esn:\n+ # Use a custom esn\n+ if custom_esn != stored_esn:\n+ g.LOCAL_DB.set_value('esn', custom_esn, table=TABLE_SESSION)\n+ common.send_signal(signal=common.Signals.ESN_CHANGED, data=custom_esn)\n+ else:\n+ esn_generated = g.LOCAL_DB.get_value('esn_generated', table=TABLE_SESSION)\n+ if stored_esn != esn_generated:\n+ # Custom esn erased, use the generated one\n+ esn_generated = g.LOCAL_DB.get_value('esn_generated', table=TABLE_SESSION)\n+ g.LOCAL_DB.set_value('esn', esn_generated, table=TABLE_SESSION)\n+ common.send_signal(signal=common.Signals.ESN_CHANGED, data=esn_generated)\n+\nshow_menu_changed = False\nsort_order_type_changed = False\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Reintroduced manual ESN
105,991
11.08.2019 16:51:17
-7,200
2800133c6d939b7dd3041b9cd7fc2d54e8b92bed
Migrate old file cache library to database at addon upgrade
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -419,7 +419,7 @@ def export_item(item_task, library_home):\nif item_task['is_strm']:\nexport_filename = xbmc.makeLegalFilename('/'.join(\n[destination_folder.decode('utf-8'), item_task['filename'] + '.strm']))\n- _add_to_library(item_task['videoid'], export_filename, (item_task['nfo_data'] is not None))\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:\nnfo_filename = xbmc.makeLegalFilename('/'.join(\n@@ -455,10 +455,10 @@ def _write_nfo_file(nfo_data, nfo_filename):\nfilehandle.close()\n-def _add_to_library(videoid, export_filename, nfo_export):\n+def add_to_library(videoid, export_filename, nfo_export, exclude_update=False):\n\"\"\"Add an exported file to the library\"\"\"\nif videoid.mediatype == common.VideoId.EPISODE:\n- g.SHARED_DB.set_tvshow(videoid.tvshowid, nfo_export, False)\n+ g.SHARED_DB.set_tvshow(videoid.tvshowid, nfo_export, exclude_update)\ng.SHARED_DB.insert_season(videoid.tvshowid, videoid.seasonid)\ng.SHARED_DB.insert_episode(videoid.tvshowid, videoid.seasonid, videoid.value,\nexport_filename.decode(\"utf-8\"))\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/upgrade_actions.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Defines upgrade actions\"\"\"\n+from __future__ import unicode_literals\n+\n+import os\n+\n+import xbmc\n+import xbmcvfs\n+\n+import resources.lib.common as common\n+import resources.lib.kodi.library as library\n+from resources.lib.globals import g\n+\n+try:\n+ import cPickle as pickle\n+except ImportError:\n+ import pickle\n+\n+\n+def migrate_library_to_db():\n+ common.debug('Migrate library from file cache library.ndb2 to database')\n+ file_loc = [g.DATA_PATH, 'library.ndb2']\n+ library_file = xbmc.translatePath(os.path.join(*file_loc))\n+\n+ if xbmcvfs.exists(library_file):\n+ handle = xbmcvfs.File(library_file, 'r')\n+ lib = pickle.loads(handle.read())\n+ handle.close()\n+ for item in lib['content'].values():\n+ videoid = item['videoid']\n+ if videoid.mediatype == common.VideoId.MOVIE:\n+ library.add_to_library(videoid, item['file'], False, False)\n+ elif videoid.mediatype == common.VideoId.SHOW:\n+ for season_key in item.keys():\n+ if season_key not in ['videoid', 'nfo_export', 'exclude_from_update']:\n+ for episode_key in item[season_key].keys():\n+ if episode_key not in ['videoid', 'nfo_export']:\n+ library.add_to_library(item[season_key][episode_key]['videoid'],\n+ item[season_key][episode_key]['file'],\n+ item.get('nfo_export', False),\n+ item.get('exclude_from_update', False))\n+ xbmcvfs.rename(library_file, library_file + '.bak')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "@@ -4,6 +4,7 @@ from __future__ import unicode_literals\nimport resources.lib.common as common\n+import resources.lib.upgrade_actions as upgrade_actions\nfrom resources.lib.globals import g\nfrom resources.lib.database.db_update import run_local_db_updates, run_shared_db_updates\n@@ -36,7 +37,6 @@ def _perform_addon_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\ncommon.debug('Initialize addon upgrade operations, from version {} to {})'\n.format(previous_ver, current_ver))\n- # <Do something here>\n# Always leave this to last - After the operations set current version\ng.LOCAL_DB.set_value('addon_previous_version', current_ver)\n@@ -45,7 +45,8 @@ def _perform_service_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\ncommon.debug('Initialize service upgrade operations, from version {} to {})'\n.format(previous_ver, current_ver))\n- # <Do something here>\n+ if previous_ver is None:\n+ upgrade_actions.migrate_library_to_db()\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
Migrate old file cache library to database at addon upgrade
105,991
06.08.2019 03:11:22
-7,200
4c3cf2c92225bb7e0b79435f545e49493776e5fe
Fix upnext from library
[ { "change_type": "MODIFY", "old_path": "resources/lib/navigation/player.py", "new_path": "resources/lib/navigation/player.py", "diff": "@@ -11,6 +11,7 @@ from resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.api.shakti as api\nimport resources.lib.kodi.infolabels as infolabels\n+import resources.lib.kodi.library as library\nimport resources.lib.kodi.ui as ui\nfrom resources.lib.services.playback import get_timeline_markers\n@@ -147,10 +148,19 @@ def get_upnext_info(videoid, current_episode, metadata):\nxbmcgui.ListItem())\nnext_info = {\n'current_episode': upnext_info(videoid, *current_episode),\n- 'next_episode': upnext_info(next_episode_id, *next_episode),\n- 'play_info': {'play_path': common.build_url(videoid=next_episode_id,\n- mode=g.MODE_PLAY)},\n+ 'next_episode': upnext_info(next_episode_id, *next_episode)\n}\n+\n+ if (xbmc.getInfoLabel('Container.PluginName') != g.ADDON.getAddonInfo('id')\n+ and 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': xbmc.translatePath(filepath)}\n+ else:\n+ next_info['play_info'] = {'play_path': common.build_url(\n+ videoid = next_episode_id, mode = g.MODE_PLAY)}\nif 'creditsOffset' in metadata[0]:\nnext_info['notification_time'] = (metadata[0]['runtime'] -\nmetadata[0]['creditsOffset'])\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix upnext from library
105,991
06.08.2019 07:43:29
-7,200
2490792820ef6773ed029dc7ffb9ea7d292ca92e
Display progress bar when exporting new episodes manually
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -807,3 +807,7 @@ msgstr \"\"\nmsgctxt \"#30197\"\nmsgid \"Include in auto update\"\nmsgstr \"\"\n+\n+msgctxt \"#30198\"\n+msgid \"Exporting new episodes\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -538,7 +538,7 @@ def export_all_new_episodes():\nfor videoid_value in g.SHARED_DB.get_tvshows_id_list(VidLibProp.exclude_update, False):\nvideoid = common.VideoId.from_path([common.VideoId.SHOW, videoid_value])\n- export_new_episodes(videoid, False)\n+ export_new_episodes(videoid, True)\n# add some randomness between show analysis to limit servers load and ban risks\nxbmc.sleep(random.randint(1000, 5001))\n@@ -547,19 +547,22 @@ def export_all_new_episodes():\ncommon.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n-def export_new_episodes(videoid, scan=True):\n+def export_new_episodes(videoid, silent=False):\n\"\"\"\nExport new episodes for a tv show by it's video id\n:param videoid: The videoid of the tv show to process\n:param scan: Whether or not to scan the library after exporting, useful for a single show\n+ :param silent: don't display user interface while exporting\n:return: None\n\"\"\"\n+\n+ method = execute_library_tasks_silently if silent else execute_library_tasks\n+\nif videoid.mediatype == common.VideoId.SHOW:\ncommon.debug('Exporting new episodes for {}'.format(videoid))\n- execute_library_tasks_silently(videoid, [export_new_item], False)\n- if scan:\n- common.debug('Notify service to update the library')\n- common.send_signal(common.Signals.LIBRARY_UPDATE_REQUESTED)\n+ method(videoid, [export_new_item],\n+ title=common.get_local_string(30198),\n+ sync_mylist=False)\nelse:\ncommon.debug('{} is not a tv show, no new episodes will be exported'.format(videoid))\n@@ -580,7 +583,8 @@ def execute_library_tasks(videoid, task_handlers, title, sync_mylist=True, nfo_s\n@update_kodi_library\n-def execute_library_tasks_silently(videoid, task_handlers, sync_mylist, nfo_settings=None):\n+def execute_library_tasks_silently(videoid, task_handlers, title=None,\n+ sync_mylist=False, nfo_settings=None):\n\"\"\"Execute library tasks for videoid and don't show any GUI feedback\"\"\"\n# pylint: disable=broad-except\nfor task_handler in task_handlers:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -60,8 +60,8 @@ 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- self.params.get('sync_mylist', False),\n- nfo_settings)\n+ sync_mylist=self.params.get('sync_mylist', False),\n+ nfo_settings=nfo_settings)\[email protected]_video_id(path_offset=1)\ndef remove_silent(self, videoid):\n@@ -70,7 +70,7 @@ class LibraryActionExecutor(object):\nlist and Kodi library and do no sync, if not explicitly asked to.\"\"\"\nlibrary.execute_library_tasks_silently(\nvideoid, [library.remove_item],\n- self.params.get('sync_mylist', False))\n+ sync_mylist=self.params.get('sync_mylist', False))\n# Not used for now\n# @common.inject_video_id(path_offset=1)\n@@ -80,7 +80,7 @@ class LibraryActionExecutor(object):\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- # self.params.get('sync_mylist', False))\n+ # sync_mylist=self.params.get('sync_mylist', False))\ndef initial_mylist_sync(self, pathitems):\n\"\"\"Perform an initial sync of My List and the Kodi library\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Display progress bar when exporting new episodes manually
106,046
11.08.2019 18:30:56
-7,200
0be5d97cf9812803fd0fa346505b2ce3a4b65554
Simplified code for manual ESN
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -57,10 +57,7 @@ def extract_session_data(content):\napi_data = extract_api_data(react_context)\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- esn_generated = generate_esn(user_data)\n- if not g.ADDON.getSetting('esn'):\n- g.LOCAL_DB.set_value('esn', esn_generated, TABLE_SESSION)\n- g.LOCAL_DB.set_value('esn_generated', esn_generated, TABLE_SESSION)\n+ g.LOCAL_DB.set_value('esn', generate_esn(user_data), TABLE_SESSION)\ng.LOCAL_DB.set_value('locale_id', user_data.get('preferredLocale').get('id', 'en-US'))\n# Save api urls\nfor key, path in api_data.items():\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -8,15 +8,15 @@ All other code executed on module level will only be executed once, when\nthe module is first imported on the first addon invocation.\"\"\"\nfrom __future__ import unicode_literals\n+import collections\nimport os\nimport sys\n-from urlparse import urlparse, parse_qsl\nfrom urllib import unquote\n-import collections\nimport xbmc\nimport xbmcaddon\nimport xbmcvfs\n+from urlparse import urlparse, parse_qsl\nimport resources.lib.cache as cache\n@@ -329,6 +329,12 @@ class GlobalVariables(object):\n\"\"\"\nreturn g.LOCAL_DB.get_value('suspend_settings_monitor', False)\n+ def get_esn(self):\n+ \"\"\"Get the generated esn or if set get the custom esn\"\"\"\n+ from resources.lib.database.db_utils import (TABLE_SESSION)\n+ custom_esn = g.ADDON.getSetting('esn')\n+ return custom_esn if custom_esn else g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\n+\ndef get_edge_esn(self):\n\"\"\"Get a previously generated edge ESN from the settings or generate\na new one if none exists\"\"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -15,7 +15,6 @@ from functools import wraps\nimport requests\nimport xbmcaddon\n-from resources.lib.database.db_utils import (TABLE_SESSION)\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n@@ -80,7 +79,7 @@ class MSLHandler(object):\ndef perform_key_handshake(self, data=None):\n\"\"\"Perform a key handshake and initialize crypto keys\"\"\"\n# pylint: disable=unused-argument\n- esn = data or g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\n+ esn = data or g.get_esn()\nif not esn:\ncommon.info('Cannot perform key handshake, missing ESN')\nreturn False\n@@ -107,7 +106,7 @@ class MSLHandler(object):\n:param viewable_id: The id of of the viewable\n:return: MPD XML Manifest or False if no success\n\"\"\"\n- manifest = self._load_manifest(viewable_id, g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\n+ manifest = self._load_manifest(viewable_id, g.get_esn())\n# Disable 1080p Unlock for now, as it is broken due to Netflix changes\n# if (g.ADDON.getSettingBool('enable_1080p_unlock') and\n# not g.ADDON.getSettingBool('enable_vp9_profiles') and\n@@ -215,7 +214,7 @@ class MSLHandler(object):\n'version': 2,\n'url': self.last_license_url,\n'id': id,\n- 'esn': g.LOCAL_DB.get_value('esn', table=TABLE_SESSION),\n+ 'esn': g.get_esn(),\n'languages': [g.LOCAL_DB.get_value('locale_id')],\n'uiVersion': 'shakti-v5bca5cd3',\n'clientVersion': '6.0013.315.051',\n@@ -228,9 +227,7 @@ class MSLHandler(object):\n'echo': 'sessionId'\n}\n- response = self._chunked_request(ENDPOINTS['license'],\n- license_request_data,\n- g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\n+ response = self._chunked_request(ENDPOINTS['license'], license_request_data, g.get_esn())\nreturn response[0]['licenseResponseBase64']\[email protected]_execution(immediate=True)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -98,7 +98,7 @@ class NetflixSession(object):\nself.session.headers.update(\n{'x-netflix.request.client.user.guid': g.LOCAL_DB.get_active_profile_guid()})\ncookies.save(self.account_hash, self.session.cookies)\n- _update_esn(g.LOCAL_DB.get_value('esn', table=TABLE_SESSION))\n+ _update_esn(g.get_esn())\n@property\ndef auth_url(self):\n@@ -463,7 +463,7 @@ def _set_esn(esn):\nSet the ESN in settings if it hasn't been set yet.\nReturn True if the new ESN has been set, False otherwise\n\"\"\"\n- if not g.LOCAL_DB.get_value('esn', table=TABLE_SESSION) and esn:\n+ if not g.get_esn() and esn:\ng.LOCAL_DB.set_value('esn', esn, table=TABLE_SESSION)\nreturn True\nreturn False\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -24,20 +24,12 @@ class SettingsMonitor(xbmc.Monitor):\ng.init_globals(sys.argv)\n+ # Check if the custom esn is changed\ncustom_esn = g.ADDON.getSetting('esn')\n- stored_esn = g.LOCAL_DB.get_value('esn', table=TABLE_SESSION)\n- if custom_esn:\n- # Use a custom esn\n- if custom_esn != stored_esn:\n- g.LOCAL_DB.set_value('esn', custom_esn, table=TABLE_SESSION)\n- common.send_signal(signal=common.Signals.ESN_CHANGED, data=custom_esn)\n- else:\n- esn_generated = g.LOCAL_DB.get_value('esn_generated', table=TABLE_SESSION)\n- if stored_esn != esn_generated:\n- # Custom esn erased, use the generated one\n- esn_generated = g.LOCAL_DB.get_value('esn_generated', table=TABLE_SESSION)\n- g.LOCAL_DB.set_value('esn', esn_generated, table=TABLE_SESSION)\n- common.send_signal(signal=common.Signals.ESN_CHANGED, data=esn_generated)\n+ custom_esn_old = g.LOCAL_DB.get_value('custom_esn', '', TABLE_SETTINGS_MONITOR)\n+ if custom_esn != custom_esn_old:\n+ g.LOCAL_DB.set_value('custom_esn', custom_esn, TABLE_SETTINGS_MONITOR)\n+ common.send_signal(signal=common.Signals.ESN_CHANGED, data=g.get_esn())\nshow_menu_changed = False\nsort_order_type_changed = False\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Simplified code for manual ESN
106,046
15.08.2019 18:21:29
-7,200
3707affd7fe663d872d80c6a4329bdc749bcffd4
Renamed table names to make them compatible to different MySQL MariaDB and MySQL server have different requirements
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_local.py", "new_path": "resources/lib/database/db_local.py", "diff": "@@ -12,7 +12,7 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\nsuper(NFLocalDatabase, self).__init__(db_utils.LOCAL_DB_FILENAME)\ndef _get_active_guid_profile(self):\n- query = 'SELECT Guid FROM Profiles WHERE IsActive = 1'\n+ query = 'SELECT Guid FROM profiles WHERE IsActive = 1'\ncur = self._execute_query(query)\nresult = cur.fetchone()\nif result is None:\n@@ -23,17 +23,17 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\ndef get_profile_config(self, key, default_value=None, guid=None):\n\"\"\"Get a value from a profile, if guid is not specified, is obtained from active profile\"\"\"\nif guid is None:\n- query = ('SELECT Value FROM ProfilesConfig '\n- 'INNER JOIN Profiles ON ProfilesConfig.Guid = Profiles.Guid '\n+ query = ('SELECT Value FROM profiles_config '\n+ 'INNER JOIN profiles ON profiles_config.Guid = profiles.Guid '\n'WHERE '\n- 'Profiles.IsActive = 1 AND '\n- 'ProfilesConfig.Name = ?')\n+ 'profiles.IsActive = 1 AND '\n+ 'profiles_config.Name = ?')\ncur = self._execute_query(query, (key,))\nelse:\n- query = ('SELECT Value FROM ProfilesConfig '\n+ query = ('SELECT Value FROM profiles_config '\n'WHERE '\n- 'ProfilesConfig.Guid = ? AND '\n- 'ProfilesConfig.Name = ?')\n+ 'profiles_config.Guid = ? AND '\n+ 'profiles_config.Name = ?')\ncur = self._execute_query(query, (guid, key))\nresult = cur.fetchone()\nreturn result[0] if result else default_value\n@@ -44,37 +44,37 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\n# Update or insert approach, if there is no updated row then insert new one (no id changes)\nif not guid:\nguid = self._get_active_guid_profile()\n- update_query = 'UPDATE ProfilesConfig SET Value = ? WHERE Guid = ? AND Name = ?'\n+ update_query = 'UPDATE profiles_config SET Value = ? WHERE Guid = ? AND Name = ?'\ncur = self._execute_query(update_query, (value, guid, key))\nif cur.rowcount == 0:\n- insert_query = 'INSERT INTO ProfilesConfig (Guid, Name, Value) VALUES (?, ?, ?)'\n+ insert_query = 'INSERT INTO profiles_config (Guid, Name, Value) VALUES (?, ?, ?)'\nself._execute_non_query(insert_query, (guid, key, value))\n@db_sqlite.handle_connection\ndef set_profile(self, guid, is_active, sort_order):\n\"\"\"Update or Insert a profile\"\"\"\n# Update or insert approach, if there is no updated row then insert new one (no id changes)\n- data = db_utils.sql_filtered_update('Profiles',\n+ data = db_utils.sql_filtered_update('profiles',\n['IsActive', 'SortOrder'],\n['Guid'],\n[is_active, sort_order, guid])\ncur = self._execute_query(data[0], data[1])\nif cur.rowcount == 0:\n- data = db_utils.sql_filtered_insert('Profiles',\n+ data = db_utils.sql_filtered_insert('profiles',\n['Guid', 'IsActive', 'SortOrder'],\n[guid, is_active, sort_order])\nself._execute_non_query(data[0], data[1])\n@db_sqlite.handle_connection\ndef switch_active_profile(self, guid):\n- update_query = 'UPDATE Profiles SET IsActive = 0'\n+ update_query = 'UPDATE profiles SET IsActive = 0'\nself._execute_non_query(update_query)\n- update_query = 'UPDATE Profiles SET IsActive = 1 WHERE Guid = ?'\n+ update_query = 'UPDATE profiles SET IsActive = 1 WHERE Guid = ?'\nself._execute_non_query(update_query, (guid,))\n@db_sqlite.handle_connection\ndef delete_profile(self, guid):\n- query = 'DELETE FROM Profiles WHERE Guid = ?'\n+ query = 'DELETE FROM profiles WHERE Guid = ?'\nself._execute_non_query(query, (guid,))\n@db_sqlite.handle_connection\n@@ -83,6 +83,6 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\n@db_sqlite.handle_connection\ndef get_guid_profiles(self):\n- query = 'SELECT Guid FROM Profiles ORDER BY SortOrder'\n+ query = 'SELECT Guid FROM profiles ORDER BY SortOrder'\ncur = self._execute_query(query)\nreturn [row[0] for row in cur.fetchall()]\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "@@ -33,13 +33,13 @@ def get_shareddb_class(force_sqlite=False):\nquery = db_utils.mysql_insert_or_update('profiles', ['Guid'], ['SortOrder'])\nself._execute_non_query(query, (guid, sort_order), multi=True)\nelse:\n- data = db_utils.sql_filtered_update('Profiles',\n+ data = db_utils.sql_filtered_update('profiles',\n['SortOrder'],\n['Guid'],\n[sort_order, guid])\ncur = self._execute_query(data[0], data[1])\nif cur.rowcount == 0:\n- data = db_utils.sql_filtered_insert('Profiles',\n+ data = db_utils.sql_filtered_insert('profiles',\n['Guid', 'SortOrder'],\n[guid, sort_order])\nself._execute_non_query(data[0], data[1])\n@@ -47,14 +47,14 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef delete_profile(self, guid):\n- query = 'DELETE FROM Profiles WHERE Guid = ?'\n+ query = 'DELETE FROM profiles WHERE Guid = ?'\nself._execute_non_query(query, (guid,))\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef get_movie_filepath(self, movieid, default_value=None):\n\"\"\"Get movie filepath for given id\"\"\"\n- query = 'SELECT FilePath FROM VideoLibMovies WHERE MovieID = ?'\n+ query = 'SELECT FilePath FROM video_lib_movies WHERE MovieID = ?'\ncur = self._execute_query(query, (movieid,))\nresult = cur.fetchone()\nreturn result[0] if result else default_value\n@@ -64,12 +64,12 @@ def get_shareddb_class(force_sqlite=False):\ndef get_episode_filepath(self, tvshowid, seasonid, episodeid, default_value=None):\n\"\"\"Get movie filepath for given id\"\"\"\nquery =\\\n- ('SELECT FilePath FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'WHERE VideoLibSeasons.TvShowID = ? AND '\n- 'VideoLibSeasons.SeasonID = ? AND '\n- 'VideoLibEpisodes.EpisodeID = ?')\n+ ('SELECT FilePath FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'WHERE video_lib_seasons.TvShowID = ? AND '\n+ 'video_lib_seasons.SeasonID = ? AND '\n+ 'video_lib_episodes.EpisodeID = ?')\ncur = self._execute_query(query, (tvshowid, seasonid, episodeid))\nresult = cur.fetchone()\nreturn result[0] if result is not None else default_value\n@@ -80,12 +80,12 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Get all episodes IDs and filepaths for given id\"\"\"\ncur = self.get_cursor_for_dict_results()\nquery =\\\n- ('SELECT VideoLibEpisodes.FilePath, VideoLibSeasons.TvShowID, '\n- 'VideoLibEpisodes.SeasonID, VideoLibEpisodes.EpisodeID '\n- 'FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'WHERE VideoLibSeasons.TvShowID = ?')\n+ ('SELECT video_lib_episodes.FilePath, video_lib_seasons.TvShowID, '\n+ 'video_lib_episodes.SeasonID, video_lib_episodes.EpisodeID '\n+ 'FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'WHERE video_lib_seasons.TvShowID = ?')\ncur = self._execute_query(query, (tvshowid,), cur)\nreturn cur.fetchall()\n@@ -95,13 +95,13 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Get all episodes IDs and filepaths for given id\"\"\"\ncur = self.get_cursor_for_dict_results()\nquery =\\\n- ('SELECT VideoLibEpisodes.FilePath, VideoLibSeasons.TvShowID, '\n- 'VideoLibEpisodes.SeasonID, VideoLibEpisodes.EpisodeID '\n- 'FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'WHERE VideoLibSeasons.TvShowID = ? AND '\n- 'VideoLibSeasons.SeasonID = ?')\n+ ('SELECT video_lib_episodes.FilePath, video_lib_seasons.TvShowID, '\n+ 'video_lib_episodes.SeasonID, video_lib_episodes.EpisodeID '\n+ 'FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'WHERE video_lib_seasons.TvShowID = ? AND '\n+ 'video_lib_seasons.SeasonID = ?')\ncur = self._execute_query(query, (tvshowid, seasonid), cur)\nreturn cur.fetchall()\n@@ -111,10 +111,10 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Get random episode filepath of a show of a given id\"\"\"\nrand_func_name = 'RAND()' if self.is_mysql_database else 'RANDOM()'\nquery =\\\n- ('SELECT FilePath FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'WHERE VideoLibSeasons.TvShowID = ? '\n+ ('SELECT FilePath FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'WHERE video_lib_seasons.TvShowID = ? '\n'ORDER BY {} LIMIT 1').format(rand_func_name)\ncur = self._execute_query(query, (tvshowid,))\nresult = cur.fetchone()\n@@ -126,10 +126,10 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Get random episode filepath of a show of a given id\"\"\"\nrand_func_name = 'RAND()' if self.is_mysql_database else 'RANDOM()'\nquery =\\\n- ('SELECT FilePath FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'WHERE VideoLibSeasons.TvShowID = ? AND VideoLibSeasons.SeasonID = ? '\n+ ('SELECT FilePath FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'WHERE video_lib_seasons.TvShowID = ? AND video_lib_seasons.SeasonID = ? '\n'ORDER BY {} LIMIT 1').format(rand_func_name)\ncur = self._execute_query(query, (tvshowid, seasonid))\nresult = cur.fetchone()\n@@ -140,9 +140,9 @@ def get_shareddb_class(force_sqlite=False):\ndef get_all_video_id_list(self):\n\"\"\"Get all the ids of movies and tvshows contained in the library\"\"\"\ncur = self.get_cursor_for_list_results()\n- query = ('SELECT MovieID FROM VideoLibMovies '\n+ query = ('SELECT MovieID FROM video_lib_movies '\n'UNION '\n- 'SELECT TvShowID FROM VideoLibTvShows')\n+ 'SELECT TvShowID FROM video_lib_tvshows')\ncur = self._execute_query(query, cursor=cur)\nreturn self.return_rows_as_list(cur)\n@@ -157,11 +157,11 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"\ncur = self.get_cursor_for_list_results()\nif enum_vid_prop and prop_value:\n- query = ('SELECT TvShowID FROM VideoLibTvShows'\n+ query = ('SELECT TvShowID FROM video_lib_tvshows'\n'WHERE ' + enum_vid_prop.value + ' = ?')\ncur = self._execute_query(query, (str(prop_value),), cur)\nelse:\n- query = 'SELECT TvShowID FROM VideoLibTvShows'\n+ query = 'SELECT TvShowID FROM video_lib_tvshows'\ncur = self._execute_query(query, cursor=cur)\nreturn self.return_rows_as_list(cur)\n@@ -170,7 +170,7 @@ def get_shareddb_class(force_sqlite=False):\ndef get_movies_id_list(self):\n\"\"\"Get all the ids of movies contained in the library\"\"\"\ncur = self.get_cursor_for_list_results()\n- query = 'SELECT MovieID FROM VideoLibMovies'\n+ query = 'SELECT MovieID FROM video_lib_movies'\ncur = self._execute_query(query, cursor=cur)\nreturn self.return_rows_as_list(cur)\n@@ -178,7 +178,7 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_sqlite.handle_connection\ndef movie_id_exists(self, movieid):\n\"\"\"Return True if a movie id exists\"\"\"\n- query = 'SELECT EXISTS(SELECT 1 FROM VideoLibMovies WHERE MovieID = ?)'\n+ query = 'SELECT EXISTS(SELECT 1 FROM video_lib_movies WHERE MovieID = ?)'\ncur = self._execute_query(query, (movieid,))\nreturn bool(cur.fetchone()[0])\n@@ -186,7 +186,7 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_sqlite.handle_connection\ndef tvshow_id_exists(self, tvshowid):\n\"\"\"Return True if a tvshow id exists\"\"\"\n- query = 'SELECT EXISTS(SELECT 1 FROM VideoLibTvShows WHERE TvShowID = ?)'\n+ query = 'SELECT EXISTS(SELECT 1 FROM video_lib_tvshows WHERE TvShowID = ?)'\ncur = self._execute_query(query, (tvshowid,))\nreturn bool(cur.fetchone()[0])\n@@ -196,10 +196,10 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Return True if a tvshow season id exists\"\"\"\nquery =\\\n('SELECT EXISTS('\n- 'SELECT 1 FROM VideoLibSeasons '\n- 'INNER JOIN VideoLibTvShows '\n- 'ON VideoLibSeasons.TvShowID = VideoLibTvShows.TvShowID '\n- 'WHERE VideoLibTvShows.TvShowID = ? AND VideoLibSeasons.SeasonID = ?)')\n+ 'SELECT 1 FROM video_lib_seasons '\n+ 'INNER JOIN video_lib_tvshows '\n+ 'ON video_lib_seasons.TvShowID = video_lib_tvshows.TvShowID '\n+ 'WHERE video_lib_tvshows.TvShowID = ? AND video_lib_seasons.SeasonID = ?)')\ncur = self._execute_query(query, (tvshowid, seasonid))\nreturn bool(cur.fetchone()[0])\n@@ -209,14 +209,14 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Return True if a tvshow episode id exists\"\"\"\nquery =\\\n('SELECT EXISTS('\n- 'SELECT 1 FROM VideoLibEpisodes '\n- 'INNER JOIN VideoLibSeasons '\n- 'ON VideoLibEpisodes.SeasonID = VideoLibSeasons.SeasonID '\n- 'INNER JOIN VideoLibTvShows '\n- 'ON VideoLibSeasons.TvShowID = VideoLibTvShows.TvShowID '\n- 'WHERE VideoLibTvShows.TvShowID = ? AND '\n- 'VideoLibSeasons.SeasonID = ? AND '\n- 'VideoLibEpisodes.EpisodeID = ?)')\n+ 'SELECT 1 FROM video_lib_episodes '\n+ 'INNER JOIN video_lib_seasons '\n+ 'ON video_lib_episodes.SeasonID = video_lib_seasons.SeasonID '\n+ 'INNER JOIN video_lib_tvshows '\n+ 'ON video_lib_seasons.TvShowID = video_lib_tvshows.TvShowID '\n+ 'WHERE video_lib_tvshows.TvShowID = ? AND '\n+ 'video_lib_seasons.SeasonID = ? AND '\n+ 'video_lib_episodes.EpisodeID = ?)')\ncur = self._execute_query(query, (tvshowid, seasonid, episodeid))\nreturn bool(cur.fetchone()[0])\n@@ -226,16 +226,16 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Update or insert a movie\"\"\"\n# Update or insert approach, if there is no updated row then insert new one\nif self.is_mysql_database:\n- query = db_utils.mysql_insert_or_update('VideoLibMovies', ['MovieID'],\n+ query = db_utils.mysql_insert_or_update('video_lib_movies', ['MovieID'],\n['FilePath', 'NfoExport'])\nself._execute_non_query(query, (movieid, file_path, str(nfo_export)), multi=True)\nelse:\n- update_query = ('UPDATE VideoLibMovies SET FilePath = ?, NfoExport = ? '\n+ update_query = ('UPDATE video_lib_movies SET FilePath = ?, NfoExport = ? '\n'WHERE MovieID = ?')\ncur = self._execute_query(update_query, (file_path, str(nfo_export), movieid))\nif cur.rowcount == 0:\n- insert_query =\\\n- 'INSERT INTO VideoLibMovies (MovieID, FilePath, NfoExport) VALUES (?, ?, ?)'\n+ insert_query = ('INSERT INTO video_lib_movies (MovieID, FilePath, NfoExport) '\n+ 'VALUES (?, ?, ?)')\nself._execute_non_query(insert_query, (movieid, file_path, str(nfo_export)))\n@db_base_mysql.handle_connection\n@@ -244,18 +244,18 @@ def get_shareddb_class(force_sqlite=False):\n\"\"\"Update or insert a tvshow\"\"\"\n# Update or insert approach, if there is no updated row then insert new one\nif self.is_mysql_database:\n- query = db_utils.mysql_insert_or_update('videolibtvshows', ['TvShowID'],\n+ query = db_utils.mysql_insert_or_update('video_lib_tvshows', ['TvShowID'],\n['ExcludeUpdate', 'NfoExport'])\nself._execute_non_query(query, (tvshowid, str(exclude_update), str(nfo_export)),\nmulti=True)\nelse:\n- update_query = ('UPDATE VideoLibTvShows SET NfoExport = ?, ExcludeUpdate = ? '\n+ update_query = ('UPDATE video_lib_tvshows SET NfoExport = ?, ExcludeUpdate = ? '\n'WHERE TvShowID = ?')\ncur = self._execute_query(update_query, (str(nfo_export),\nstr(exclude_update), tvshowid))\nif cur.rowcount == 0:\ninsert_query = \\\n- ('INSERT INTO VideoLibTvShows (TvShowID, NfoExport, ExcludeUpdate) '\n+ ('INSERT INTO video_lib_tvshows (TvShowID, NfoExport, ExcludeUpdate) '\n'VALUES (?, ?, ?)')\nself._execute_non_query(insert_query, (tvshowid,\nstr(nfo_export),\n@@ -266,7 +266,7 @@ def get_shareddb_class(force_sqlite=False):\ndef insert_season(self, tvshowid, seasonid):\n\"\"\"Insert a season if not exists\"\"\"\nif not self.season_id_exists(tvshowid, seasonid):\n- insert_query = ('INSERT INTO VideoLibSeasons (TvShowID, SeasonID) '\n+ insert_query = ('INSERT INTO video_lib_seasons (TvShowID, SeasonID) '\n'VALUES (?, ?)')\nself._execute_non_query(insert_query, (tvshowid, seasonid))\n@@ -275,7 +275,7 @@ def get_shareddb_class(force_sqlite=False):\ndef insert_episode(self, tvshowid, seasonid, episodeid, file_path):\n\"\"\"Insert a episode if not exists\"\"\"\nif not self.episode_id_exists(tvshowid, seasonid, episodeid):\n- insert_query = ('INSERT INTO VideoLibEpisodes (SeasonID, EpisodeID, FilePath) '\n+ insert_query = ('INSERT INTO video_lib_episodes (SeasonID, EpisodeID, FilePath) '\n'VALUES (?, ?, ?)')\nself._execute_non_query(insert_query, (seasonid, episodeid, file_path))\n@@ -283,24 +283,24 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_sqlite.handle_connection\ndef delete_movie(self, movieid):\n\"\"\"Delete a movie from database\"\"\"\n- query = 'DELETE FROM VideoLibMovies WHERE MovieID = ?'\n+ query = 'DELETE FROM video_lib_movies WHERE MovieID = ?'\nself._execute_query(query, (movieid,))\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef delete_tvshow(self, tvshowid):\n\"\"\"Delete a tvshow from database\"\"\"\n- query = 'DELETE FROM VideoLibTvShows WHERE TvShowID = ?'\n+ query = 'DELETE FROM video_lib_tvshows WHERE TvShowID = ?'\nself._execute_query(query, (tvshowid,))\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef delete_season(self, tvshowid, seasonid):\n\"\"\"Delete a season from database\"\"\"\n- query = 'DELETE FROM VideoLibSeasons WHERE TvShowID = ? AND SeasonID = ?'\n+ query = 'DELETE FROM video_lib_seasons WHERE TvShowID = ? AND SeasonID = ?'\nself._execute_query(query, (tvshowid, seasonid))\n# if there are no other seasons, delete the tvshow\n- query = 'SELECT EXISTS(SELECT 1 FROM VideoLibSeasons WHERE TvShowID = ?)'\n+ query = 'SELECT EXISTS(SELECT 1 FROM video_lib_seasons WHERE TvShowID = ?)'\ncur = self._execute_query(query, (tvshowid,))\nif not bool(cur.fetchone()[0]):\nself.delete_tvshow(tvshowid)\n@@ -309,10 +309,10 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_sqlite.handle_connection\ndef delete_episode(self, tvshowid, seasonid, episodeid):\n\"\"\"Delete a episode from database\"\"\"\n- query = 'DELETE FROM VideoLibEpisodes WHERE SeasonID = ? AND EpisodeID = ?'\n+ query = 'DELETE FROM video_lib_episodes WHERE SeasonID = ? AND EpisodeID = ?'\nself._execute_query(query, (seasonid, episodeid))\n# if there are no other episodes, delete the season\n- query = 'SELECT EXISTS(SELECT 1 FROM VideoLibEpisodes WHERE SeasonID = ?)'\n+ query = 'SELECT EXISTS(SELECT 1 FROM video_lib_episodes WHERE SeasonID = ?)'\ncur = self._execute_query(query, (seasonid,))\nif not bool(cur.fetchone()[0]):\nself.delete_season(tvshowid, seasonid)\n@@ -328,7 +328,7 @@ def get_shareddb_class(force_sqlite=False):\n:param data_type: OPTIONAL Used to set data type conversion only when default_value is None\n:return: the property value\n\"\"\"\n- query = 'SELECT ' + enum_vid_prop.value + ' FROM VideoLibTvShows WHERE TvShowID = ?'\n+ query = 'SELECT ' + enum_vid_prop.value + ' FROM video_lib_tvshows WHERE TvShowID = ?'\ncur = self._execute_query(query, (tvshowid,))\nresult = cur.fetchone()\nif default_value is not None:\n@@ -341,7 +341,7 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef set_tvshow_property(self, tvshowid, enum_vid_prop, value):\n- update_query = ('UPDATE VideoLibTvShows '\n+ update_query = ('UPDATE video_lib_tvshows '\n'SET ' + enum_vid_prop.value + ' = ? WHERE TvShowID = ?')\nvalue = common.convert_to_string(value)\ncur = self._execute_query(update_query, (value, tvshowid))\n@@ -350,7 +350,7 @@ def get_shareddb_class(force_sqlite=False):\n@db_base_sqlite.handle_connection\ndef get_stream_continuity(self, profile_guid, videoid, default_value=None, data_type=None):\n\"\"\"Get stream continuity value of a given id stored to current profile\"\"\"\n- query = 'SELECT Value FROM StreamContinuity WHERE ProfileGuid = ? AND VideoID = ?'\n+ query = 'SELECT Value FROM stream_continuity WHERE ProfileGuid = ? AND VideoID = ?'\ncur = self._execute_query(query, (profile_guid, videoid))\nresult = cur.fetchone()\nif default_value is not None:\n@@ -368,19 +368,19 @@ def get_shareddb_class(force_sqlite=False):\nvalue = common.convert_to_string(value)\ndate_last_modified = common.convert_to_string(datetime.now())\nif self.is_mysql_database:\n- query = db_utils.mysql_insert_or_update('StreamContinuity',\n+ query = db_utils.mysql_insert_or_update('stream_continuity',\n['ProfileGuid', 'VideoID'],\n['Value', 'DateLastModified'])\nself._execute_non_query(query, (profile_guid, videoid, value, date_last_modified),\nmulti=True)\nelse:\n- update_query = ('UPDATE StreamContinuity '\n+ update_query = ('UPDATE stream_continuity '\n'SET Value = ?, DateLastModified = ? '\n'WHERE ProfileGuid = ? AND VideoID = ?')\ncur = self._execute_query(update_query, (value, date_last_modified,\nprofile_guid, videoid))\nif cur.rowcount == 0:\n- insert_query = ('INSERT INTO StreamContinuity '\n+ insert_query = ('INSERT INTO stream_continuity '\n'(ProfileGuid, VideoID, Value, DateLastModified) '\n'VALUES (?, ?, ?, ?)')\nself._execute_non_query(insert_query, (profile_guid, videoid,\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "@@ -14,11 +14,11 @@ LOCAL_DB_FILENAME = 'nf_local.sqlite3'\nSHARED_DB_FILENAME = 'nf_shared.sqlite3'\n# Table mapping: ( Table name, [ columns ] )\n-TABLE_APP_CONF = ('AppConfig', ['Name', 'Value'])\n-TABLE_SESSION = ('Session', ['Name', 'Value'])\n-TABLE_MENU_DATA = ('MenuData', ['ContextId', 'Value'])\n-TABLE_SETTINGS_MONITOR = ('SettingsMonitor', ['Name', 'Value'])\n-TABLE_SHARED_APP_CONF = ('SharedAppConfig', ['Name', 'Value'])\n+TABLE_APP_CONF = ('app_config', ['Name', 'Value'])\n+TABLE_SESSION = ('session', ['Name', 'Value'])\n+TABLE_MENU_DATA = ('menu_data', ['ContextId', 'Value'])\n+TABLE_SETTINGS_MONITOR = ('settings_monitor', ['Name', 'Value'])\n+TABLE_SHARED_APP_CONF = ('shared_app_config', ['Name', 'Value'])\n# Enum mapping the video library columns of the tables\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Renamed table names to make them compatible to different MySQL MariaDB and MySQL server have different requirements
106,046
17.08.2019 14:40:43
-7,200
47b4f0773d1ca11581c79c0317f715414f573a80
Implemented create MySQL database
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_base_mysql.py", "new_path": "resources/lib/database/db_base_mysql.py", "diff": "@@ -9,6 +9,7 @@ import mysql.connector\nimport resources.lib.common as common\nimport resources.lib.database.db_base as db_base\nimport resources.lib.database.db_utils as db_utils\n+import resources.lib.database.db_create_mysql as db_create_mysql\nfrom resources.lib.database.db_exceptions import (MySQLConnectionError, MySQLError)\nfrom resources.lib.globals import g\n@@ -68,12 +69,14 @@ class MySQLDatabase(db_base.BaseDatabase):\n.format(db_info))\nexcept mysql.connector.Error as e:\nif e.errno == 1049 and not self.is_connection_test:\n- # Database does not exist\n- # TODO: create a new one\n- if self.conn and self.conn.is_connected():\n- self.conn.close()\n+ # Database does not exist, create a new one\n+ try:\n+ db_create_mysql.create_database(self.config.copy())\nself._initialize_connection()\nreturn\n+ except mysql.connector.Error as e:\n+ common.error(\"MySql error {}:\".format(e))\n+ raise MySQLConnectionError\ncommon.error(\"MySql error {}:\".format(e))\nraise MySQLConnectionError\nfinally:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_base_sqlite.py", "new_path": "resources/lib/database/db_base_sqlite.py", "diff": "@@ -8,7 +8,7 @@ from functools import wraps\nimport resources.lib.common as common\nimport resources.lib.database.db_base as db_base\n-import resources.lib.database.db_create as db_create\n+import resources.lib.database.db_create_sqlite as db_create_sqlite\nimport resources.lib.database.db_utils as db_utils\nfrom resources.lib.database.db_exceptions import (SQLiteConnectionError, SQLiteError)\n@@ -62,7 +62,7 @@ class SQLiteDatabase(db_base.BaseDatabase):\n# TODO: Temporary when stabilized it will be possible to implement the db code creation\n# If database file do not exist copy a new one\ndb_filename = os.path.basename(self.db_file_path)\n- db_create.check_database_file(db_filename)\n+ db_create_sqlite.check_database_file(db_filename)\ntry:\ncommon.debug('Trying connection to the database {}'.format(db_filename))\nself.conn = sql.connect(self.db_file_path)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/database/db_create_mysql.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Functions to create new databases\"\"\"\n+from __future__ import unicode_literals\n+\n+import mysql.connector\n+\n+import resources.lib.common as common\n+\n+\n+def create_database(config):\n+ \"\"\"Create a new database\"\"\"\n+ db_name = config.pop('database', None)\n+ common.debug('The MySQL database {} does not exist, creating a new one'.format(db_name))\n+ conn = mysql.connector.connect(**config)\n+ cur = conn.cursor()\n+\n+ schema = ('CREATE DATABASE netflix_addon '\n+ 'CHARACTER SET utf8mb4 '\n+ 'COLLATE utf8mb4_unicode_ci;')\n+ cur.execute(schema)\n+\n+ table = ('CREATE TABLE netflix_addon.profiles ('\n+ 'ID INT(11) NOT NULL AUTO_INCREMENT,'\n+ 'Guid VARCHAR(50) NOT NULL,'\n+ 'SortOrder INT(11) NOT NULL,'\n+ 'PRIMARY KEY (ID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.profiles '\n+ 'ADD UNIQUE INDEX Guid(Guid);')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+\n+ table = ('CREATE TABLE netflix_addon.shared_app_config ('\n+ 'ID INT(11) NOT NULL AUTO_INCREMENT,'\n+ 'Name VARCHAR(100) NOT NULL,'\n+ 'Value TEXT DEFAULT NULL,'\n+ 'PRIMARY KEY (ID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.shared_app_config '\n+ 'ADD UNIQUE INDEX Name_UNIQUE(Name);')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+\n+ table = ('CREATE TABLE netflix_addon.stream_continuity ('\n+ 'ProfileGuid VARCHAR(50) NOT NULL,'\n+ 'VideoID INT(11) NOT NULL,'\n+ 'Value TEXT DEFAULT NULL,'\n+ 'DateLastModified VARCHAR(50) NOT NULL,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.stream_continuity '\n+ 'ADD CONSTRAINT FK_streamcontinuity_ProfileGuid FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES netflix_addon.profiles(Guid) ON DELETE CASCADE ON UPDATE CASCADE;')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+\n+ table = ('CREATE TABLE netflix_addon.video_lib_episodes ('\n+ 'EpisodeID INT(11) NOT NULL,'\n+ 'SeasonID INT(11) NOT NULL,'\n+ 'FilePath TEXT DEFAULT NULL,'\n+ 'PRIMARY KEY (EpisodeID, SeasonID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ cur.execute(table)\n+\n+ table = ('CREATE TABLE netflix_addon.video_lib_movies ('\n+ 'MovieID INT(11) NOT NULL,'\n+ 'FilePath TEXT DEFAULT NULL,'\n+ 'NfoExport VARCHAR(5) NOT NULL DEFAULT \\'False\\','\n+ 'PRIMARY KEY (MovieID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ cur.execute(table)\n+\n+ table = ('CREATE TABLE netflix_addon.video_lib_seasons ('\n+ 'TvShowID INT(11) NOT NULL,'\n+ 'SeasonID INT(11) NOT NULL,'\n+ 'PRIMARY KEY (TvShowID, SeasonID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ cur.execute(table)\n+\n+ table = ('CREATE TABLE netflix_addon.video_lib_tvshows ('\n+ 'TvShowID INT(11) NOT NULL,'\n+ 'ExcludeUpdate VARCHAR(5) NOT NULL DEFAULT \\'False\\','\n+ 'NfoExport VARCHAR(5) NOT NULL DEFAULT \\'False\\','\n+ 'PRIMARY KEY (TvShowID))'\n+ 'ENGINE = INNODB, CHARACTER SET utf8mb4, COLLATE utf8mb4_unicode_ci;')\n+ alter_tbl = ('ALTER TABLE netflix_addon.video_lib_tvshows '\n+ 'ADD UNIQUE INDEX UK_videolibtvshows_TvShowID(TvShowID);')\n+ cur.execute(table)\n+ cur.execute(alter_tbl)\n+\n+ if conn and conn.is_connected():\n+ conn.close()\n" }, { "change_type": "RENAME", "old_path": "resources/lib/database/db_create.py", "new_path": "resources/lib/database/db_create_sqlite.py", "diff": "" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented create MySQL database
106,046
17.08.2019 14:42:05
-7,200
dcf82ccf570ea7a48fcd1ee1711d4f9071210fee
Fixed datetime in auto update library
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -511,13 +511,11 @@ def _remove_videoid_from_db(videoid):\ng.SHARED_DB.delete_episode(videoid.tvshowid, videoid.seasonid, videoid.episodeid)\n-\ndef _export_all_new_episodes_running():\nupdate = g.SHARED_DB.get_value('library_export_new_episodes_running', False)\nif update:\nstart_time = g.SHARED_DB.get_value('library_export_new_episode_start_time',\n- data_type=datetime)\n- start_time = common.strp(start_time, '%Y-%m-%d %H:%M')\n+ datetime.utcfromtimestamp(0))\nif datetime.now() >= start_time + timedelta(hours=6):\ng.SHARED_DB.set_value('library_export_new_episodes_running', False)\ncommon.warn('Canceling previous library update: duration >6 hours')\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -104,9 +104,8 @@ def _compute_next_schedule():\ntime = g.ADDON.getSetting('update_time') or '00:00'\nlast_run = g.SHARED_DB.get_value('library_auto_update_last_start',\n- datetime.now() - timedelta(days=(50*365)))\n- last_run = common.strp('{} {}'.format(last_run, time[0:5]),\n- '%Y-%m-%d %H:%M')\n+ datetime.utcfromtimestamp(0))\n+ last_run = last_run.replace(hour=int(time[0:2]), minute=int(time[3:5]))\nnext_run = last_run + timedelta(days=[0, 1, 2, 5, 7][update_frequency])\ncommon.debug('Next library auto update is scheduled for {}'.format(next_run))\nreturn next_run\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed datetime in auto update library
106,046
16.08.2019 10:14:22
-7,200
43b0b54e1a73fcff252fc1a98d5c3dd3c2e83b42
Device selection for library auto-updates prevents possible concurrency if updates to the library are active on multiple devices
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -843,3 +843,27 @@ msgstr \"\"\nmsgctxt \"#30206\"\nmsgid \"ERROR: The MySQL database is not reachable - check the connection - fallback to local database\"\nmsgstr \"\"\n+\n+msgctxt \"#30207\"\n+msgid \"Set this device as main auto-updates manager\"\n+msgstr \"\"\n+\n+msgctxt \"#30208\"\n+msgid \"Check if this device is the main auto-update manager\"\n+msgstr \"\"\n+\n+msgctxt \"#30209\"\n+msgid \"This device now handle the auto-updates of shared-library\"\n+msgstr \"\"\n+\n+msgctxt \"#30210\"\n+msgid \"This device handle the auto-updates of shared-library\"\n+msgstr \"\"\n+\n+msgctxt \"#30211\"\n+msgid \"Another device handle the auto-updates of shared-library\"\n+msgstr \"\"\n+\n+msgctxt \"#30212\"\n+msgid \"There is no device that handle the auto-updates of shared-library\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -21,6 +21,16 @@ from .logging import debug, info, error\nfrom .kodiops import get_local_string\n+def get_device_uuid():\n+ \"\"\"Generate an uuid for the current device based on the device MAC address\"\"\"\n+ import uuid\n+ mac = uuid.getnode()\n+ if (mac >> 40) % 2:\n+ from platform import node\n+ mac = node()\n+ return str(uuid.uuid5(uuid.NAMESPACE_DNS, str(mac)))\n+\n+\ndef find(value_to_find, attribute, search_space):\n\"\"\"Find a video with matching id in a dict or list\"\"\"\nfor video in search_space:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -137,3 +137,19 @@ class LibraryActionExecutor(object):\n# in addition, you must also wait for the timeout to obtain any connection error\n# Perhaps creating a particular modal dialog with connection parameters can help\npass\n+\n+ def set_autoupdate_device(self, pathitems):\n+ \"\"\"Set the current device to manage auto-update of the shared-library (MySQL)\"\"\"\n+ g.SHARED_DB.set_value('auto_update_device_uuid', common.get_device_uuid())\n+ ui.show_notification(common.get_local_string(30209), time=8000)\n+\n+ def check_autoupdate_device(self, pathitems):\n+ \"\"\"Check if the current device manage the auto-updates of the shared-library (MySQL)\"\"\"\n+ uuid = g.SHARED_DB.get_value('auto_update_device_uuid')\n+ if uuid is None:\n+ msg = common.get_local_string(30212)\n+ else:\n+ current_device_uuid = common.get_device_uuid()\n+ msg = common.get_local_string(30210) \\\n+ if current_device_uuid == uuid else common.get_local_string(30211)\n+ ui.show_notification(msg, time=8000)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -101,6 +101,13 @@ def _compute_next_schedule():\nif not update_frequency:\ncommon.debug('Library auto update scheduled is disabled')\nreturn None\n+ if g.ADDON.getSettingBool('use_mysql'):\n+ current_device_uuid = common.get_device_uuid()\n+ uuid = g.SHARED_DB.get_value('auto_update_device_uuid')\n+ if current_device_uuid != uuid:\n+ common.debug('The auto update has been disabled because another device '\n+ 'has been set as the main update manager')\n+ return None\ntime = g.ADDON.getSetting('update_time') or '00:00'\nlast_run = g.SHARED_DB.get_value('library_auto_update_last_start',\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"mysql_host\" type=\"ipaddress\" label=\"30203\" default=\"127.0.0.1\" visible=\"eq(-3,true)\" subsetting=\"true\"/>\n<setting id=\"mysql_port\" type=\"number\" label=\"30204\" default=\"3306\" visible=\"eq(-4,true)\" subsetting=\"true\"/>\n<setting id=\"mysql_test\" type=\"action\" label=\"30205\" action=\"RunPlugin(plugin://plugin.video.netflix/library/mysql_test/)\" visible=\"false\" subsetting=\"true\" option=\"close\"/>\n+ <setting id=\"mysql_device_auto_update\" type=\"action\" label=\"30207\" action=\"RunPlugin(plugin://plugin.video.netflix/library/set_autoupdate_device/)\" visible=\"eq(-6,true)\" subsetting=\"true\"/>\n+ <setting id=\"mysql_check_auto_update_device\" type=\"action\" label=\"30208\" action=\"RunPlugin(plugin://plugin.video.netflix/library/check_autoupdate_device/)\" visible=\"eq(-7,true)\" subsetting=\"true\"/>\n</category>\n<category label=\"30166\"><!--Main menu items-->\n<setting id=\"show_menu_mylist\" type=\"bool\" label=\"30167\" default=\"true\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Device selection for library auto-updates prevents possible concurrency if updates to the library are active on multiple devices
106,046
17.08.2019 12:05:15
-7,200
5a23c96dd8e43f663ac1793631667ed093b27f11
Fixed missing value converter in get/set profile config
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_local.py", "new_path": "resources/lib/database/db_local.py", "diff": "\"\"\"Local database access and functions\"\"\"\nfrom __future__ import unicode_literals\n+import resources.lib.common as common\nimport resources.lib.database.db_base_sqlite as db_sqlite\nimport resources.lib.database.db_utils as db_utils\nfrom resources.lib.database.db_exceptions import (ProfilesMissing)\n@@ -20,7 +21,7 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\nreturn result[0]\n@db_sqlite.handle_connection\n- def get_profile_config(self, key, default_value=None, guid=None):\n+ def get_profile_config(self, key, default_value=None, guid=None, data_type=None):\n\"\"\"Get a value from a profile, if guid is not specified, is obtained from active profile\"\"\"\nif guid is None:\nquery = ('SELECT Value FROM profiles_config '\n@@ -36,7 +37,12 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\n'profiles_config.Name = ?')\ncur = self._execute_query(query, (guid, key))\nresult = cur.fetchone()\n- return result[0] if result else default_value\n+ if default_value is not None:\n+ data_type = type(default_value)\n+ elif data_type is None:\n+ data_type = str\n+ return common.convert_from_string(result[0], data_type) \\\n+ if result is not None else default_value\n@db_sqlite.handle_connection\ndef set_profile_config(self, key, value, guid=None):\n@@ -45,6 +51,7 @@ class NFLocalDatabase(db_sqlite.SQLiteDatabase):\nif not guid:\nguid = self._get_active_guid_profile()\nupdate_query = 'UPDATE profiles_config SET Value = ? WHERE Guid = ? AND Name = ?'\n+ value = common.convert_to_string(value)\ncur = self._execute_query(update_query, (value, guid, key))\nif cur.rowcount == 0:\ninsert_query = 'INSERT INTO profiles_config (Guid, Name, Value) VALUES (?, ?, ?)'\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed missing value converter in get/set profile config
105,991
17.08.2019 01:28:09
-7,200
0d97629090c3547627e065045cb66f4e054098cc
Fix stream_continuity for tvshows Saved VideoId was the episodeid instead of the showid
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/stream_continuity.py", "new_path": "resources/lib/services/playback/stream_continuity.py", "diff": "@@ -57,7 +57,9 @@ class StreamContinuityManager(PlaybackActionManager):\nvideoid = common.VideoId.from_dict(data['videoid'])\nif videoid.mediatype in [common.VideoId.MOVIE, common.VideoId.EPISODE]:\nself.did_restore = False\n- self.current_videoid = videoid\n+ self.current_videoid = videoid \\\n+ if videoid.mediatype == common.VideoId.MOVIE \\\n+ else videoid.derive_parent(0)\nelse:\nself.enabled = False\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix stream_continuity for tvshows Saved VideoId was the episodeid instead of the showid
106,046
18.08.2019 11:05:20
-7,200
b98cba577676a060460acdaf1eed1e76553d26f5
Added possibility to convert an old videoid class instance
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/videoid.py", "new_path": "resources/lib/common/videoid.py", "diff": "@@ -144,6 +144,24 @@ class VideoId(object):\nEither movie, show, season, episode, supplemental or unspecified\"\"\"\nreturn self._mediatype\n+ def convert_old_videoid_type(self):\n+ \"\"\"\n+ If the data contained in to videoid comes from the previous version\n+ of the videoid class (without supplementalid), then convert the class object\n+ to the new type of class or else return same class\n+ \"\"\"\n+ if len(self._id_values) == 5:\n+ videoid_dict = {\n+ 'mediatype': self._mediatype,\n+ 'movieid': self._id_values[1],\n+ 'episodeid': self._id_values[2],\n+ 'seasonid': self._id_values[3],\n+ 'tvshowid': self._id_values[4]\n+ }\n+ return VideoId.from_dict(videoid_dict)\n+ else:\n+ return self\n+\ndef to_path(self):\n\"\"\"Generate a valid pathitems list (['show', tvshowid, ...]) from\nthis instance\"\"\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added possibility to convert an old videoid class instance Co-authored-by: Smeulf <[email protected]>
106,046
18.08.2019 11:11:50
-7,200
69bf70ca4da47a1fa16ac41c082e78f0410850ae
Fixed migrate library error on old videoid class instance
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_actions.py", "new_path": "resources/lib/upgrade_actions.py", "diff": "@@ -27,7 +27,7 @@ def migrate_library_to_db():\nlib = pickle.loads(handle.read())\nhandle.close()\nfor item in lib['content'].values():\n- videoid = item['videoid']\n+ videoid = item['videoid'].convert_old_videoid_type()\nif videoid.mediatype == common.VideoId.MOVIE:\nlibrary.add_to_library(videoid, item['file'], False, False)\nelif videoid.mediatype == common.VideoId.SHOW:\n@@ -35,7 +35,8 @@ def migrate_library_to_db():\nif season_key not in ['videoid', 'nfo_export', 'exclude_from_update']:\nfor episode_key in item[season_key].keys():\nif episode_key not in ['videoid', 'nfo_export']:\n- library.add_to_library(item[season_key][episode_key]['videoid'],\n+ library.add_to_library(\n+ item[season_key][episode_key]['videoid'].convert_old_videoid_type(),\nitem[season_key][episode_key]['file'],\nitem.get('nfo_export', False),\nitem.get('exclude_from_update', False))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed migrate library error on old videoid class instance Co-authored-by: Smeulf <[email protected]>
105,991
17.08.2019 22:39:20
-7,200
c754ccc6a074b8541756861035d09f829d7007bf
Fix library encoding issues
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -414,16 +414,16 @@ def 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\ndestination_folder = xbmc.makeLegalFilename('/'.join(\n- [library_home, item_task['section'], item_task['destination']]))\n+ [library_home, item_task['section'], item_task['destination']])).decode('utf-8')\n_create_destination_folder(destination_folder)\nif item_task['is_strm']:\nexport_filename = xbmc.makeLegalFilename('/'.join(\n- [destination_folder.decode('utf-8'), item_task['filename'] + '.strm']))\n+ [destination_folder, item_task['filename'] + '.strm'])).decode('utf-8')\nadd_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:\nnfo_filename = xbmc.makeLegalFilename('/'.join(\n- [destination_folder.decode('utf-8'), item_task['filename'] + '.nfo']))\n+ [destination_folder, item_task['filename'] + '.nfo'])).decode('utf-8')\n_write_nfo_file(item_task['nfo_data'], nfo_filename)\ncommon.debug('Exported {}'.format(item_task['title']))\n@@ -460,10 +460,9 @@ def add_to_library(videoid, export_filename, nfo_export, exclude_update=False):\nif videoid.mediatype == common.VideoId.EPISODE:\ng.SHARED_DB.set_tvshow(videoid.tvshowid, nfo_export, exclude_update)\ng.SHARED_DB.insert_season(videoid.tvshowid, videoid.seasonid)\n- g.SHARED_DB.insert_episode(videoid.tvshowid, videoid.seasonid, videoid.value,\n- export_filename.decode(\"utf-8\"))\n+ g.SHARED_DB.insert_episode(videoid.tvshowid, videoid.seasonid, videoid.value, export_filename)\nelif videoid.mediatype == common.VideoId.MOVIE:\n- g.SHARED_DB.set_movie(videoid.value, export_filename.decode(\"utf-8\"), nfo_export)\n+ g.SHARED_DB.set_movie(videoid.value, export_filename, nfo_export)\[email protected]_execution(immediate=False)\n@@ -485,7 +484,7 @@ def remove_item(item_task, library_home=None):\nxbmcvfs.delete(nfo_file)\ndirs, files = xbmcvfs.listdir(parent_folder.decode(\"utf-8\"))\ntvshow_nfo_file = xbmc.makeLegalFilename(\n- '/'.join([parent_folder.decode(\"utf-8\"), 'tvshow.nfo']))\n+ '/'.join([parent_folder.decode(\"utf-8\"), 'tvshow.nfo'])).decode(\"utf-8\")\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@@ -615,7 +614,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 file in xbmcvfs.listdir(folder)[1]:\n- filepath = xbmc.makeLegalFilename('/'.join([folder, file.decode('utf-8')]))\n+ filepath = xbmc.makeLegalFilename('/'.join([folder, file])).decode('utf-8')\nif filepath.endswith('.strm'):\ncommon.debug('Trying to migrate {}'.format(filepath))\ntry:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix library encoding issues
106,046
18.08.2019 10:59:33
-7,200
f5d27290128299854b27a4e88e661358f6a13db1
Improved checks for MySQL connection
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -813,7 +813,7 @@ msgid \"Exporting new episodes\"\nmsgstr \"\"\nmsgctxt \"#30199\"\n-msgid \"Shared library (Need Kodi MySql server database)\"\n+msgid \"Shared library (Kodi MySQL server is required)\"\nmsgstr \"\"\nmsgctxt \"#30200\"\n@@ -825,7 +825,7 @@ msgid \"Username\"\nmsgstr \"\"\nmsgctxt \"#30202\"\n-msgid \"Password\"\n+msgid \"Connection to the MySQL database was successful\"\nmsgstr \"\"\nmsgctxt \"#30203\"\n@@ -841,7 +841,7 @@ msgid \"Test database connection\"\nmsgstr \"\"\nmsgctxt \"#30206\"\n-msgid \"ERROR: The MySQL database is not reachable - check the connection - fallback to local database\"\n+msgid \"ERROR: The MySQL database is not reachable - the local database will be used\"\nmsgstr \"\"\nmsgctxt \"#30207\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/globals.py", "new_path": "resources/lib/globals.py", "diff": "@@ -236,7 +236,10 @@ class GlobalVariables(object):\nself.SHARED_DB = shared_db_class()\nexcept MySQLConnectionError:\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\nimport resources.lib.kodi.ui as ui\n+ self.ADDON.setSettingBool('use_mysql', False)\nui.show_notification(self.ADDON.getLocalizedString(30206), time=10000)\nshared_db_class = db_shared.get_shareddb_class(force_sqlite=True)\nself.SHARED_DB = shared_db_class()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -26,9 +26,21 @@ class SettingsMonitor(xbmc.Monitor):\ncommon.debug('SettingsMonitor: settings have been changed, started checks')\nreboot_addon = False\n+ use_mysql = g.ADDON.getSettingBool('use_mysql')\n+ use_mysql_old = g.LOCAL_DB.get_value('use_mysql', False, TABLE_SETTINGS_MONITOR)\n+ use_mysql_turned_on = use_mysql and not use_mysql_old\n+\ncommon.debug('SettingsMonitor: Reinitialization of global settings')\ng.init_globals(sys.argv, reboot_addon)\n+ # Check the MySQL connection status after reinitialization of global settings\n+ use_mysql_after = g.ADDON.getSettingBool('use_mysql')\n+ if use_mysql_turned_on and use_mysql_after:\n+ g.LOCAL_DB.set_value('use_mysql', True, TABLE_SETTINGS_MONITOR)\n+ ui.show_notification(g.ADDON.getLocalizedString(30202))\n+ if not use_mysql_after and use_mysql_old:\n+ g.LOCAL_DB.set_value('use_mysql', False, TABLE_SETTINGS_MONITOR)\n+\n# Check if the custom esn is changed\ncustom_esn = g.ADDON.getSetting('esn')\ncustom_esn_old = g.LOCAL_DB.get_value('custom_esn', '', TABLE_SETTINGS_MONITOR)\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting label=\"30199\" type=\"lsep\"/><!--Shared library-->\n<setting id=\"use_mysql\" type=\"bool\" label=\"30200\" default=\"false\"/>\n<setting id=\"mysql_username\" type=\"text\" label=\"30201\" default=\"kodi\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n- <setting id=\"mysql_password\" type=\"text\" label=\"30202\" default=\"kodi\" option=\"hidden\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n+ <setting id=\"mysql_password\" type=\"text\" label=\"30004\" default=\"kodi\" option=\"hidden\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting id=\"mysql_host\" type=\"ipaddress\" label=\"30203\" default=\"127.0.0.1\" visible=\"eq(-3,true)\" subsetting=\"true\"/>\n<setting id=\"mysql_port\" type=\"number\" label=\"30204\" default=\"3306\" visible=\"eq(-4,true)\" subsetting=\"true\"/>\n<setting id=\"mysql_test\" type=\"action\" label=\"30205\" action=\"RunPlugin(plugin://plugin.video.netflix/library/mysql_test/)\" visible=\"false\" subsetting=\"true\" option=\"close\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Improved checks for MySQL connection
106,046
19.08.2019 21:07:40
-7,200
4dc745ebdabec2f6fda17e8a9dde69b3c5d133b9
Updated readme Update guide for MySQL, shared library and auto-update
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -111,6 +111,19 @@ Only add/remove to My List from within the addon keeps the Kodi library in sync.\n### My watched status is not being updated?!\nThe addon does not report watched status back to Netflix (yet). This is a top priority on our roadmap, but we haven't been able to figure this out just yet.\n+### Can i share the exported content in the library with multiple devices?\n+Yes it is possible share the same library with multiple devices that using netflix addon.\n+In order to work it is necessary use Kodi with a MySQL server.\n+You can follow the official Kodi MySQL setup instructions at [Kodi Wiki](https://kodi.wiki/view/MySQL).\n+When done, in each device that use this addon, open the addon settings and under Library page:\n+- Check \"Enable custom library folder\", and choose a shared \"Custom library path\". The path must be the exact same on all devices.\n+- Enable \"Use MySQL shared library database\", then set the same connection parameters used in Kodi MySQL setup.\n+\n+### Auto-update of exported content\n+WARNING: AN INTENSIVE USE of AUTO-UPDATE function due to many exported tv shows MAY CAUSE A TEMPORARY BAN of the ACCOUNT that varies starting from 24/48 hours. Use at your own risk.\n+If it happens often, there is the possibility to exclude the auto-updates from the tv shows, by open context menu on a tv show and selecting \"Exclude from auto update\".\n+- If you want to use the auto-update with a shared exported content (to multiple devices), you need to set up one of the devices as the main library update manager, by using the menu \"Set this device as main auto-updates manager\" from the chosen device under Library page.\n+\n## Something doesn't work\nIf something doesn't work for you, please:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated readme Update guide for MySQL, shared library and auto-update Co-authored-by: Smeulf <[email protected]>
106,046
20.08.2019 19:47:43
-7,200
c269d3f0a1113255d0f40b1addd85bb94fe2ec0f
Version bump (15.0)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.14.6\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.0\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.15.0 (2019-08-20)\n+-Implemented data management through database\n+-Implemented automatic export of new episodes\n+-Implemented a version upgrade system\n+-Implemented management of login errors\n+-Added a new context menu \"Export new episodes\" for a single tv show\n+-Added ability to exclude (and re-include) a tv show from library auto update\n+-Added possibility to share the same library with multiple devices (MySQL server is required)\n+-No more concurrency and data loss problems of previous \"persistent storage\"\n+-Fixed continuous \"new access\" email notification from netflix\n+-Fixed locale id error\n+-Fixed automatic library updates\n+-Fixed logout now the profiles are no longer accessible and you can enter your credentials\n+-Fixed exporting tvshow.nfo for a single episode\n+-Fixed UpNext watched status from Kodi library\n+-Fixed issue with library items that containing % in the path\n+-Other minor improvements and fixes\n+\nv0.14.6 (2019-06-29)\n-Improved Library Management that include:\n-Fixed TvShow not removed from library\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (15.0)
106,046
25.08.2019 10:37:13
-7,200
387ef268a2b03da867c47c72ac40482289452649
Cleanup custom_viewmode activate_view the implementation of the method to get the skin id was not well accepted and will not be implemented
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/listings.py", "new_path": "resources/lib/kodi/listings.py", "diff": "@@ -38,28 +38,11 @@ def _activate_view(partial_setting_id):\n\"\"\"Activate the given view if the plugin is run in the foreground\"\"\"\nif 'plugin://{}'.format(g.ADDON_ID) in xbmc.getInfoLabel('Container.FolderPath'):\nif g.ADDON.getSettingBool('customview'):\n- # Do not change the sequence of this keys, match the return value of the enum xml menu\n- list_views = collections.OrderedDict({\n- '''\n- With Kodi 19 should be implemented a method to get the id of the current skin,\n- so we can use this list only with the default skin,\n- the other skins partially implement the view types of the standard skin of kodi\n- causing also alterations in the translations of the view type names.\n- 'List': 50,\n- 'Poster': 51,\n- 'IconWall': 52,\n- 'Shift': 53,\n- 'InfoWall': 54,\n- 'WideList': 55,\n- 'Wall': 500,\n- 'Banner': 501,\n- 'FanArt': 502,'''\n- 'LastUsed': 0, # Leave the management to kodi\n- 'Custom': -1\n- })\n- # Force a custom view\n- view_id = list_views.values()[int(g.ADDON.getSettingInt('viewmode' + partial_setting_id))]\n- if view_id == -1:\n+ view_mode = int(g.ADDON.getSettingInt('viewmode' + partial_setting_id))\n+ if view_mode == 0:\n+ # Leave the management to kodi\n+ return\n+ # Force a custom view, get the id from settings\nview_id = int(g.ADDON.getSettingInt('viewmode' + partial_setting_id + 'id'))\nif view_id > 0:\nxbmc.executebuiltin('Container.SetViewMode({})'.format(view_id))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Cleanup custom_viewmode activate_view the implementation of the method to get the skin id was not well accepted and will not be implemented
106,046
25.08.2019 15:05:35
-7,200
d7cd28070baed3f98b0f22fc0ad1f6367765721d
Version bump (15.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=\"0.15.0\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.1\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.15.1 (2019-08-25)\n+-Fixed wrong path to linux systems\n+\nv0.15.0 (2019-08-20)\n-Implemented data management through database\n-Implemented automatic export of new episodes\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (15.1)
106,046
25.08.2019 16:54:02
-7,200
14c71edf01fa8952a3c7688f9635b0d4102a8d39
Added more debug profile info and hidden esn
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -17,12 +17,14 @@ from .exceptions import (InvalidProfilesError, InvalidAuthURLError, InvalidMembe\nPAGE_ITEMS_INFO = [\n'models/userInfo/data/name',\n- 'models/userInfo/data/guid',\n+ 'models/userInfo/data/guid', # Main profile guid\n+ 'models/userInfo/data/userGuid', # Current profile guid\n'models/userInfo/data/countryOfSignup',\n'models/userInfo/data/membershipStatus',\n'models/userInfo/data/isTestAccount',\n'models/userInfo/data/deviceTypeId',\n'models/userInfo/data/isAdultVerified',\n+ 'models/userInfo/data/isKids',\n'models/userInfo/data/pinEnabled',\n'models/serverDefs/data/BUILD_IDENTIFIER',\n'models/esnGeneratorModel/data/esn',\n@@ -79,6 +81,9 @@ def extract_profiles(falkor_cache):\ncommon.debug('Parsing profile {}'.format(guid))\navatar_url = _get_avatar(falkor_cache, profile)\nprofile = profile['summary']['value']\n+ debug_info = ['profileName', 'isAccountOwner', 'isActive', 'isKids', 'maturityLevel']\n+ for k_info in debug_info:\n+ common.debug('Profile info {}'.format({k_info: profile[k_info]}))\nis_active = profile.pop('isActive')\ng.LOCAL_DB.set_profile(guid, is_active, sort_order)\ng.SHARED_DB.set_profile(guid, sort_order)\n@@ -121,6 +126,7 @@ def extract_userdata(react_context):\ntry:\nextracted_value = {path[-1]: common.get_path(path, react_context)}\nuser_data.update(extracted_value)\n+ if 'esn' not in path:\ncommon.debug('Extracted {}'.format(extracted_value))\nexcept (AttributeError, KeyError):\ncommon.debug('Could not extract {}'.format(path))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added more debug profile info and hidden esn
106,046
29.08.2019 21:08:04
-7,200
4f840d3c741c76a39db6a47dff309701f7c2d812
Perform upgrade and configuration checks after login
[ { "change_type": "MODIFY", "old_path": "addon.py", "new_path": "addon.py", "diff": "@@ -103,9 +103,9 @@ if __name__ == '__main__':\nsuccess = False\ntry:\n+ if check_valid_credentials():\nupgrade_ctrl.check_addon_upgrade()\ng.initial_addon_configuration()\n- if check_valid_credentials():\nroute(filter(None, g.PATH.split('/')))\nsuccess = True\nexcept common.BackendNotReady:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Perform upgrade and configuration checks after login
106,046
29.08.2019 21:10:04
-7,200
2a3d24590d60a817e3918172eaa91721ca0f6ab6
Implemented create SQLite database
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_base_sqlite.py", "new_path": "resources/lib/database/db_base_sqlite.py", "diff": "@@ -52,24 +52,27 @@ def handle_connection(func):\nclass SQLiteDatabase(db_base.BaseDatabase):\ndef __init__(self, db_filename):\nself.is_mysql_database = False\n+ self.db_filename = db_filename\nself.db_file_path = db_utils.get_local_db_path(db_filename)\nsuper(SQLiteDatabase, self).__init__()\ndef _initialize_connection(self):\n- # If database file do not exist create a new one\n- # if not common.file_exists(db_filename, g.DATA_PATH):\n- # db_utils.create_database(self.db_file_path)\n- # TODO: Temporary when stabilized it will be possible to implement the db code creation\n- # If database file do not exist copy a new one\n- db_filename = os.path.basename(self.db_file_path)\n- db_create_sqlite.check_database_file(db_filename)\ntry:\n- common.debug('Trying connection to the database {}'.format(db_filename))\n+\n+ common.debug('Trying connection to the database {}'.format(self.db_filename))\nself.conn = sql.connect(self.db_file_path)\ncur = self.conn.cursor()\n- cur.execute('SELECT SQLITE_VERSION()')\n+ cur.execute(str('SELECT SQLITE_VERSION()'))\ncommon.debug('Database connection {} was successful (SQLite ver. {})'\n- .format(db_filename, cur.fetchone()[0]))\n+ .format(self.db_filename, cur.fetchone()[0]))\n+ cur.row_factory = lambda cursor, row: row[0]\n+ cur.execute(str('SELECT name FROM sqlite_master WHERE type=\\'table\\' '\n+ 'AND name NOT LIKE \\'sqlite_%\\''))\n+ list_tables = cur.fetchall()\n+ if len(list_tables) == 0:\n+ # If no tables exist create a new one\n+ self.conn.close()\n+ db_create_sqlite.create_database(self.db_file_path, self.db_filename)\nexcept sql.Error as e:\ncommon.error(\"SQLite error {}:\".format(e.args[0]))\nraise SQLiteConnectionError\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_create_sqlite.py", "new_path": "resources/lib/database/db_create_sqlite.py", "diff": "\"\"\"Functions to create new databases\"\"\"\nfrom __future__ import unicode_literals\n-import os\nimport sqlite3 as sql\n-from resources.lib.globals import g\n-\nimport resources.lib.common as common\nimport resources.lib.database.db_utils as db_utils\n-# TODO: In the future, when the databases are stable, we can create the sql code for db creation\n-# TODO: And so removing the db file copy\n-\n-\n-def check_database_file(db_filename):\n- \"\"\"If database file do not exist copy a new one from addon folder\"\"\"\n- if common.file_exists(db_filename, os.path.join(g.ADDON_DATA_PATH, 'database'))\\\n- and not common.file_exists(db_filename, os.path.join(g.DATA_PATH, 'database')):\n- common.debug('Database file {} is missing, copy a new one'.format(db_filename))\n-\n- common.copy_file(os.path.join(g.ADDON_DATA_PATH, 'database', db_filename),\n- os.path.join(g.DATA_PATH, 'database', db_filename))\n-\n-def create_database(db_file_path):\n- if db_utils.LOCAL_DB_FILENAME in db_file_path:\n+def create_database(db_file_path, db_filename):\n+ common.debug('The SQLite database {} is empty, creating tables'.format(db_filename))\n+ if db_utils.LOCAL_DB_FILENAME == db_filename:\n_create_local_database(db_file_path)\n- if db_utils.SHARED_DB_FILENAME in db_file_path:\n+ if db_utils.SHARED_DB_FILENAME == db_filename:\n_create_shared_database(db_file_path)\ndef _create_local_database(db_file_path):\n\"\"\"Create a new local database\"\"\"\n- pass\n+ conn = sql.connect(db_file_path)\n+ cur = conn.cursor()\n+\n+ table = str('CREATE TABLE app_config ('\n+ 'ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'\n+ 'Name TEXT UNIQUE NOT NULL,'\n+ 'Value TEXT);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE menu_data ('\n+ 'ContextId TEXT PRIMARY KEY NOT NULL,'\n+ 'Value TEXT);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE profiles ('\n+ 'ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,'\n+ 'Guid TEXT NOT NULL UNIQUE,'\n+ 'IsActive BOOLEAN DEFAULT (0) NOT NULL,'\n+ 'SortOrder INTEGER NOT NULL);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE profiles_config ('\n+ 'Guid TEXT NOT NULL,'\n+ 'Name TEXT NOT NULL,'\n+ 'Value TEXT,'\n+ 'PRIMARY KEY (Guid, Name ),'\n+ 'FOREIGN KEY (Guid)'\n+ 'REFERENCES Profiles (Guid) ON DELETE CASCADE ON UPDATE CASCADE);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE session ('\n+ 'Name TEXT PRIMARY KEY NOT NULL,'\n+ 'Value TEXT);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE settings_monitor ('\n+ 'Name TEXT PRIMARY KEY NOT NULL,'\n+ 'Value TEXT);')\n+ cur.execute(table)\n+\n+ if conn:\n+ conn.close()\ndef _create_shared_database(db_file_path):\n\"\"\"Create a new shared database\"\"\"\n- pass\n+ conn = sql.connect(db_file_path)\n+ cur = conn.cursor()\n+\n+ table = str('CREATE TABLE profiles ('\n+ 'ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,'\n+ 'Guid TEXT NOT NULL UNIQUE,'\n+ 'SortOrder INTEGER NOT NULL);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE shared_app_config ('\n+ 'ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'\n+ 'Name TEXT NOT NULL UNIQUE,'\n+ 'Value TEXT);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE stream_continuity ('\n+ 'ProfileGuid TEXT NOT NULL,'\n+ 'VideoID INTEGER NOT NULL,'\n+ 'Value TEXT,'\n+ 'DateLastModified TEXT NOT NULL,'\n+ 'PRIMARY KEY (ProfileGuid, VideoID ),'\n+ 'FOREIGN KEY (ProfileGuid)'\n+ 'REFERENCES Profiles (Guid) ON DELETE CASCADE ON UPDATE CASCADE);')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE video_lib_episodes ('\n+ 'EpisodeID INTEGER,'\n+ 'SeasonID INTEGER,'\n+ 'FilePath TEXT,'\n+ 'PRIMARY KEY (EpisodeID, SeasonID));')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE video_lib_movies ('\n+ 'MovieID INTEGER PRIMARY KEY NOT NULL,'\n+ 'FilePath TEXT NOT NULL,'\n+ 'NfoExport TEXT NOT NULL DEFAULT (\\'False\\'));')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE video_lib_seasons ('\n+ 'TvShowID INTEGER NOT NULL,'\n+ 'SeasonID INTEGER NOT NULL,'\n+ 'PRIMARY KEY (TvShowID, SeasonID));')\n+ cur.execute(table)\n+\n+ table = str('CREATE TABLE video_lib_tvshows ('\n+ 'TvShowID INTEGER PRIMARY KEY NOT NULL,'\n+ 'ExcludeUpdate TEXT NOT NULL DEFAULT (\\'False\\'),'\n+ 'NfoExport TEXT NOT NULL DEFAULT (\\'False\\'));')\n+ cur.execute(table)\n+\n+ if conn:\n+ conn.close()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/database/db_utils.py", "new_path": "resources/lib/database/db_utils.py", "diff": "@@ -4,6 +4,7 @@ from __future__ import unicode_literals\nimport os\nimport xbmc\n+import xbmcvfs\nimport resources.lib.common as common\nfrom enum import Enum\n@@ -29,6 +30,10 @@ class VidLibProp(Enum):\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+ if not xbmcvfs.exists(db_folder):\n+ xbmcvfs.mkdirs(db_folder)\nreturn xbmc.translatePath(os.path.join(g.DATA_PATH, 'database', db_filename))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Implemented create SQLite database
106,046
30.08.2019 19:58:44
-7,200
8b534a69e7a59fc136e642c1c1e3c02392439840
Readded superclass methods to shared db class
[ { "change_type": "MODIFY", "old_path": "resources/lib/database/db_shared.py", "new_path": "resources/lib/database/db_shared.py", "diff": "@@ -23,6 +23,19 @@ def get_shareddb_class(force_sqlite=False):\nelse:\nsuper(NFSharedDatabase, self).__init__(db_utils.SHARED_DB_FILENAME)\n+ def get_value(self, key, default_value=None, table=db_utils.TABLE_SHARED_APP_CONF,\n+ data_type=None):\n+ return super(NFSharedDatabase, self).get_value(key, default_value, table, data_type)\n+\n+ def get_values(self, key, default_value=None, table=db_utils.TABLE_SHARED_APP_CONF):\n+ return super(NFSharedDatabase, self).get_values(key, default_value, table)\n+\n+ def set_value(self, key, value, table=db_utils.TABLE_SHARED_APP_CONF):\n+ super(NFSharedDatabase, self).set_value(key, value, table)\n+\n+ def delete_key(self, key, table=db_utils.TABLE_SHARED_APP_CONF):\n+ super(NFSharedDatabase, self).delete_key(key, table)\n+\n@db_base_mysql.handle_connection\n@db_base_sqlite.handle_connection\ndef set_profile(self, guid, sort_order):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Readded superclass methods to shared db class
105,991
27.08.2019 19:46:32
-7,200
d6d69c041b4ad44c460465669057ad73b5a2fa20
Fix LibraryUpdateService at first run At service very first run, settings.xml is not created yet and throws an error "update_frequency = g.ADDON.getSettingInt('auto_update') TypeError: Invalid setting type"
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -96,6 +96,7 @@ class LibraryUpdateService(xbmc.Monitor):\ndef _compute_next_schedule():\n+ try:\nupdate_frequency = g.ADDON.getSettingInt('auto_update')\nif not update_frequency:\n@@ -116,3 +117,12 @@ def _compute_next_schedule():\nnext_run = last_run + timedelta(days=[0, 1, 2, 5, 7][update_frequency])\ncommon.debug('Next library auto update is scheduled for {}'.format(next_run))\nreturn next_run\n+ except Exception:\n+ # If settings.xml was not created yet, as at first service run\n+ # g.ADDON.getSettingInt('auto_update') will thrown a TypeError\n+ # If any other error appears, we don't want the service to crash,\n+ # let's return None in all case\n+ import traceback\n+ common.debug(traceback.format_exc())\n+ common.debug('Managed error at _compute_next_schedule')\n+ return None\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix LibraryUpdateService at first run At service very first run, settings.xml is not created yet and throws an error "update_frequency = g.ADDON.getSettingInt('auto_update') TypeError: Invalid setting type"
106,046
30.08.2019 20:35:24
-7,200
92936582b6ec67fe1a22324694ea4c56a00e482d
If falkor cache profile list is empty do not delete profiles
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/website.py", "new_path": "resources/lib/api/website.py", "diff": "@@ -76,6 +76,10 @@ def extract_profiles(falkor_cache):\n\"\"\"Extract profile information from Netflix website\"\"\"\ntry:\nprofiles_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)\nsort_order = 0\nfor guid, profile in profiles_list.items():\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
If falkor cache profile list is empty do not delete profiles
106,046
30.08.2019 21:00:15
-7,200
dd4a7b0917730a68076908bfa57f4439a701eec2
Version bump (15.2)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.1\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.2\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.15.2 (2019-08-30)\n+-Fixed key handshake at addon first run\n+-Fixed library update service at first run\n+-Local database now dynamically created by code\n+-Profile data is not deleted if an problem occurred\n+-Minor fixes\n+\nv0.15.1 (2019-08-25)\n-Fixed wrong path to linux systems\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (15.2)
106,046
01.09.2019 09:38:20
-7,200
6fc83dde0495e9b0e0e1bb08fc174db0a2fa7868
Updated request data
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -158,10 +158,7 @@ class MSLHandler(object):\n'version': 2,\n'url': '/manifest',\n'id': id,\n- 'esn': esn,\n'languages': [g.LOCAL_DB.get_value('locale_id')],\n- 'uiVersion': 'shakti-v5bca5cd3',\n- 'clientVersion': '6.0013.315.051',\n'params': {\n'type': 'standard',\n'viewableId': [viewable_id],\n@@ -173,13 +170,19 @@ class MSLHandler(object):\n'isBranching': False,\n'useHttpsStreams': False,\n'imageSubtitleHeight': 1080,\n- 'uiVersion': 'shakti-v5bca5cd3',\n+ 'uiVersion': 'shakti-v93016808',\n'uiPlatform': 'SHAKTI',\n- 'clientVersion': '6.0013.315.051',\n+ 'clientVersion': '6.0016.426.011',\n+ 'desiredVmaf': 'plus_lts', # phone_plus_exp can be used to mobile, not tested\n'supportsPreReleasePin': True,\n'supportsWatermark': True,\n+ 'supportsUnequalizedDownloadables': True,\n'showAllSubDubTracks': False,\n- 'titleSpecificData': {},\n+ 'titleSpecificData': {\n+ viewable_id: {\n+ 'unletterboxed': True\n+ }\n+ },\n'videoOutputInfo': [{\n'type': 'DigitalVideoOutputDescriptor',\n'outputType': 'unknown',\n@@ -188,7 +191,8 @@ class MSLHandler(object):\n}],\n'preferAssistiveAudio': False,\n'isNonMember': False\n- }\n+ },\n+ 'echo': ''\n}\nmanifest = self._chunked_request(ENDPOINTS['manifest'],\n@@ -214,10 +218,7 @@ class MSLHandler(object):\n'version': 2,\n'url': self.last_license_url,\n'id': id,\n- 'esn': g.get_esn(),\n'languages': [g.LOCAL_DB.get_value('locale_id')],\n- 'uiVersion': 'shakti-v5bca5cd3',\n- 'clientVersion': '6.0013.315.051',\n'params': [{\n'sessionId': sid,\n'clientTime': int(id / 10000),\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Updated request data
106,046
01.09.2019 10:20:09
-7,200
dd8bc57fd116c5279e3016a0e1e7f8eabf35600e
Added instructions to limit resolution
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "@@ -63,6 +63,7 @@ To understand if your device can handle them, you need to check if it has suppor\n- Other platform (Windows, Linux, ...)\nThe video is always software decoded due to Netflix licensing restrictions, so **you'll need a CPU that can handle the load of software decoding 1080p video** otherwise you'll have the result of stuttering video playback.\nWhich is what happens with certain RPI, 720p is maximum for those devices, and even then you need to make sure to properly cool your RPI or you'll have stuttering playback as well.\n+You can limit the resolution in this way: In the addon settings open Expert page and change `Limit video stream resolution to` value to 720p.\n### It only plays videos in 480p/720p, why is that?\ninputstream.adaptive selects the stream to play based on an initial bandwidth measurement and your screen resolution.\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added instructions to limit resolution
106,046
01.09.2019 19:14:13
-7,200
4dd93b8dbd30740d73f9c978100d3ebab748e7e8
New Issue and Pull request templates
[ { "change_type": "ADD", "old_path": null, "new_path": ".github/ISSUE_TEMPLATE/bug_report.md", "diff": "+---\n+name: Problem report\n+about: Create an extensive report to help us document a problem\n+\n+---\n+## Bug report\n+\n+#### Your Environment\n+- Netflix add-on version: <!--- e.g. 14.1 -->\n+- Operating system version/name: <!--- e.g. Windows 10, LibreElec 9.0, etc... -->\n+- Device model: <!--- if appropriate -->\n+\n+Used Operating system:\n+* [ ] Android\n+* [ ] iOS\n+* [ ] Linux\n+* [ ] OSX\n+* [ ] Raspberry-Pi\n+* [ ] Windows\n+\n+### Describe the bug\n+<!--- A bug report that is not clear will be closed -->\n+<!--- WHEN APPROPRIATE (MOST OF THE CASES) ALWAYS ATTACH THE LINK FOR KODI LOG FILE, SEE BELOW -->\n+<!--- Put your text below this line -->\n+\n+#### Expected behavior\n+<!--- Tell us what should happen -->\n+<!--- Put your text below this line -->\n+\n+#### Actual behavior\n+<!--- Tell us what happens instead -->\n+<!--- Put your text below this line -->\n+\n+#### Steps to reproduce the behavior\n+<!--- Put your text below this line -->\n+1.\n+2.\n+3.\n+\n+#### Possible fix\n+<!--- Not obligatory, but suggest a fix or reason for the bug -->\n+<!--- Put your text below this line -->\n+\n+### Debug log\n+<!--- How to get the log? Read Kodi wiki: https://kodi.wiki/view/Log_file/Easy\n+RESPECT THE RULES!\n+- A DEBUG LOG IS ALWAYS MANDATORY WHEN CREATING AN ISSUE. PROVIDE ONE!\n+- Do NOT PASTE THE CONTENT of the log HERE\n+- Do NOT CUT the log\n+- If the log file is really huge (more 1Mb) in Kodi settings disable \"Component-specific logging\" then create a new log\n+-->\n+The debug log can be found here:\n+\n+### Additional context or screenshots (if appropriate)\n+\n+#### Installation\n+* [ ] I'm using other Netflix Repo <!--- Specify which one is used -->\n+* [ ] I'm using a different source <!--- Specify which one is used -->\n+\n+#### Other information\n+<!--- E.g. related issues, suggestions, links for us to have context, etc... -->\n+<!--- Put your text below this line -->\n+\n+#### Screenshots\n+<!--- Add some screenshots if that helps understanding your problem -->\n+\n+\n+<!---\n+This addon respects the same rules used in the Kodi forum\n+https://kodi.wiki/view/Official:Forum_rules\n+therefore the single violation will eliminate your request\n+-->\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".github/ISSUE_TEMPLATE/feature_request.md", "diff": "+---\n+name: Feature request\n+about: Request for a new feature or to modify an existing one\n+\n+---\n+## Feature request\n+I'm submitting a proposal to ...\n+ - [ ] new feature\n+ - [ ] change an existing feature\n+\n+### Describe your request\n+<!--- Before opening a feature request, please take a moment to find out whether your idea fits with the scope of the project\n+taking into account the utility towards a wide community of people with different operating systems and devices.\n+Put your text below this line -->\n+\n+#### Describe the use case\n+<!--- Put your text below this line -->\n+\n+#### Describe an alternative\n+<!--- Not obligatory, concise description of any alternative solutions you've considered -->\n+<!--- Put your text below this line -->\n+\n+#### Development tips\n+<!--- Not obligatory, you can describe how you would develop it, attach links to already prepared code, etc... -->\n+<!--- Put your text below this line -->\n+\n+### Additional details or screenshots (if appropriate)\n+\n+#### Specific details\n+<!--- E.g. useful links to development, functionality for a specific operating system/device, etc... -->\n+<!--- Put your text below this line -->\n+\n+#### Screenshots\n+<!--- Add some screenshots if it helps develop the changes to be made -->\n+\n+\n+<!---\n+This add-on respects the same rules used in the Kodi forum\n+https://kodi.wiki/view/Official:Forum_rules\n+and in the Kodi add-on development rules\n+https://kodi.wiki/view/Add-on_rules\n+therefore the single violation will eliminate your request\n+-->\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".github/ISSUE_TEMPLATE/support_request.md", "diff": "+---\n+name: Support request\n+about: Request for help to use the add-on\n+\n+---\n+## Support request\n+\n+#### Your Environment\n+- Netflix add-on version: <!--- e.g. 14.1 -->\n+- Operating system version/name: <!--- e.g. Windows 10, LibreElec 9.0, etc... -->\n+- Device model: <!--- if appropriate -->\n+\n+Used Operating system:\n+* [ ] Android\n+* [ ] iOS\n+* [ ] Linux\n+* [ ] OSX\n+* [ ] Raspberry-Pi\n+* [ ] Windows\n+\n+### Describe your help request\n+<!--- A bug report that is not clear will be closed -->\n+<!--- WHEN APPROPRIATE (MOST OF THE CASES) ALWAYS ATTACH THE LINK FOR KODI LOG FILE, SEE BELOW -->\n+<!--- Put your text below this line -->\n+\n+#### Screenshots\n+<!--- Add some screenshots if that helps understanding your problem -->\n+\n+\n+<!---\n+This addon respects the same rules used in the Kodi forum\n+https://kodi.wiki/view/Official:Forum_rules\n+therefore the single violation will eliminate your request\n+-->\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".github/PULL_REQUEST_TEMPLATE/pull_request.md", "diff": "+### Check if this PR fulfills these requirements:\n+* [ ] My changes respect the [Kodi add-on development rules](https://kodi.wiki/view/Add-on_rules)\n+* [ ] I have read the [**CONTRIBUTING**](Contributing.md) document.\n+* [ ] I made sure there wasn't another one [Pull Requests](../../pulls) opened for the same update/change\n+* [ ] I have successfully tested my changes locally\n+\n+#### Types of changes\n+- [ ] New feature (non-breaking change which adds functionality)\n+- [ ] Feature change (non-breaking change which change behaviour of an existing functionality)\n+- [ ] Improvement (non-breaking change which improve functionality)\n+- [ ] Bug fix (non-breaking change which fixes an issue)\n+- [ ] Breaking change (fix or feature that would cause existing functionality to change)\n+\n+### Description\n+<!--- Motivation and a possible detailed explanation of the changes -->\n+<!--- Put your text below this line -->\n+\n+### In case of Feature change / Breaking change:\n+#### Describe the current behavior\n+<!--- Put your text below this line -->\n+\n+#### Describe the new behavior\n+<!--- Put your text below this line -->\n+\n+### Screenshots (if appropriate):\n+<!--- Add some screenshots if they can be useful to show the differences between before and after the changes -->\n" }, { "change_type": "DELETE", "old_path": "ISSUE_TEMPLATE.md", "new_path": null, "diff": "-*I'm submitting a ...*\n- - [ ] bug report\n- - [ ] feature request\n- - [ ] support request\n-\n-## General information\n-\n-### Addon version used\n-\n-[eg. 13.21.0]\n-\n-### Description\n-\n-[Description of the bug or feature]\n-\n-### Steps to Reproduce\n-\n-1. [First Step]\n-2. [Second Step]\n-3. [and so on...]\n-\n-**Expected behavior:** [What you expected to happen]\n-\n-**Actual behavior:** [What actually happened]\n-\n-## Context (Environment)\n-\n-### Installation\n-\n-* [ ] I'm using this Netflix Repo\n-* [ ] I'm using other Netflix Repo (Please specify which)\n-* [ ] I'm using a different source (Please tell which)\n-\n-### Operating System\n-\n-* [ ] Linux (x86/x64)\n-* [ ] OSX (x86/x64)\n-* [ ] Windows (x86/x64)\n-* [ ] Linux (ARM)\n-* [ ] Android\n-\n-#### Additional informatin on the environment\n-\n-[Descripe your environment a bit more detailed, are you using LibreElec f.e.]\n-\n-## Debug log\n-\n-SIMPLE RULES:\n-- Before performing any operation enable Kodi debug logging [Settings->System->Logging->Enable debug logging] only after perform the operations to reproduce the issue\n-- Copy here a link to your debug log, use something like [https://paste.kodi.tv/](https://paste.kodi.tv/) or similar\n-- Do NOT paste the content of the log here\n-- Do NOT cut the log\n-- If the log file is really huge (more than 1Mb) then in Kodi settings disable the *Component-specific logging*\n-\n-## Other information\n-\n-[e.g. detailed explanation, related issues, suggestions how to fix, links for us to have context, etc.]\n-\n-### Screenshots\n-\n-[Please add a screenshot if that helps understanding your problem]\n-\n-[You can erase any parts of this template not applicable to your Issue.]\n" }, { "change_type": "DELETE", "old_path": "PULL_REQUEST_TEMPLATE.md", "new_path": null, "diff": "-## Types of changes\n-\n-- [ ] Bug fix (non-breaking change which fixes an issue)\n-- [ ] New feature (non-breaking change which adds functionality)\n-- [ ] Breaking change (fix or feature that would cause existing functionality to change)\n-- [ ] I have read the [**CONTRIBUTING**](Contributing.md) document.\n-\n-### All Submissions:\n-\n-* [ ] Have you followed the guidelines in our Contributing document?\n-* [ ] Have you checked to ensure there aren't other open [Pull Requests](../../pulls) for the same update/change?\n-\n-\n-### Changes to Core Features:\n-\n-* [ ] Have you added an explanation of what your changes do and why you'd like us to include them?\n-* [ ] Have you successfully ran tests with your changes locally?\n-\n-## Screenshots (if appropriate):\n-\n-[You can erase any parts of this template not applicable to your Pull Request.]\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
New Issue and Pull request templates
106,046
04.09.2019 19:57:06
-7,200
af6db6acee5b80c7138f5625c2d4577baeae1504
Descriptions for the newbies..
[ { "change_type": "MODIFY", "old_path": ".github/ISSUE_TEMPLATE/bug_report.md", "new_path": ".github/ISSUE_TEMPLATE/bug_report.md", "diff": "---\nname: Problem report\n-about: Create an extensive report to help us document a problem\n+about: If something doesn't work\n---\n## Bug report\n" }, { "change_type": "MODIFY", "old_path": ".github/ISSUE_TEMPLATE/feature_request.md", "new_path": ".github/ISSUE_TEMPLATE/feature_request.md", "diff": "---\nname: Feature request\n-about: Request for a new feature or to modify an existing one\n+about: If you want to propose a new feature or to modify an existing one\n---\n## Feature request\n" }, { "change_type": "MODIFY", "old_path": ".github/ISSUE_TEMPLATE/support_request.md", "new_path": ".github/ISSUE_TEMPLATE/support_request.md", "diff": "---\n-name: Support request\n-about: Request for help to use the add-on\n+name: Help request\n+about: If you need help on how to use the addon\n---\n-## Support request\n+## Help request\n#### Your Environment\n- Netflix add-on version: <!--- e.g. 14.1 -->\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Descriptions for the newbies..
105,993
09.09.2019 02:16:59
-7,200
e1a59ce8826ac57f553d85086d749b78b4a6a376
Separate run tests in Makefile
[ { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -18,7 +18,7 @@ blue = \\e[1;34m\nwhite = \\e[1;37m\nreset = \\e[0m\n-all: clean sanity unit docs\n+all: clean test zip\nclean:\nfind . -name '*.pyc' -type f -delete\n@@ -44,13 +44,17 @@ addon: clean\nunit:\n@echo -e \"$(white)=$(blue) Starting unit tests$(reset)\"\n+ python -m unittest discover\n+\n+run:\n+ @echo -e \"$(white)=$(blue) Run CLI$(reset)\"\n# python test/run.py /action/purge_cache/\n# python test/run.py /action/purge_cache/?on_disk=True\n-# python service.py\n# python test/run.py /\n# python test/run.py /directory/root\n# python test/run.py /directory/search/cartoon\n- python -m unittest discover\n+# python service.py\n+ python test/run.py /\nzip: clean\n@echo -e \"$(white)=$(blue) Building new package$(reset)\"\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/api/data_types.py", "new_path": "resources/lib/api/data_types.py", "diff": "@@ -202,7 +202,7 @@ class SubgenreList(object):\n\"\"\"A list of subgenre.\"\"\"\ndef __init__(self, path_response):\ncommon.debug('Subgenre data: {}'.format(path_response))\n- self.lists = {}\n+ self.lists = []\nif path_response:\nself.perpetual_range_selector = path_response.get('_perpetual_range_selector')\ngenre_id = next(path_response.get('genres', {}).iterkeys())\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Separate run tests in Makefile
105,993
09.09.2019 03:55:03
-7,200
3c3a9f867a3a68009dceebb83ce89e4e20413f78
First integration tests This is the first set of integration tests.
[ { "change_type": "MODIFY", "old_path": ".travis.yml", "new_path": ".travis.yml", "diff": "@@ -18,10 +18,19 @@ script:\n- tox\n- tox -e flake8\n- pylint resources/lib/ test/\n-#- kodi-addon-checker . --branch=leia\n-#- coverage run service.py\n-#- coverage run test/run.py /\n-- coverage run -m unittest discover\n+#- coverage run -m unittest discover\n+#- coverage run -a service.py\n+#- sleep 10\n+#- coverage run -a test/run.py /directory/root\n+#- coverage run -a test/run.py /directory/profiles\n+#- coverage run -a test/run.py /directory/home\n+#- coverage run -a test/run.py /directory/video_list_sorted/myList/queue\n+#- coverage run -a test/run.py /directory/video_list_sorted/newRelease/newRelease\n+#- coverage run -a test/run.py /directory/video_list/continueWatching/continueWatching\n+#- coverage run -a test/run.py /directory/video_list/chosenForYou/topTen\n+#- coverage run -a test/run.py /directory/video_list/recentlyAdded/1592210\n+#- coverage run -a test/run.py /directory/show/80057281/\n+#- pkill -f service.py\nafter_success:\n- codecov\n" }, { "change_type": "MODIFY", "old_path": "Makefile", "new_path": "Makefile", "diff": "@@ -48,13 +48,25 @@ unit:\nrun:\n@echo -e \"$(white)=$(blue) Run CLI$(reset)\"\n-# python test/run.py /action/purge_cache/\n-# python test/run.py /action/purge_cache/?on_disk=True\n-# python test/run.py /\n-# python test/run.py /directory/root\n-# python test/run.py /directory/search/cartoon\n-# python service.py\n- python test/run.py /\n+ coverage run -a service.py &\n+ sleep 10\n+ coverage run -a test/run.py /action/purge_cache/\n+ coverage run -a test/run.py /action/purge_cache/?on_disk=True\n+ coverage run -a test/run.py /directory/root\n+ coverage run -a test/run.py /directory/profiles\n+ coverage run -a test/run.py /directory/home\n+ coverage run -a test/run.py /directory/video_list_sorted/myList/queue\n+ coverage run -a test/run.py /directory/video_list_sorted/newRelease/newRelease\n+ coverage run -a test/run.py /directory/video_list/continueWatching/continueWatching\n+ coverage run -a test/run.py /directory/video_list/chosenForYou/topTen\n+ coverage run -a test/run.py /directory/video_list/recentlyAdded/1592210\n+ coverage run -a test/run.py /directory/show/80057281/\n+ coverage run -a test/run.py /directory/show/80057281/season/80186799/\n+ coverage run -a test/run.py /directory/genres/tvshows/83/\n+ coverage run -a test/run.py /directory/genres/movies/34399/\n+ coverage run -a test/run.py /directory/search/search/cool\n+ coverage run -a test/run.py /directory/exported/exported\n+ pkill -ef service.py\nzip: clean\n@echo -e \"$(white)=$(blue) Building new package$(reset)\"\n" }, { "change_type": "MODIFY", "old_path": "test/run.py", "new_path": "test/run.py", "diff": "@@ -14,13 +14,13 @@ xbmcgui = __import__('xbmcgui')\nxbmcplugin = __import__('xbmcplugin')\nxbmcvfs = __import__('xbmcvfs')\n-default = '/mainmenu'\n+default = 'directory/root'\nif len(sys.argv) > 1:\n- path = sys.argv[1] or default\n+ path = sys.argv[1].lstrip('/') or default\nelse:\npath = default\n-uri = 'plugin://plugin.video.netflix{path}'.format(path=path)\n+uri = 'plugin://plugin.video.netflix/{path}'.format(path=path)\nsys.argv = [uri, '0', '']\n" }, { "change_type": "MODIFY", "old_path": "test/xbmc.py", "new_path": "test/xbmc.py", "diff": "@@ -28,6 +28,7 @@ LOGNONE = 'None'\nINFO_LABELS = {\n'System.BuildVersion': '18.2',\n+ 'Container.FolderPath': 'plugin://plugin.video.netflix/',\n}\nREGIONS = {\n@@ -135,7 +136,7 @@ def getCondVisibility(string):\ndef getGlobalIdleTime():\n''' A reimplementation of the xbmc getGlobalIdleTime() function '''\n- return 1\n+ return 0\ndef getInfoLabel(key):\n@@ -190,9 +191,9 @@ def sleep(seconds):\ndef translatePath(path):\n''' A stub implementation of the xbmc translatePath() function '''\nif path.startswith('special://home'):\n- return path.replace('special://home', os.path.join(os.getcwd(), 'test/'))\n+ return path.replace('special://home', os.path.join(os.getcwd(), 'test'))\nif path.startswith('special://profile'):\n- return path.replace('special://profile', os.path.join(os.getcwd(), 'test/usedata/'))\n+ return path.replace('special://profile', os.path.join(os.getcwd(), 'test/usedata'))\nif path.startswith('special://userdata'):\n- return path.replace('special://userdata', os.path.join(os.getcwd(), 'test/userdata/'))\n+ return path.replace('special://userdata', os.path.join(os.getcwd(), 'test/userdata'))\nreturn path\n" }, { "change_type": "MODIFY", "old_path": "test/xbmcextra.py", "new_path": "test/xbmcextra.py", "diff": "@@ -113,12 +113,13 @@ def addon_settings():\nwith open('test/userdata/credentials.json') as f:\nsettings.update(json.load(f))\nexcept (IOError, OSError) as e:\n- if 'NETFLIX_USERNAME' in os.environ and 'NETFLIX_PASSWORD' in os.environ and 'NETFLIX_ESN' in os.environ:\n+ if os.environ.get('NETFLIX_USERNAME') and os.environ.get('NETFLIX_PASSWORD'):\nprint('Using credentials from the environment variables NETFLIX_USERNAME, NETFLIX_PASSWORD and NETFLIX_ESN')\nsettings['username'] = os.environ.get('NETFLIX_USERNAME')\nsettings['password'] = os.environ.get('NETFLIX_PASSWORD')\n+ if os.environ.get('NETFLIX_ESN'):\nsettings['esn'] = os.environ.get('NETFLIX_ESN')\n- else:\n+ if not settings.get('username') and not settings.get('password') or not settings.get('esn'):\nprint(\"Error using 'test/userdata/credentials.json': %s\" % e, file=sys.stderr)\nreturn settings\n" }, { "change_type": "MODIFY", "old_path": "test/xbmcgui.py", "new_path": "test/xbmcgui.py", "diff": "@@ -55,7 +55,9 @@ class Dialog:\nreturn os.environ.get('NETFLIX_USERNAME')\nif heading == 'Password':\nreturn os.environ.get('NETFLIX_PASSWORD')\n- return ''\n+ if heading == 'Search term':\n+ return 'Family'\n+ return 'Foobar'\n@staticmethod\ndef numeric(type, heading, defaultt=''): # pylint: disable=redefined-builtin\n@@ -195,6 +197,8 @@ class Window:\ndef getProperty(self, key):\n''' A stub implementation for the xbmcgui Window class getProperty() method '''\n+ print('xbmcgui getProperty {key}'.format(key=key))\n+ return ''\ndef setProperty(self, key, value):\n''' A stub implementation for the xbmcgui Window class setProperty() method '''\n" }, { "change_type": "MODIFY", "old_path": "test/xbmcvfs.py", "new_path": "test/xbmcvfs.py", "diff": "@@ -10,7 +10,11 @@ import shutil\ndef File(path, flags='r'):\n''' A reimplementation of the xbmcvfs File() function '''\n+ try:\nreturn open(path, flags)\n+ except IOError:\n+ from StringIO import StringIO\n+ return StringIO('')\ndef Stat(path):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
First integration tests This is the first set of integration tests.
105,991
10.09.2019 01:24:27
-7,200
c27f437ec4ad70a20151a3f80c459f4c020b3c0e
Improve LibraryUpdateService: wait for settings to be written
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -62,6 +62,9 @@ class LibraryUpdateService(xbmc.Monitor):\nAs settings changed, we will compute next schedule again\nto ensure it's still correct\n\"\"\"\n+ # wait for slow system (like Raspberry Pi) to write the settings\n+ xbmc.sleep(500)\n+ # then compute the next schedule\nself.next_schedule = _compute_next_schedule()\ndef onScanStarted(self, library):\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Improve LibraryUpdateService: wait for settings to be written
105,991
10.09.2019 17:02:02
-7,200
40828942d9bcd508b02c525f823225468119c71e
Fix library.py _get_item when source is "special://" If the item path is "special://" we need to search both translated and untranslated paths in the kodi library, because it's possible to add a "special://" path to sources
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/library.py", "new_path": "resources/lib/kodi/library.py", "diff": "@@ -81,14 +81,25 @@ def _get_item(mediatype, filename):\n# To ensure compatibility with previously exported items,\n# make the filename legal\nfname = xbmc.makeLegalFilename(filename)\n- path = os.path.dirname(xbmc.translatePath(fname).decode(\"utf-8\"))\n+ untranslated_path = os.path.dirname(fname).decode(\"utf-8\")\n+ translated_path = os.path.dirname(xbmc.translatePath(fname).decode(\"utf-8\"))\nshortname = os.path.basename(xbmc.translatePath(fname).decode(\"utf-8\"))\n# We get the data from Kodi library using filters.\n# This is much faster than loading all episodes in memory\n+\n+ # First build the path filter, we may have to search in both special and translated path\n+ path_filter = {'field': 'path', 'operator': 'startswith', 'value': translated_path} \\\n+ if fname[:10] != 'special://' \\\n+ else {'or': [\n+ {'field': 'path', 'operator': 'startswith', 'value': translated_path},\n+ {'field': 'path', 'operator': 'startswith', 'value': untranslated_path}\n+ ]}\n+\n+ # Now build the all request and call the json-rpc function through common.get_library_items\nlibrary_item = common.get_library_items(\nmediatype,\n{'and': [\n- {'field': 'path', 'operator': 'startswith', 'value': path},\n+ path_filter,\n{'field': 'filename', 'operator': 'is', 'value': shortname}\n]})[0]\nif not library_item:\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix library.py _get_item when source is "special://" If the item path is "special://" we need to search both translated and untranslated paths in the kodi library, because it's possible to add a "special://" path to sources https://github.com/CastagnaIT/plugin.video.netflix/issues/199#issuecomment-529958007
106,046
14.09.2019 13:41:34
-7,200
a3c4ccd66561b95e17156f92f1d6a2cded6f89b9
Removed mac uuid in favour of device uuid This fixes problems with newer androids 9/10 that have random mac address and also with apple devices
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/__init__.py", "new_path": "resources/lib/common/__init__.py", "diff": "@@ -13,3 +13,4 @@ from .kodiops import *\nfrom .pathops import *\nfrom .misc_utils import *\nfrom .data_conversion import *\n+from .uuid_device import *\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/common/credentials.py", "new_path": "resources/lib/common/credentials.py", "diff": "@@ -6,32 +6,9 @@ from resources.lib.globals import g\nfrom resources.lib.api.exceptions import MissingCredentialsError\nfrom .logging import error\n+from .uuid_device import get_crypt_key\n__BLOCK_SIZE__ = 32\n-__CRYPT_KEY__ = None\n-\n-\n-def __crypt_key():\n- \"\"\"\n- Lazily generate the crypt key and return it\n- \"\"\"\n- # pylint: disable=global-statement\n- global __CRYPT_KEY__\n- if not __CRYPT_KEY__:\n- __CRYPT_KEY__ = __uniq_id()\n- return __CRYPT_KEY__\n-\n-\n-def __uniq_id():\n- \"\"\"\n- Returns a unique id based on the devices MAC address\n- \"\"\"\n- import uuid\n- mac = uuid.getnode()\n- if (mac >> 40) % 2:\n- from platform import node\n- mac = node()\n- return uuid.uuid5(uuid.NAMESPACE_DNS, str(mac)).bytes\ndef encrypt_credential(raw):\n@@ -49,7 +26,7 @@ def encrypt_credential(raw):\nfrom Cryptodome.Util import Padding\nraw = bytes(Padding.pad(data_to_pad=raw, block_size=__BLOCK_SIZE__))\niv = Random.new().read(AES.block_size)\n- cipher = AES.new(__crypt_key(), AES.MODE_CBC, iv)\n+ cipher = AES.new(get_crypt_key(), AES.MODE_CBC, iv)\nreturn base64.b64encode(iv + cipher.encrypt(raw))\n@@ -67,7 +44,7 @@ def decrypt_credential(enc, secret=None):\nfrom Cryptodome.Util import Padding\nenc = base64.b64decode(enc)\niv = enc[:AES.block_size]\n- cipher = AES.new(secret or __uniq_id(), AES.MODE_CBC, iv)\n+ cipher = AES.new(secret or get_crypt_key(), AES.MODE_CBC, iv)\ndecoded = Padding.unpad(\npadded_data=cipher.decrypt(enc[AES.block_size:]),\nblock_size=__BLOCK_SIZE__).decode('utf-8')\n" }, { "change_type": "ADD", "old_path": null, "new_path": "resources/lib/common/uuid_device.py", "diff": "+# -*- coding: utf-8 -*-\n+\"\"\"Get the UUID of the device\"\"\"\n+from __future__ import absolute_import, division, unicode_literals\n+\n+from .logging import debug\n+from .misc_utils import get_system_platform\n+\n+try: # Python 2\n+ from __builtin__ import str as text\n+except ImportError: # Python 3\n+ from builtins import str as text\n+\n+__CRYPT_KEY__ = None\n+\n+\n+def get_crypt_key():\n+ \"\"\"\n+ Lazily generate the crypt key and return it\n+ \"\"\"\n+ # pylint: disable=global-statement\n+ global __CRYPT_KEY__\n+ if not __CRYPT_KEY__:\n+ __CRYPT_KEY__ = _get_system_uuid()\n+ return __CRYPT_KEY__\n+\n+\n+def get_random_uuid():\n+ \"\"\"\n+ Generate a random uuid\n+ :return: a string of a random uuid\n+ \"\"\"\n+ import uuid\n+ return text(uuid.uuid4())\n+\n+\n+def _get_system_uuid():\n+ \"\"\"\n+ Try to get an uuid from the system, if it's not possible generates a fake uuid\n+ :return: an uuid converted to MD5\n+ \"\"\"\n+ import uuid\n+ uuid_value = None\n+ system = get_system_platform()\n+ if system in ['windows', 'xbox']:\n+ uuid_value = _get_windows_uuid()\n+ elif system == 'android':\n+ uuid_value = _get_android_uuid()\n+ elif system == 'linux':\n+ uuid_value = _get_linux_uuid()\n+ elif system in ['osx', 'ios']:\n+ uuid_value = _get_macos_uuid()\n+ if not uuid_value:\n+ debug('It is not possible to get a system UUID creating a new UUID')\n+ uuid_value = _get_fake_uuid(system != 'android')\n+ return uuid.uuid5(uuid.NAMESPACE_DNS, text(uuid_value)).bytes\n+\n+\n+def _get_windows_uuid():\n+ # pylint: disable=broad-except\n+ # pylint: disable=no-member\n+ uuid_value = None\n+ try:\n+ try: # Python 2\n+ import _winreg as winreg\n+ except ImportError: # Python 3\n+ import winreg as winreg\n+ registry = winreg.HKEY_LOCAL_MACHINE\n+ address = 'SOFTWARE\\\\Microsoft\\\\Cryptography'\n+ keyargs = winreg.KEY_READ | winreg.KEY_WOW64_64KEY\n+ key = winreg.OpenKey(registry, address, 0, keyargs)\n+ value = winreg.QueryValueEx(key, 'MachineGuid')\n+ winreg.CloseKey(key)\n+ uuid_value = value[0]\n+ except Exception:\n+ pass\n+ if not uuid_value:\n+ try:\n+ import subprocess\n+ output = subprocess.check_output(['vol', 'c:'])\n+ output = output.split()\n+ uuid_value = output[len(output) - 1:]\n+ except Exception:\n+ pass\n+ return uuid_value\n+\n+\n+def _get_linux_uuid():\n+ # pylint: disable=broad-except\n+ import subprocess\n+ uuid_value = None\n+ try:\n+ uuid_value = subprocess.check_output(['cat', '/var/lib/dbus/machine-id']).decode('utf-8')\n+ except Exception:\n+ pass\n+ if not uuid_value:\n+ try:\n+ # Fedora linux\n+ uuid_value = subprocess.check_output(['cat', '/etc/machine-id']).decode('utf-8')\n+ except Exception:\n+ pass\n+ return uuid_value\n+\n+\n+def _get_android_uuid():\n+ # pylint: disable=broad-except\n+ import subprocess\n+ import re\n+ values = ''\n+ try:\n+ # Due to the new android security we cannot get any type of serials\n+ sys_prop = ['ro.product.board', 'ro.product.brand', 'ro.product.device', 'ro.product.locale'\n+ 'ro.product.manufacturer', 'ro.product.model', 'ro.product.platform',\n+ 'persist.sys.timezone', 'persist.sys.locale', 'net.hostname']\n+ # Warning net.hostname property starting from android 10 is deprecated return empty\n+ proc = subprocess.Popen(['/system/bin/getprop'], stdout=subprocess.PIPE)\n+ output_data = proc.stdout.read().decode('utf-8')\n+ proc.stdout.close()\n+ list_values = output_data.splitlines()\n+ for value in list_values:\n+ value_splitted = re.sub(r'\\[|\\]|\\s', '', value).split(':')\n+ if value_splitted[0] in sys_prop:\n+ values += value_splitted[1]\n+ except Exception:\n+ pass\n+ return values\n+\n+\n+def _get_macos_uuid():\n+ # pylint: disable=broad-except\n+ import subprocess\n+ sp_dict_values = None\n+ try:\n+ proc = subprocess.Popen(\n+ ['/usr/sbin/system_profiler', 'SPHardwareDataType', '-detaillevel', 'full', '-xml'],\n+ stdout=subprocess.PIPE)\n+ output_data = proc.stdout.read().decode('utf-8')\n+ proc.stdout.close()\n+ if output_data:\n+ sp_dict_values = _parse_osx_xml_plist_data(output_data)\n+ except Exception as exc:\n+ debug('Failed to fetch OSX/IOS system profile {}'.format(exc))\n+ if sp_dict_values:\n+ if 'UUID' in sp_dict_values.keys():\n+ return sp_dict_values['UUID']\n+ if 'serialnumber' in sp_dict_values.keys():\n+ return sp_dict_values['serialnumber']\n+ return None\n+\n+\n+def _parse_osx_xml_plist_data(data):\n+ import plistlib\n+ import re\n+ dict_values = {}\n+ try: # Python 2\n+ xml_data = plistlib.readPlistFromString(data)\n+ except AttributeError: # Python => 3.4\n+ # pylint: disable=no-member\n+ xml_data = plistlib.loads(data)\n+\n+ items_dict = xml_data[0]['_items'][0]\n+ r = re.compile(r'.*UUID.*') # Find to example \"platform_UUID\" key\n+ uuid_keys = filter(r.match, items_dict.keys())\n+ if uuid_keys:\n+ dict_values['UUID'] = items_dict[uuid_keys[0]]\n+ if not uuid_keys:\n+ r = re.compile(r'.*serial.*number.*') # Find to example \"serial_number\" key\n+ serialnumber_keys = filter(r.match, items_dict.keys())\n+ if serialnumber_keys:\n+ dict_values['serialnumber'] = items_dict[serialnumber_keys[0]]\n+ return dict_values\n+\n+\n+def _get_fake_uuid(with_hostname=True):\n+ \"\"\"\n+ Generate a uuid based on various system information\n+ \"\"\"\n+ import xbmc\n+ import platform\n+ list_values = [xbmc.getInfoLabel('System.Memory(total)')]\n+ if with_hostname:\n+ list_values.append(platform.node())\n+ return '_'.join(list_values)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Removed mac uuid in favour of device uuid This fixes problems with newer androids 9/10 that have random mac address and also with apple devices
106,046
08.09.2019 19:20:33
-7,200
ae61d7da0cfbab70de908301cac9a82b919830f9
Use randomized uuid with library autoupdate
[ { "change_type": "MODIFY", "old_path": "resources/lib/common/misc_utils.py", "new_path": "resources/lib/common/misc_utils.py", "diff": "@@ -21,16 +21,6 @@ from .logging import debug, info, error\nfrom .kodiops import get_local_string\n-def get_device_uuid():\n- \"\"\"Generate an uuid for the current device based on the device MAC address\"\"\"\n- import uuid\n- mac = uuid.getnode()\n- if (mac >> 40) % 2:\n- from platform import node\n- mac = node()\n- return str(uuid.uuid5(uuid.NAMESPACE_DNS, str(mac)))\n-\n-\ndef find(value_to_find, attribute, search_space):\n\"\"\"Find a video with matching id in a dict or list\"\"\"\nfor video in search_space:\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/navigation/library.py", "new_path": "resources/lib/navigation/library.py", "diff": "@@ -140,7 +140,9 @@ class LibraryActionExecutor(object):\ndef set_autoupdate_device(self, pathitems): # pylint: disable=unused-argument\n\"\"\"Set the current device to manage auto-update of the shared-library (MySQL)\"\"\"\n- g.SHARED_DB.set_value('auto_update_device_uuid', common.get_device_uuid())\n+ random_uuid = common.get_random_uuid()\n+ g.LOCAL_DB.set_value('client_uuid', random_uuid)\n+ g.SHARED_DB.set_value('auto_update_device_uuid', random_uuid)\nui.show_notification(common.get_local_string(30209), time=8000)\ndef check_autoupdate_device(self, pathitems): # pylint: disable=unused-argument\n@@ -149,7 +151,7 @@ class LibraryActionExecutor(object):\nif uuid is None:\nmsg = common.get_local_string(30212)\nelse:\n- current_device_uuid = common.get_device_uuid()\n+ client_uuid = g.LOCAL_DB.get_value('client_uuid')\nmsg = common.get_local_string(30210) \\\n- if current_device_uuid == uuid else common.get_local_string(30211)\n+ if client_uuid == uuid else common.get_local_string(30211)\nui.show_notification(msg, time=8000)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/library_updater.py", "new_path": "resources/lib/services/library_updater.py", "diff": "@@ -103,9 +103,9 @@ def _compute_next_schedule():\ncommon.debug('Library auto update scheduled is disabled')\nreturn None\nif g.ADDON.getSettingBool('use_mysql'):\n- current_device_uuid = common.get_device_uuid()\n+ client_uuid = g.LOCAL_DB.get_value('client_uuid')\nuuid = g.SHARED_DB.get_value('auto_update_device_uuid')\n- if current_device_uuid != uuid:\n+ if client_uuid != uuid:\ncommon.debug('The auto update has been disabled because another device '\n'has been set as the main update manager')\nreturn None\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Use randomized uuid with library autoupdate
105,993
18.09.2019 17:49:17
-7,200
e67b474b5bdaf71d1960668bcad52d4e2c33960f
Small fixes after pylint/flake cleanup
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_actions.py", "new_path": "resources/lib/upgrade_actions.py", "diff": "@@ -35,7 +35,7 @@ def migrate_library_to_db():\nif videoid.mediatype == common.VideoId.MOVIE:\nlibrary.add_to_library(videoid, item['file'], False, False)\n- elif videoid.mediatype != common.VideoId.SHOW:\n+ if videoid.mediatype != common.VideoId.SHOW:\ncontinue\nfor season_key in item.keys():\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Small fixes after pylint/flake cleanup
105,991
18.09.2019 17:20:55
-7,200
2d3b0e865b7116d2e55bfed9c69dcec789724240
Fix perpetual_path_request after Pylint fixes
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -296,7 +296,6 @@ class NetflixSession(object):\n.format(response_type))\nelse:\nrange_end = range_start + request_size\n- break\nif perpetual_range_start > 0:\nprevious_start = perpetual_range_start - (response_size * number_of_requests)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fix perpetual_path_request after Pylint fixes
105,993
19.09.2019 20:07:41
-7,200
d7cec432d45ef9cada7ad07ce0495d9f5f638c95
Add more Dutch translations and fix English spelling
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<summary lang=\"en_GB\">Netflix</summary>\n<description lang=\"en_GB\">Netflix VOD Services Addon</description>\n<disclaimer lang=\"en_GB\">Some parts of this addon may not be legal in your country of residence - please check with your local laws before installing.</disclaimer>\n+ <summary lang=\"nl_NL\">Netflix</summary>\n+ <description lang=\"nl_NL\">Bekijk Netflix films en tvprogramma's in Kodi.</description>\n+ <disclaimer lang=\"nl_NL\">Sommige delen van deze add-on zijn mogelijk onwettig in jouw land - raadpleeg de lokale wetgeving alvorens deze add-on te installeren.</disclaimer>\n<description lang=\"it_IT\">Netflix Addon servizi VOD</description>\n<disclaimer lang=\"it_IT\">Alcune parti di questo addon potrebbero non essere legali nel proprio paese di residenza - si prega di verificare le leggi locali prima dell'installazione.</disclaimer>\n<assets>\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": "@@ -853,17 +853,17 @@ msgid \"Check if this device is the main auto-update manager\"\nmsgstr \"\"\nmsgctxt \"#30209\"\n-msgid \"This device now handle the auto-updates of shared-library\"\n+msgid \"This device now handles the auto-updates of shared-library\"\nmsgstr \"\"\nmsgctxt \"#30210\"\n-msgid \"This device handle the auto-updates of shared-library\"\n+msgid \"This device handles the auto-updates of shared-library\"\nmsgstr \"\"\nmsgctxt \"#30211\"\n-msgid \"Another device handle the auto-updates of shared-library\"\n+msgid \"Another device handles the auto-updates of shared-library\"\nmsgstr \"\"\nmsgctxt \"#30212\"\n-msgid \"There is no device that handle the auto-updates of shared-library\"\n+msgid \"There is no device that handles the auto-updates of shared-library\"\nmsgstr \"\"\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": "@@ -853,17 +853,17 @@ msgid \"Check if this device is the main auto-update manager\"\nmsgstr \"Verifica se questo dispositivo gestisce gli aggiornamenti automatici\"\nmsgctxt \"#30209\"\n-msgid \"This device now handle the auto-updates of shared-library\"\n+msgid \"This device now handles the auto-updates of shared-library\"\nmsgstr \"Questo dispositivo ora gestisce gli aggiornamenti automatici alla libreria\"\nmsgctxt \"#30210\"\n-msgid \"This device handle the auto-updates of shared-library\"\n+msgid \"This device handles the auto-updates of shared-library\"\nmsgstr \"Questo dispositivo gestisce gli aggiornamenti automatici alla libreria\"\nmsgctxt \"#30211\"\n-msgid \"Another device handle the auto-updates of shared-library\"\n+msgid \"Another device handles the auto-updates of shared-library\"\nmsgstr \"Un'altro dispositivo sta gestendo gli aggiornamenti automatici alla libreria\"\nmsgctxt \"#30212\"\n-msgid \"There is no device that handle the auto-updates of shared-library\"\n+msgid \"There is no device that handles the auto-updates of shared-library\"\nmsgstr \"Nessun dispositivo sta gestendo gli aggiornamenti automatici alla libreria\"\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Add more Dutch translations and fix English spelling
106,046
19.09.2019 20:13:27
-7,200
c03b3ebbc2fe5178ed3c8e99a8eb323b6c16741e
Version bump (0.15.3)
[ { "change_type": "MODIFY", "old_path": "addon.xml", "new_path": "addon.xml", "diff": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n-<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.2\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.15.3\" provider-name=\"libdev + jojo + asciidisco + caphm + castagnait\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.26.0\"/>\n<import addon=\"script.module.addon.signals\" version=\"0.0.3\"/>\n<forum>https://forum.kodi.tv/showthread.php?tid=329767</forum>\n<source>https://github.com/CastagnaIT/plugin.video.netflix</source>\n<news>\n+v0.15.3 (2019-09-19)\n+-Initial conversion to python 3\n+-Initial integration tests\n+-Implemented device uuid to avoid always asking credentials\n+-Fixed a problem when library source is special:// or a direct path\n+-Fixed run library update on slow system like RPI\n+-Updated dutch language\n+-Minor fixes\n+\nv0.15.2 (2019-08-30)\n-Fixed key handshake at addon first run\n-Fixed library update service at first run\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Version bump (0.15.3)
106,046
21.09.2019 10:31:28
-7,200
68a79d73675a595ecf0e0017589711524264daea
Fixed skipping sections Netflix has changed the key to skipMarkers this commit also fix the error: Unknown format code 'd' for object of type 'float' in some cases the return value was float, removed superfluous time conversion
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/xmldialogs.py", "new_path": "resources/lib/kodi/ui/xmldialogs.py", "diff": "@@ -15,7 +15,7 @@ ACTION_NOOP = 999\nOS_MACHINE = machine()\n-CMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{:02d}:{:02d},silent)'\n+CMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{:02d},silent)'\ndef show_modal_dialog(dlg_class, xml, path, **kwargs):\n@@ -25,10 +25,9 @@ def show_modal_dialog(dlg_class, xml, path, **kwargs):\nclose after the specified time.\n\"\"\"\ndlg = dlg_class(xml, path, 'default', '1080i', **kwargs)\n- minutes = kwargs.get('minutes', 0)\nseconds = kwargs.get('seconds', 0)\n- if minutes > 0 or seconds > 0:\n- xbmc.executebuiltin(CMD_CLOSE_DIALOG_BY_NOOP.format(minutes, seconds))\n+ if seconds > 0:\n+ xbmc.executebuiltin(CMD_CLOSE_DIALOG_BY_NOOP.format(seconds))\ndlg.doModal()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/markers.py", "new_path": "resources/lib/services/playback/markers.py", "diff": "@@ -34,15 +34,15 @@ def get_offset_markers(metadata):\ndef get_section_markers(metadata):\n\"\"\"Extract section start and end markers from metadata if they exist\"\"\"\n- if not metadata.get('creditMarkers'):\n+ if not metadata.get('skipMarkers'):\nreturn {}\nreturn {\nsection: {\n- 'start': int(metadata['creditMarkers'][section]['start'] /\n+ 'start': int(metadata['skipMarkers'][section]['start'] /\n1000),\n- 'end': int(metadata['creditMarkers'][section]['end'] / 1000)\n+ 'end': int(metadata['skipMarkers'][section]['end'] / 1000)\n}\nfor section in SKIPPABLE_SECTIONS\n- if any(i for i in metadata['creditMarkers'][section].values())\n+ if any(i for i in metadata['skipMarkers'][section].values())\n}\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/section_skipping.py", "new_path": "resources/lib/services/playback/section_skipping.py", "diff": "@@ -69,11 +69,9 @@ class SectionSkipper(PlaybackActionManager):\ndialog_duration = (self.markers[section]['end'] -\nself.markers[section]['start'])\nseconds = dialog_duration % 60\n- minutes = (dialog_duration - seconds) / 60\nui.show_modal_dialog(ui.xmldialogs.Skip,\n\"plugin-video-netflix-Skip.xml\",\ng.ADDON.getAddonInfo('path'),\n- minutes=minutes,\nseconds=seconds,\nskip_to=self.markers[section]['end'],\nlabel=common.get_local_string(\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed skipping sections Netflix has changed the key to skipMarkers this commit also fix the error: Unknown format code 'd' for object of type 'float' in some cases the return value was float, removed superfluous time conversion
106,046
22.09.2019 11:42:31
-7,200
9815339fecf717ee823d371c76d74e8db2a2dd7c
Fixed skipping dialog duration time
[ { "change_type": "MODIFY", "old_path": "resources/lib/kodi/ui/xmldialogs.py", "new_path": "resources/lib/kodi/ui/xmldialogs.py", "diff": "\"\"\"XML based dialogs\"\"\"\nfrom __future__ import absolute_import, division, unicode_literals\n+import time\nfrom platform import machine\nimport xbmc\n@@ -15,7 +16,7 @@ ACTION_NOOP = 999\nOS_MACHINE = machine()\n-CMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{:02d},silent)'\n+CMD_CLOSE_DIALOG_BY_NOOP = 'AlarmClock(closedialog,Action(noop),{},silent)'\ndef show_modal_dialog(dlg_class, xml, path, **kwargs):\n@@ -25,9 +26,16 @@ def show_modal_dialog(dlg_class, xml, path, **kwargs):\nclose after the specified time.\n\"\"\"\ndlg = dlg_class(xml, path, 'default', '1080i', **kwargs)\n+ minutes = kwargs.get('minutes', 0)\nseconds = kwargs.get('seconds', 0)\n- if seconds > 0:\n- xbmc.executebuiltin(CMD_CLOSE_DIALOG_BY_NOOP.format(seconds))\n+ if minutes > 0 or seconds > 0:\n+ # Bug in Kodi AlarmClock function, if only the seconds are passed\n+ # the time conversion inside the function multiply the seconds by 60\n+ if seconds > 59 and minutes == 0:\n+ alarm_time = time.strftime('%M:%S', time.gmtime(seconds))\n+ else:\n+ alarm_time = '{:02d}:{:02d}'.format(minutes, seconds)\n+ xbmc.executebuiltin(CMD_CLOSE_DIALOG_BY_NOOP.format(alarm_time))\ndlg.doModal()\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/playback/section_skipping.py", "new_path": "resources/lib/services/playback/section_skipping.py", "diff": "@@ -68,11 +68,10 @@ class SectionSkipper(PlaybackActionManager):\ncommon.debug('Asking to skip {}'.format(section))\ndialog_duration = (self.markers[section]['end'] -\nself.markers[section]['start'])\n- seconds = dialog_duration % 60\nui.show_modal_dialog(ui.xmldialogs.Skip,\n\"plugin-video-netflix-Skip.xml\",\ng.ADDON.getAddonInfo('path'),\n- seconds=seconds,\n+ seconds=dialog_duration,\nskip_to=self.markers[section]['end'],\nlabel=common.get_local_string(\nSKIPPABLE_SECTIONS[section]))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Fixed skipping dialog duration time
106,046
28.09.2019 07:26:24
-7,200
d0bc8cc26375fa3c95caa988ec37f2db8f376085
Clear cache on addon upgrade
[ { "change_type": "MODIFY", "old_path": "resources/lib/upgrade_controller.py", "new_path": "resources/lib/upgrade_controller.py", "diff": "@@ -37,6 +37,8 @@ def _perform_addon_changes(previous_ver, current_ver):\n\"\"\"Perform actions for an version bump\"\"\"\ncommon.debug('Initialize addon upgrade operations, from version {} to {})'\n.format(previous_ver, current_ver))\n+ # Clear cache (prevents problems when netflix change data structures)\n+ g.CACHE.invalidate(True)\n# Always leave this to last - After the operations set current version\ng.LOCAL_DB.set_value('addon_previous_version', current_ver)\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Clear cache on addon upgrade
106,046
29.09.2019 15:30:09
-7,200
36d55311a993e77d14797574d463fb692e57bdc8
Added manifests cache bucket
[ { "change_type": "MODIFY", "old_path": "resources/lib/cache.py", "new_path": "resources/lib/cache.py", "diff": "@@ -29,9 +29,10 @@ CACHE_SUPPLEMENTAL = 'cache_supplemental'\nCACHE_METADATA = 'cache_metadata'\nCACHE_INFOLABELS = 'cache_infolabels'\nCACHE_ARTINFO = 'cache_artinfo'\n+CACHE_MANIFESTS = 'cache_manifests'\nBUCKET_NAMES = [CACHE_COMMON, CACHE_GENRES, CACHE_SUPPLEMENTAL, CACHE_METADATA,\n- CACHE_INFOLABELS, CACHE_ARTINFO]\n+ CACHE_INFOLABELS, CACHE_ARTINFO, CACHE_MANIFESTS]\nBUCKET_LOCKED = 'LOCKED_BY_{:04d}_AT_{}'\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added manifests cache bucket
106,046
29.09.2019 15:31:04
-7,200
02652f81716cc12fbf168333704e1a3f2f222d5a
Allow to exclude fallback to disk cache on key missing
[ { "change_type": "MODIFY", "old_path": "resources/lib/cache.py", "new_path": "resources/lib/cache.py", "diff": "@@ -155,14 +155,15 @@ class Cache(object):\ntimestamp = int(time())\nreturn str(BUCKET_LOCKED.format(self.plugin_handle, timestamp))\n- def get(self, bucket, identifier):\n+ def get(self, bucket, identifier, use_disk_fallback=True):\n\"\"\"Retrieve an item from a cache bucket\"\"\"\ntry:\ncache_entry = self._get_bucket(bucket)[identifier]\nexcept KeyError:\n+ if not use_disk_fallback:\n+ raise CacheMiss()\ncache_entry = self._get_from_disk(bucket, identifier)\nself.add(bucket, identifier, cache_entry['content'])\n- # Do not verify TTL on cache library, prevents the loss of exported objects\nself.verify_ttl(bucket, identifier, cache_entry)\nreturn cache_entry['content']\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Allow to exclude fallback to disk cache on key missing
106,046
29.09.2019 15:32:22
-7,200
df7832fca31e2eafb69c409387f83eb94e5139c1
Added custom eol argument
[ { "change_type": "MODIFY", "old_path": "resources/lib/cache.py", "new_path": "resources/lib/cache.py", "diff": "@@ -167,9 +167,10 @@ class Cache(object):\nself.verify_ttl(bucket, identifier, cache_entry)\nreturn cache_entry['content']\n- def add(self, bucket, identifier, content, ttl=None, to_disk=False):\n+ def add(self, bucket, identifier, content, ttl=None, to_disk=False, eol=None):\n\"\"\"Add an item to a cache bucket\"\"\"\n# pylint: disable=too-many-arguments\n+ if not eol:\neol = int(time() + (ttl if ttl else self.ttl))\n# self.common.debug('Adding {} to {} (valid until {})'\n# .format(identifier, bucket, eol))\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added custom eol argument
106,046
29.09.2019 15:35:22
-7,200
6d21a43a07666621ab1cd8786bfcfc1f4973cae1
Saving the requested manifests to the cache
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/msl/msl_handler.py", "new_path": "resources/lib/services/msl/msl_handler.py", "diff": "@@ -18,12 +18,18 @@ import xbmcaddon\nfrom resources.lib.globals import g\nimport resources.lib.common as common\nimport resources.lib.kodi.ui as ui\n+import resources.lib.cache as cache\nfrom .request_builder import MSLRequestBuilder\nfrom .profiles import enabled_profiles\nfrom .converter import convert_to_dash\nfrom .exceptions import MSLError\n+try: # Python 2\n+ unicode\n+except NameError: # Python 3\n+ unicode = str # pylint: disable=redefined-builtin\n+\nCHROME_BASE_URL = 'https://www.netflix.com/nq/msl_v1/cadmium/'\nENDPOINTS = {\n'manifest': CHROME_BASE_URL + 'pbo_manifests/%5E1.0.0/router', # \"pbo_manifests/^1.0.0/router\"\n@@ -132,6 +138,17 @@ class MSLHandler(object):\[email protected]_execution(immediate=True)\ndef _load_manifest(self, viewable_id, esn):\n+ cache_identifier = esn + '_' + unicode(viewable_id)\n+ try:\n+ # The manifest must be requested once and maintained for its entire duration\n+ manifest = g.CACHE.get(cache.CACHE_MANIFESTS, cache_identifier, False)\n+ common.debug('Manifest for {} with ESN {} obtained from the cache'\n+ .format(viewable_id, esn))\n+ # Save the manifest to disk as reference\n+ common.save_file('manifest.json', json.dumps(manifest))\n+ return manifest\n+ except cache.CacheMiss:\n+ pass\ncommon.debug('Requesting manifest for {} with ESN {}'\n.format(viewable_id, esn))\nprofiles = enabled_profiles()\n@@ -197,7 +214,11 @@ class MSLHandler(object):\nmanifest = self._chunked_request(ENDPOINTS['manifest'],\nmanifest_request_data, esn)\n+ # Save the manifest to disk as reference\ncommon.save_file('manifest.json', json.dumps(manifest))\n+ # Save the manifest to the cache to retrieve it during its validity\n+ expiration = int(manifest['expiration'] / 1000)\n+ g.CACHE.add(cache.CACHE_MANIFESTS, cache_identifier, manifest, eol=expiration)\nif 'result' in manifest:\nreturn manifest['result']\nreturn manifest\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Saving the requested manifests to the cache
106,046
29.09.2019 18:22:16
-7,200
83a25da9ffb9af4f271138952a36ac152a6079b3
Purge cache when a content profile setting is changed
[ { "change_type": "MODIFY", "old_path": "resources/lib/services/settings_monitor.py", "new_path": "resources/lib/services/settings_monitor.py", "diff": "@@ -11,6 +11,11 @@ import resources.lib.kodi.ui as ui\nfrom resources.lib.database.db_utils import (TABLE_SETTINGS_MONITOR)\nfrom resources.lib.globals import g\n+try: # Python 2\n+ unicode\n+except NameError: # Python 3\n+ unicode = str # pylint: disable=redefined-builtin\n+\nclass SettingsMonitor(xbmc.Monitor):\ndef __init__(self):\n@@ -23,6 +28,7 @@ class SettingsMonitor(xbmc.Monitor):\ndef _on_change(self):\ncommon.debug('SettingsMonitor: settings have been changed, started checks')\nreboot_addon = False\n+ clean_cache = False\nuse_mysql = g.ADDON.getSettingBool('use_mysql')\nuse_mysql_old = g.LOCAL_DB.get_value('use_mysql', False, TABLE_SETTINGS_MONITOR)\n@@ -47,7 +53,6 @@ class SettingsMonitor(xbmc.Monitor):\ncommon.send_signal(signal=common.Signals.ESN_CHANGED, data=g.get_esn())\n# Check menu settings changes\n- sort_order_type_changed = False\nfor menu_id, menu_data in g.MAIN_MENU_ITEMS.iteritems():\n# Check settings changes in show menu\nshow_menu_new_setting = bool(g.ADDON.getSettingBool('_'.join(('show_menu', menu_id))))\n@@ -71,10 +76,24 @@ class SettingsMonitor(xbmc.Monitor):\ng.LOCAL_DB.set_value('menu_{}_sortorder'.format(menu_id),\nmenu_sortorder_new_setting,\nTABLE_SETTINGS_MONITOR)\n- sort_order_type_changed = True\n-\n- if sort_order_type_changed:\n# We remove the cache to allow get the new results in the chosen order\n+ clean_cache = True\n+\n+ # Check changes on content profiles\n+ # This is necessary because it is possible that some manifests\n+ # could be cached using the previous settings (see msl_handler - load_manifest)\n+ menu_keys = ['enable_dolby_sound', 'enable_vp9_profiles', 'enable_hevc_profiles',\n+ 'enable_hdr_profiles', 'enable_dolbyvision_profiles', 'enable_force_hdcp',\n+ 'disable_webvtt_subtitle']\n+ collect_int = ''\n+ for menu_key in menu_keys:\n+ collect_int += unicode(int(g.ADDON.getSettingBool(menu_key)))\n+ collect_int_old = g.LOCAL_DB.get_value('content_profiles_int', '', TABLE_SETTINGS_MONITOR)\n+ if collect_int != collect_int_old:\n+ g.LOCAL_DB.set_value('content_profiles_int', collect_int, TABLE_SETTINGS_MONITOR)\n+ clean_cache = True\n+\n+ if clean_cache:\ncommon.run_plugin('plugin://plugin.video.netflix/action/purge_cache/'\n'?on_disk=True&no_notification=True')\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "</category>\n<category label=\"30023\"><!--Expert-->\n<setting label=\"30115\" type=\"lsep\"/>\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" } ]
Python
MIT License
castagnait/plugin.video.netflix
Purge cache when a content profile setting is changed
106,046
07.10.2019 17:03:57
-7,200
ffe2a652b2510452167cad52e2b9141e67180460
Do not limit obtaining data from my-list this should fix the problem of add/remove to my-list when there are over 92 elements
[ { "change_type": "MODIFY", "old_path": "resources/lib/api/shakti.py", "new_path": "resources/lib/api/shakti.py", "diff": "@@ -256,7 +256,8 @@ def custom_video_list_basicinfo(list_id):\ncallargs = {\n'paths': paths,\n'length_params': ['stdlist', ['lists', list_id]],\n- 'perpetual_range_start': None\n+ 'perpetual_range_start': None,\n+ 'no_limit_req': True\n}\n# When the list is empty the server returns an empty response\npath_response = common.make_call('perpetual_path_request', callargs)\n" }, { "change_type": "MODIFY", "old_path": "resources/lib/services/nfsession/nfsession.py", "new_path": "resources/lib/services/nfsession/nfsession.py", "diff": "@@ -250,7 +250,8 @@ class NetflixSession(object):\[email protected]_return_call\n@needs_login\[email protected]_execution(immediate=True)\n- def perpetual_path_request(self, paths, length_params, perpetual_range_start=None):\n+ def perpetual_path_request(self, paths, length_params, perpetual_range_start=None,\n+ no_limit_req=False):\n\"\"\"Perform a perpetual path request against the Shakti API to retrieve\na possibly large video list. If the requested video list's size is\nlarger than MAX_PATH_REQUEST_SIZE, multiple path requests will be\n@@ -268,7 +269,7 @@ class NetflixSession(object):\nif context_name == 'genres':\nresponse_size += 1\n- number_of_requests = 2\n+ number_of_requests = 100 if no_limit_req else 2\nperpetual_range_start = int(perpetual_range_start) if perpetual_range_start else 0\nrange_start = perpetual_range_start\nrange_end = range_start + request_size\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Do not limit obtaining data from my-list this should fix the problem of add/remove to my-list when there are over 92 elements
105,993
07.10.2019 17:49:41
-7,200
85b58429cdc196d69bed5d68f6fec6a792240c72
Added InputStream Helper settings to settings menu
[ { "change_type": "MODIFY", "old_path": "resources/language/resource.language.en_gb/strings.po", "new_path": "resources/language/resource.language.en_gb/strings.po", "diff": "@@ -157,7 +157,7 @@ msgid \"ESN (set automatically, can be changed manually)\"\nmsgstr \"\"\nmsgctxt \"#30035\"\n-msgid \"Inputstream Addon Settings...\"\n+msgid \"InputStream Adaptive settings...\"\nmsgstr \"\"\nmsgctxt \"#30036\"\n@@ -645,7 +645,7 @@ msgid \"Does your device support the 4K standard?\\r\\nThe device must:\\r\\nBe Netfl\nmsgstr \"\"\nmsgctxt \"#30157\"\n-msgid \"The InputStream settings panel will now be opened, so you have to change this option \\\"Override HDCP status\\\" to ON\"\n+msgid \"The InputStream Adaptive settings panel will now be opened, so you have to change this option \\\"Override HDCP status\\\" to ON\"\nmsgstr \"\"\nmsgctxt \"#30158\"\n@@ -867,3 +867,7 @@ msgstr \"\"\nmsgctxt \"#30212\"\nmsgid \"There is no device that handles the auto-updates of shared-library\"\nmsgstr \"\"\n+\n+msgctxt \"#30213\"\n+msgid \"InputStream Helper settings...\"\n+msgstr \"\"\n" }, { "change_type": "MODIFY", "old_path": "resources/settings.xml", "new_path": "resources/settings.xml", "diff": "<setting id=\"autologin_id\" type=\"text\" label=\"30056\" default=\"\" enable=\"false\" visible=\"eq(-2,true)\" subsetting=\"true\"/>\n<setting type=\"sep\"/>\n<setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"Addon.OpenSettings(inputstream.adaptive)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n+ <setting id=\"ishelper_settings\" type=\"action\" label=\"30213\" action=\"Addon.OpenSettings(script.module.inputstreamhelper)\" option=\"close\"/>\n</category>\n<category label=\"30025\"><!--Library-->\n<setting id=\"enablelibraryfolder\" type=\"bool\" label=\"30026\" default=\"false\"/>\n" } ]
Python
MIT License
castagnait/plugin.video.netflix
Added InputStream Helper settings to settings menu Co-authored-by: Stefano Gottardo <[email protected]>