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
|
---|---|---|---|---|---|---|---|---|---|
105,979 | 13.10.2017 18:21:51 | -7,200 | b8c25c767f4076b6274a5882a99d70282695dfd3 | fix(profiles): Fixes unicode error | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -600,8 +600,8 @@ class KodiHelper:\n\"\"\"\nfor profile in profiles:\nurl = build_url({'action': action, 'profile_id': profile['id']})\n- url_save_autologin = build_url({'action': 'save_autologin', 'autologin_id': profile['id'], 'autologin_user': profile['profileName']})\n- li = xbmcgui.ListItem(label=profile['profileName'], iconImage=profile['avatar'])\n+ url_save_autologin = build_url({'action': 'save_autologin', 'autologin_id': profile['id'], 'autologin_user': profile['profileName'].encode('utf-8')})\n+ li = xbmcgui.ListItem(label=profile['profileName'].encode('utf-8'), iconImage=profile['avatar'])\nli.setProperty('fanart_image', self.default_fanart)\nli.addContextMenuItems([(self.get_local_string(30053), 'RunPlugin('+url_save_autologin+')',)])\nxbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=li, isFolder=True)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(profiles): Fixes unicode error |
105,979 | 14.10.2017 18:21:30 | -7,200 | d384d338c6753a0b7a77053beaaa62c5459991bd | chore(perf): Avoids redundant login check request at each call | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -25,6 +25,12 @@ try:\nimport cPickle as pickle\nexcept:\nimport pickle\n+try:\n+ # Python 2.6-2.7\n+ from HTMLParser import HTMLParser\n+except ImportError:\n+ # Python 3\n+ from html.parser import HTMLParser\nVIEW_FOLDER = 'folder'\nVIEW_MOVIE = 'movie'\n@@ -578,34 +584,56 @@ class KodiHelper:\nxbmc.executebuiltin('Container.Refresh')\ndef build_profiles_listing(self, profiles, action, build_url):\n- \"\"\"Builds the profiles list Kodi screen\n-\n- Parameters\n- ----------\n- profiles : :obj:`list` of :obj:`dict` of :obj:`str`\n- List of user profiles\n-\n- action : :obj:`str`\n- Action paramter to build the subsequent routes\n-\n- build_url : :obj:`fn`\n- Function to build the subsequent routes\n+ \"\"\"\n+ Builds the profiles list Kodi screen\n- Returns\n- -------\n- bool\n- List could be build\n+ :param profiles: list of user profiles\n+ :type profiles: list\n+ :param action: action paramter to build the subsequent routes\n+ :type action: str\n+ :param build_url: function to build the subsequent routes\n+ :type build_url: fn\n+ :returns: bool -- List could be build\n\"\"\"\n+ # init html parser for entity decoding\n+ html_parser = HTMLParser()\n+ # build menu items for every profile\nfor profile in profiles:\n- url = build_url({'action': action, 'profile_id': profile['guid']})\n- url_save_autologin = build_url({'action': 'save_autologin', 'autologin_id': profile['guid'], 'autologin_user': profile['profileName'].encode('utf-8')})\n- li = xbmcgui.ListItem(label=profile['profileName'].encode('utf-8'), iconImage=profile['avatar'])\n- li.setProperty('fanart_image', self.default_fanart)\n- li.addContextMenuItems([(self.get_local_string(30053), 'RunPlugin('+url_save_autologin+')',)])\n- xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=li, isFolder=True)\n- xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL)\n- xbmcplugin.endOfDirectory(self.plugin_handle)\n- return True\n+ # load & encode profile data\n+ enc_profile_name = profile.get('profileName', '').encode('utf-8')\n+ unescaped_profile_name = html_parser.unescape(enc_profile_name)\n+ profile_guid = profile.get('guid')\n+\n+ # build urls\n+ url = build_url({'action': action, 'profile_id': profile_guid})\n+ autologin_url = build_url({\n+ 'action': 'save_autologin',\n+ 'autologin_id': profile_guid,\n+ 'autologin_user': enc_profile_name})\n+\n+ # add list item\n+ list_item = xbmcgui.ListItem(\n+ label=unescaped_profile_name,\n+ iconImage=profile.get('avatar'))\n+ list_item.setProperty(\n+ key='fanart_image',\n+ value=self.default_fanart)\n+ # add context menu options\n+ auto_login = (\n+ self.get_local_string(30053),\n+ 'RunPlugin(' + autologin_url + ')')\n+ list_item.addContextMenuItems(items=[auto_login])\n+\n+ # add directory & sorting options\n+ xbmcplugin.addDirectoryItem(\n+ handle=self.plugin_handle,\n+ url=url,\n+ listitem=list_item,\n+ isFolder=True)\n+ xbmcplugin.addSortMethod(\n+ handle=self.plugin_handle,\n+ sortMethod=xbmcplugin.SORT_METHOD_LABEL)\n+ return xbmcplugin.endOfDirectory(handle=self.plugin_handle)\ndef build_main_menu_listing (self, video_list_ids, user_list_order, actions, build_url):\n\"\"\"Builds the video lists (my list, continue watching, etc.) Kodi screen\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -214,9 +214,25 @@ class NetflixSession:\n\"\"\"\n# load cookies\naccount_hash = self._generate_account_hash(account=account)\n- if self._load_cookies(filename=self.cookie_path + '_' + account_hash) == False:\n+ cookies = self._load_cookies(\n+ filename=self.cookie_path + '_' + account_hash)\n+ if cookies == False:\nreturn False\n+ # find the earliest expiration date in the cookies\n+ expires = 99999999999999999999\n+ cur_stamp = int(time())\n+ for domains in cookies:\n+ for domain in cookies[domains].keys():\n+ for cookie_key in cookies[domains][domain]:\n+ exp = int(cookies[domains][domain][cookie_key].expires)\n+ if expires > exp:\n+ expires = exp\n+ if expires > cur_stamp:\n+ self.log(\n+ msg='Cookie expires: ' + str(expires) + ' / ' + str(cur_stamp))\n+ return True\n+\n# load the profiles page (to verify the user)\nresponse = self._session_get(component='profiles')\nif response:\n@@ -1826,6 +1842,7 @@ class NetflixSession:\njar = cookies.RequestsCookieJar()\njar._cookies = _cookies\nself.session.cookies = jar\n+ return _cookies\nelse:\nreturn False\n@@ -1985,8 +2002,6 @@ class NetflixSession:\nDirectly assigns it to the NetflixSession instance\n\"\"\"\nuser_data, profiles = self.extract_inline_netflix_page_data(content=content)\n- self.log(user_data)\n- self.log(profiles)\nif user_data is None:\nreturn None\nself.user_data = user_data\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | chore(perf): Avoids redundant login check request at each call |
105,979 | 14.10.2017 20:32:30 | -7,200 | 58677be9d1867313f185e99b1e1b11104c6d0389 | chore(performance): Load cookies from memory if available | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpRequestHandler.py",
"new_path": "resources/lib/NetflixHttpRequestHandler.py",
"diff": "# Module: NetflixHttpRequestHandler\n# Created on: 07.03.2017\n-import BaseHTTPServer\nimport json\n+import BaseHTTPServer\nfrom types import FunctionType\nfrom urlparse import urlparse, parse_qs\nfrom resources.lib.KodiHelper import KodiHelper\n@@ -28,7 +28,10 @@ class NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n\"\"\" Represents the callable internal server that dispatches requests to Netflix\"\"\"\ndef do_GET(self):\n- \"\"\"GET request handler (we only need this, as we only do GET requests internally)\"\"\"\n+ \"\"\"\n+ GET request handler\n+ (we only need this, as we only do GET requests internally)\n+ \"\"\"\nurl = urlparse(self.path)\nparams = parse_qs(url.query)\nmethod = params.get('method', [None])[0]\n@@ -40,16 +43,17 @@ class NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n# no existing method given\nif method not in methods:\n- self.send_error(404, 'Method \"' + str(method) + '\" not found. Available methods: ' + str(methods))\n- return\n+ return self.send_error(404, 'Method \"' + str(method) + '\" not found. Available methods: ' + str(methods))\n# call method & get the result\nresult = getattr(sub_res_handler, method)(params)\nself.send_response(200)\nself.send_header('Content-type', 'application/json')\nself.end_headers()\n- self.wfile.write(json.dumps({'method': method, 'result': result}));\n- return\n+ return self.wfile.write(json.dumps({\n+ 'method': method,\n+ 'result': result}))\n+\ndef log_message(self, format, *args):\n\"\"\"Disable the BaseHTTPServer Log\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -114,6 +114,8 @@ class NetflixSession:\nself.data_path = data_path\nself.verify_ssl = verify_ssl\nself.log = log_fn\n+ self.parsed_cookies = {}\n+ self.parsed_user_data = {}\nself._init_session()\ndef extract_inline_netflix_page_data(self, content='', items=None):\n@@ -222,10 +224,10 @@ class NetflixSession:\n# find the earliest expiration date in the cookies\nexpires = 99999999999999999999\ncur_stamp = int(time())\n- for domains in cookies:\n- for domain in cookies[domains].keys():\n- for cookie_key in cookies[domains][domain]:\n- exp = int(cookies[domains][domain][cookie_key].expires)\n+ for domains in cookies[0]:\n+ for domain in cookies[0][domains].keys():\n+ for cookie_key in cookies[0][domains][domain]:\n+ exp = int(cookies[0][domains][domain][cookie_key].expires)\nif expires > exp:\nexpires = exp\nif expires > cur_stamp:\n@@ -237,7 +239,8 @@ class NetflixSession:\nresponse = self._session_get(component='profiles')\nif response:\n# parse out the needed inline information\n- user_data, profiles = self.extract_inline_netflix_page_data(content=response.text)\n+ user_data, profiles = self.extract_inline_netflix_page_data(\n+ content=response.text)\nself.profiles = profiles\n# if we have profiles, cookie is still valid\nif self.profiles:\n@@ -284,7 +287,9 @@ class NetflixSession:\n}\n# perform the login\n- login_response = self._session_post(component='login', data=login_payload)\n+ login_response = self._session_post(\n+ component='login',\n+ data=login_payload)\nuser_data = self._parse_page_contents(content=login_response.text)\naccount_hash = self._generate_account_hash(account=account)\n# we know that the login was successfull if we find ???\n@@ -319,7 +324,10 @@ class NetflixSession:\n'authURL': self.user_data['authURL']\n}\n- response = self._session_get(component='switch_profiles', type='api', params=payload)\n+ response = self._session_get(\n+ component='switch_profiles',\n+ type='api',\n+ params=payload)\nif (response == None or response.status_code != 200):\nreturn False\n@@ -349,8 +357,13 @@ class NetflixSession:\n'pin': pin,\n'authURL': self.user_data.get('authURL', '')\n}\n- response = self._session_post(component='adult_pin', type='api', data=payload)\n- pin_response = self._process_response(response=response, component=self._get_api_url_for(component='adult_pin'))\n+ response = self._session_post(\n+ component='adult_pin',\n+ type='api',\n+ data=payload)\n+ pin_response = self._process_response(\n+ response=response,\n+ component=self._get_api_url_for(component='adult_pin'))\nif 'error' in pin_response.keys():\nself.log(msg='Pin error')\nself.log(msg=str(pin_response))\n@@ -1802,59 +1815,63 @@ class NetflixSession:\nos.remove(os.path.join(subdir, file))\ndef _save_cookies(self, filename):\n- \"\"\"Tiny helper that stores cookies from the session in a given file\n-\n- Parameters\n- ----------\n- filename : :obj:`str`\n- Complete path incl. filename that determines where to store the cookie\n+ \"\"\"\n+ Stores cookies from the session in a file & mememory\n- Returns\n- -------\n- bool\n- Storage procedure was successfull\n+ :param filename: path incl. filename of the cookie file\n+ :type filename: str\n+ :returns: bool -- Storing procedure successfull\n\"\"\"\nif not os.path.isdir(os.path.dirname(filename)):\nreturn False\n- with open(filename, 'w') as f:\n- f.truncate()\n- pickle.dump(self.session.cookies._cookies, f)\n+ with open(filename, 'w') as file_handle:\n+ _cookies = self.session.cookies._cookies\n+ jar = self.session.cookies\n+ file_handle.truncate()\n+ pickle.dump(_cookies, file_handle)\n+ self.parsed_cookies[filename] = (_cookies, jar)\ndef _load_cookies(self, filename):\n- \"\"\"Tiny helper that loads cookies into the active session from a given file\n-\n- Parameters\n- ----------\n- filename : :obj:`str`\n- Complete path incl. filename that determines where to load the cookie from\n+ \"\"\"\n+ Loads cookies into the active session from a given file\n- Returns\n- -------\n- bool\n- Load procedure was successfull\n+ :param filename: path incl. filename of the cookie file\n+ :type filename: str\n+ :returns: bool or tuple -- Loading didn't work or parsed cookie data\n\"\"\"\n+ # check if we have in memory cookies to spare some file i/o\n+ current_cookie = self.parsed_cookies.get(filename, None)\n+ if current_cookie is not None:\n+ self.log(msg='Loading cookies from memory')\n+ self.session.cookies = current_cookie[1]\n+ return current_cookie\n+\n+ # return if we haven't found a cookie file\nif not os.path.isfile(filename):\n+ self.log(msg='No cookies found')\nreturn False\n+ # open the cookies file & set the loaded cookies\nwith open(filename) as f:\n+ self.log(msg='Loading cookies from file')\n_cookies = pickle.load(f)\nif _cookies:\njar = cookies.RequestsCookieJar()\njar._cookies = _cookies\nself.session.cookies = jar\n- return _cookies\n+ self.parsed_cookies[filename] = (_cookies, jar)\n+ return self.parsed_cookies.get(filename)\nelse:\nreturn False\ndef _delete_cookies(self, path):\n- \"\"\"Tiny helper that deletes cookie data\n-\n- Parameters\n- ----------\n- filename : :obj:`str`\n- Complete path incl. filename that determines where to delete the files\n+ \"\"\"\n+ Deletes cookie data\n+ :param path: path + filename for the cookie file\n+ :type path: string\n\"\"\"\n+ self.parsed_cookies[path] = None\nhead, tail = os.path.split(path)\nfor subdir, dirs, files in os.walk(head):\nfor file in files:\n@@ -1863,19 +1880,14 @@ class NetflixSession:\nself._init_session()\ndef _generate_account_hash(self, account):\n- \"\"\"Generates a has for the given account (used for cookie verification)\n-\n- Parameters\n- ----------\n- account : :obj:`dict` of :obj:`str`\n- Dict containing an email, country & a password property\n+ \"\"\"\n+ Generates a has for the given account (used for cookie/ud verification)\n- Returns\n- -------\n- :obj:`str`\n- Account data hash\n+ :param account: email & password\n+ :type account: dict\n+ :returns: str -- Account data hash\n\"\"\"\n- return urlsafe_b64encode(account['email'])\n+ return urlsafe_b64encode(account.get('email', 'NoMail'))\ndef _session_post(self, component, type='document', data={}, headers={}, params={}):\n\"\"\"Executes a get request using requests for the current session & measures the duration of that request\n@@ -1974,17 +1986,17 @@ class NetflixSession:\n# we generate an esn from device strings for android\nimport subprocess\ntry:\n- manufacturer = subprocess.check_output([\"/system/bin/getprop\", \"ro.product.manufacturer\"])\n+ manufacturer = subprocess.check_output(['/system/bin/getprop', 'ro.product.manufacturer'])\nif manufacturer:\nesn = 'NFANDROID1-PRV-'\n- input = subprocess.check_output([\"/system/bin/getprop\", \"ro.nrdp.modelgroup\"])\n+ input = subprocess.check_output(['/system/bin/getprop', 'ro.nrdp.modelgroup'])\nif not input:\n- esn = esn + 'T-L3-'\n+ esn += 'T-L3-'\nelse:\n- esn = esn + input.strip(' \\t\\n\\r') + '-'\n- esn = esn + '{:5}'.format(manufacturer.strip(' \\t\\n\\r').upper())\n- input = subprocess.check_output([\"/system/bin/getprop\" ,\"ro.product.model\"])\n- esn = esn + input.strip(' \\t\\n\\r').replace(' ', '=').upper()\n+ esn += input.strip(' \\t\\n\\r') + '-'\n+ esn += '{:5}'.format(manufacturer.strip(' \\t\\n\\r').upper())\n+ input = subprocess.check_output(['/system/bin/getprop' ,'ro.product.model'])\n+ esn += input.strip(' \\t\\n\\r').replace(' ', '=').upper()\nself.log(msg='Android generated ESN:' + esn)\nreturn esn\nexcept OSError as e:\n@@ -2001,7 +2013,8 @@ class NetflixSession:\nthe session relevant data from the HTML page\nDirectly assigns it to the NetflixSession instance\n\"\"\"\n- user_data, profiles = self.extract_inline_netflix_page_data(content=content)\n+ user_data, profiles = self.extract_inline_netflix_page_data(\n+ content=content)\nif user_data is None:\nreturn None\nself.user_data = user_data\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | chore(performance): Load cookies from memory if available |
105,979 | 15.10.2017 11:54:54 | -7,200 | 16436f82e83411ababac838301401bc3fd143101 | refactor(NetflixHttpRequestHandler): Tiny improvements | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSLHttpRequestHandler.py",
"new_path": "resources/lib/MSLHttpRequestHandler.py",
"diff": "# Module: MSLHttpRequestHandler\n# Created on: 26.01.2017\n-import BaseHTTPServer\nimport base64\n+import BaseHTTPServer\nfrom urlparse import urlparse, parse_qs\nfrom MSL import MSL\nfrom KodiHelper import KodiHelper\nkodi_helper = KodiHelper()\n-\nmsl = MSL(kodi_helper)\n+\nclass MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\ndef do_HEAD(self):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpRequestHandler.py",
"new_path": "resources/lib/NetflixHttpRequestHandler.py",
"diff": "# Module: NetflixHttpRequestHandler\n# Created on: 07.03.2017\n+\"\"\"Oppionionated internal proxy that dispatches requests to Netflix\"\"\"\n+\nimport json\nimport BaseHTTPServer\nfrom types import FunctionType\nfrom urlparse import urlparse, parse_qs\n+from utils import get_class_methods\nfrom resources.lib.KodiHelper import KodiHelper\nfrom resources.lib.NetflixSession import NetflixSession\nfrom resources.lib.NetflixHttpSubRessourceHandler import NetflixHttpSubRessourceHandler\n-kodi_helper = KodiHelper()\n-\n-netflix_session = NetflixSession(\n- cookie_path=kodi_helper.cookie_path,\n- data_path=kodi_helper.data_path,\n- verify_ssl=kodi_helper.get_ssl_verification_setting(),\n- log_fn=kodi_helper.log\n+KODI_HELPER = KodiHelper()\n+NETFLIX_SESSION = NetflixSession(\n+ cookie_path=KODI_HELPER.cookie_path,\n+ data_path=KODI_HELPER.data_path,\n+ verify_ssl=KODI_HELPER.get_ssl_verification_setting(),\n+ log_fn=KODI_HELPER.log\n)\n# get list of methods & instance form the sub ressource handler\n-methods = [x for x, y in NetflixHttpSubRessourceHandler.__dict__.items() if type(y) == FunctionType]\n-sub_res_handler = NetflixHttpSubRessourceHandler(kodi_helper=kodi_helper, netflix_session=netflix_session)\n+METHODS = get_class_methods(class_item=NetflixHttpSubRessourceHandler)\n+RES_HANDLER = NetflixHttpSubRessourceHandler(\n+ kodi_helper=KODI_HELPER,\n+ netflix_session=NETFLIX_SESSION)\nclass NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n- \"\"\" Represents the callable internal server that dispatches requests to Netflix\"\"\"\n+ \"\"\"Oppionionated internal proxy that dispatches requests to Netflix\"\"\"\ndef do_GET(self):\n\"\"\"\n@@ -42,11 +46,15 @@ class NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nreturn\n# no existing method given\n- if method not in methods:\n- return self.send_error(404, 'Method \"' + str(method) + '\" not found. Available methods: ' + str(methods))\n+ if method not in METHODS:\n+ error_msg = 'Method \"'\n+ error_msg += str(method)\n+ error_msg += '\" not found. Available methods: '\n+ error_msg += str(methods)\n+ return self.send_error(404, error_msg)\n# call method & get the result\n- result = getattr(sub_res_handler, method)(params)\n+ result = getattr(RES_HANDLER, method)(params)\nself.send_response(200)\nself.send_header('Content-type', 'application/json')\nself.end_headers()\n@@ -54,7 +62,6 @@ class NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n'method': method,\n'result': result}))\n-\ndef log_message(self, format, *args):\n\"\"\"Disable the BaseHTTPServer Log\"\"\"\nreturn\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "@@ -8,6 +8,7 @@ import time\nimport hashlib\nimport platform\nfrom functools import wraps\n+from types import FunctionType\nimport xbmc\n@@ -107,3 +108,14 @@ def __get_mac_address(delay=1):\ntime.sleep(delay)\nmac_addr = xbmc.getInfoLabel('Network.MacAddress')\nreturn mac_addr\n+\n+def get_class_methods(class_item=None):\n+ \"\"\"\n+ Returns the class methods of agiven class object\n+\n+ :param class_item: Class item to introspect\n+ :type class_item: object\n+ :returns: list -- Class methods\n+ \"\"\"\n+ _type = FunctionType\n+ return [x for x, y in class_item.__dict__.items() if isinstance(y, _type)]\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/test/mocks/MinimalClassMocks.py",
"diff": "+class MockClass(object):\n+ def __init__(self):\n+ pass\n+ def foo():\n+ pass\n+ def bar():\n+ pass\n+\n+class Error_resp_401(object):\n+ status_code = 401\n+ pass\n+\n+class Error_resp_500(object):\n+ status_code = 500\n+ pass\n+\n+class Success_resp(object):\n+ status_code = 200\n+ def json(self):\n+ return {'foo': 'bar'}\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/test/test_Utils.py",
"new_path": "resources/test/test_Utils.py",
"diff": "import unittest\nimport mock\n-from resources.lib.utils import get_user_agent, noop, uniq_id, __get_mac_address as gma\n+from resources.lib.utils import get_user_agent, noop, uniq_id, get_class_methods, __get_mac_address as gma\n+from mocks.MinimalClassMocks import MockClass\nfrom mocks.LoggerMocks import TestLoggerWithArgs, TestLoggerWithCredentialArgs, TestLoggerWithNoArgs\n+\nclass UtilsTestCase(unittest.TestCase):\n\"\"\"Tests for the `Utils` module\"\"\"\n@@ -20,7 +22,6 @@ class UtilsTestCase(unittest.TestCase):\ncontainer=get_user_agent(),\nmember='Chrome/59.0.3071.115')\n-\[email protected]('platform.system')\ndef test_get_user_agent_Linux(self, mock_system):\n\"\"\"ADD ME\"\"\"\n@@ -129,3 +130,8 @@ class UtilsTestCase(unittest.TestCase):\nsecond='\"TestLoggerWithCredentialArgs::to_be_logged\" called with arguments :a = b:')\ninstTestLoggerWithCredentialArgs = TestLoggerWithCredentialArgs(logger_3=logger_3)\ninstTestLoggerWithCredentialArgs.to_be_logged(credentials='foo', account='bar', a='b')\n+\n+ def test_get_class_methods(self):\n+ self.assertEqual(\n+ first=get_class_methods(class_item=MockClass),\n+ second=['bar', 'foo', '__init__'])\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | refactor(NetflixHttpRequestHandler): Tiny improvements |
105,979 | 15.10.2017 22:07:57 | -7,200 | f41e8acb8af5fe99384a8c133f429923e8ac23d1 | fix(play): Check for maturity | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -82,7 +82,9 @@ class Navigation(object):\nif self.kodi_helper.get_setting ('autologin_enable') == 'true':\nprofile_id = self.kodi_helper.get_setting ('autologin_id')\nif profile_id != '':\n- self.call_netflix_service({'method': 'switch_profile', 'profile_id': profile_id})\n+ self.call_netflix_service({\n+ 'method': 'switch_profile',\n+ 'profile_id': profile_id})\nreturn self.show_video_lists()\nreturn self.show_profiles()\nelif params['action'] == 'save_autologin':\n@@ -95,10 +97,17 @@ class Navigation(object):\n# show a list of shows/movies\ntype = None if 'type' not in params.keys() else params['type']\nstart = 0 if 'start' not in params.keys() else int(params['start'])\n- return self.show_video_list(video_list_id=params['video_list_id'], type=type, start=start)\n+ video_list = self.show_video_list(\n+ video_list_id=params.get('video_list_id'),\n+ type=type,\n+ start=start)\n+ return video_list\nelif params['action'] == 'season_list':\n# list of seasons for a show\n- return self.show_seasons(show_id=params['show_id'], tvshowtitle=params['tvshowtitle'])\n+ seasons = self.show_seasons(\n+ show_id=params.get('show_id'),\n+ tvshowtitle=params.get('tvshowtitle'))\n+ return seasons\nelif params['action'] == 'episode_list':\n# list of episodes for a season\nreturn self.show_episode_list(season_id=params['season_id'], tvshowtitle=params['tvshowtitle'])\n@@ -124,7 +133,8 @@ class Navigation(object):\nelif params['action'] == 'update':\n# adds a title to the users list on Netflix\nself.remove_from_library(video_id=params['id'])\n- alt_title = self.kodi_helper.show_add_to_library_title_dialog(original_title=urllib.unquote(params['title']).decode('utf8'))\n+ alt_title = self.kodi_helper.show_add_to_library_title_dialog(\n+ original_title=urllib.unquote(params['title']).decode('utf8'))\nself.export_to_library(video_id=params['id'], alt_title=alt_title)\nreturn self.kodi_helper.refresh()\nelif params['action'] == 'removeexported':\n@@ -148,13 +158,17 @@ class Navigation(object):\nelif params['action'] == 'play_video':\n# play a video, check for adult pin if needed\nadult_pin = None\n- ask_for_adult_pin = self.kodi_helper.get_setting('adultpin_enable').lower() == 'true'\n+ adult_setting = self.kodi_helper.get_setting('adultpin_enable')\n+ ask_for_adult_pin = adult_setting.lower() == 'true'\nif ask_for_adult_pin is True:\nif self.check_for_adult_pin(params=params):\nadult_pin = self.kodi_helper.show_adult_pin_dialog()\nif self._check_response(self.call_netflix_service({'method': 'send_adult_pin', 'pin': adult_pin})) != True:\nreturn self.kodi_helper.show_wrong_adult_pin_notification()\n- self.play_video(video_id=params['video_id'], start_offset=params.get('start_offset', -1), infoLabels=params.get('infoLabels', {}))\n+ self.play_video(\n+ video_id=params['video_id'],\n+ start_offset=params.get('start_offset', -1),\n+ infoLabels=params.get('infoLabels', {}))\nelif params['action'] == 'user-items' and params['type'] == 'search':\n# if the user requested a search, ask for the term\nterm = self.kodi_helper.show_search_term_dialog()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(play): Check for maturity |
105,979 | 16.10.2017 15:34:08 | -7,200 | f6f693ee8348352e4d87ed8ff92dab8a2d4eebe8 | refctor(Dialogs): Moves all dialog ui related methods into their own subclass | [
{
"change_type": "MODIFY",
"old_path": "makefile",
"new_path": "makefile",
"diff": "@@ -10,10 +10,11 @@ COVERAGE_FILE = ./.coverage\nCOVERAGE_DIR = ./coverage\nREPORT_DIR = ./report\nDOCS_DIR = ./docs\n-FLAKE_FILES = ./addon.py ./service.py ./setup.py ./resources/lib/utils.py ./resources/lib/MSLHttpRequestHandler.py ./resources/lib/NetflixHttpRequestHandler.py ./resources/lib/Navigation.py\n-RADON_FILES = resources/lib/*.py ./addon.py ./service.py\n+FLAKE_FILES = ./addon.py ./service.py ./setup.py ./resources/lib/utils.py ./resources/lib/MSLHttpRequestHandler.py ./resources/lib/NetflixHttpRequestHandler.py ./resources/lib/Navigation.py ./resources/lib/kodihelper/Dialogs.py\n+RADON_FILES = resources/lib/*.py resources/lib/kodihelper/*.py ./addon.py ./service.py\n+PYLINT_FILES = addon service setup resources.lib.kodihelper.Dialogs resources.lib.MSLHttpRequestHandler resources.lib.NetflixHttpRequestHandler resources.lib.utils\nLINT_REPORT_FILE = ./report/lint.html\n-TEST_OPTIONS = -s --cover-package=resources.lib.utils --cover-package=resources.lib.NetflixSession --cover-package=resources.lib.Navigation --cover-package=resources.lib.MSL --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.Library --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.Library --cover-package=resources.lib.NetflixHttpRequestHandler --cover-package=resources.lib.NetflixHttpSubRessourceHandler --cover-erase --with-coverage --cover-branches\n+TEST_OPTIONS = -s --cover-package=resources.lib.utils --cover-package=resources.lib.NetflixSession --cover-package=resources.lib.Navigation --cover-package=resources.lib.MSL --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.kodihelper.Dialogs --cover-package=resources.lib.Library --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.Library --cover-package=resources.lib.NetflixHttpRequestHandler --cover-package=resources.lib.NetflixHttpSubRessourceHandler --cover-erase --with-coverage --cover-branches\nI18N_FILES = resources/language/**/*.po\nall: clean lint test docs\n@@ -38,8 +39,8 @@ clean-coverage:\nlint:\nflake8 --filename=$(FLAKE_FILES)\n- pylint addon service setup resources --ignore=test,UniversalAnalytics || exit 0\n- pylint addon service setup resources --ignore=test,UniversalAnalytics --output-format=html > $(LINT_REPORT_FILE)\n+ pylint $(PYLINT_FILES) --ignore=test,UniversalAnalytics || exit 0\n+ pylint $(PYLINT_FILES) --ignore=test,UniversalAnalytics --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": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "# Module: KodiHelper\n# Created on: 13.01.2017\n-import xbmcplugin\n-import xbmcgui\n-import xbmc\n+import re\nimport json\nimport base64\n-import re\nimport hashlib\n+from os import remove\n+from uuid import uuid4\n+from urllib import urlencode\nfrom Cryptodome import Random\n+from os.path import join, isfile\nfrom Cryptodome.Cipher import AES\nfrom Cryptodome.Util import Padding\n-from MSL import MSL\n-from os import remove\n-from os.path import join, isfile\n-from urllib import urlencode\n+import xbmc\n+import xbmcgui\n+import xbmcplugin\nfrom xbmcaddon import Addon\n-from uuid import uuid4\n+from resources.lib.MSL import MSL\n+from resources.lib.kodihelper.Dialogs import Dialogs\nfrom utils import get_user_agent, uniq_id\nfrom UniversalAnalytics import Tracker\ntry:\n@@ -79,6 +80,9 @@ class KodiHelper(object):\nself.crypt_key = uniq_id()\nself.library = None\nself.setup_memcache()\n+ self.dialogs = Dialogs(\n+ get_local_string=self.get_local_string,\n+ custom_export_name=self.custom_export_name)\ndef get_addon(self):\n\"\"\"Returns a fresh addon instance\"\"\"\n@@ -110,268 +114,6 @@ class KodiHelper(object):\n\"\"\"Refresh the current list\"\"\"\nreturn xbmc.executebuiltin('Container.Refresh')\n- def show_rating_dialog(self):\n- \"\"\"Asks the user for a movie rating\n-\n- Returns\n- -------\n- :obj:`int`\n- Movie rating between 0 & 10\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- heading = self.get_local_string(string_id=30019)\n- heading += ' '\n- heading += self.get_local_string(string_id=30022)\n- return dlg.numeric(heading=heading, type=0)\n-\n- def show_adult_pin_dialog(self):\n- \"\"\"Asks the user for the adult pin\n-\n- Returns\n- -------\n- :obj:`int`\n- 4 digit adult pin needed for adult movies\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.input(\n- heading=self.get_local_string(string_id=30002),\n- type=xbmcgui.INPUT_NUMERIC)\n- return dialog\n-\n- def show_wrong_adult_pin_notification(self):\n- \"\"\"Shows notification that a wrong adult pin was given\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30006),\n- message=self.get_local_string(string_id=30007),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=5000)\n- return dialog\n-\n- def show_search_term_dialog(self):\n- \"\"\"Asks the user for a term to query the netflix search for\n-\n- Returns\n- -------\n- :obj:`str`\n- Term to search for\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- term = dlg.input(\n- heading=self.get_local_string(string_id=30003),\n- type=xbmcgui.INPUT_ALPHANUM)\n- if len(term) == 0:\n- term = None\n- return term\n-\n- def show_add_to_library_title_dialog(self, original_title):\n- \"\"\"\n- Asks the user for an alternative title for the show/movie that\n- gets exported to the local library\n-\n- Parameters\n- ----------\n- original_title : :obj:`str`\n- Original title of the show (as suggested by the addon)\n-\n- Returns\n- -------\n- :obj:`str`\n- Title to persist\n- \"\"\"\n- if self.custom_export_name == 'true':\n- return original_title\n- dlg = xbmcgui.Dialog()\n- custom_title = dlg.input(\n- heading=self.get_local_string(string_id=30031),\n- defaultt=original_title,\n- type=xbmcgui.INPUT_ALPHANUM) or original_title\n- return original_title or custom_title\n-\n- def show_password_dialog(self):\n- \"\"\"Asks the user for its Netflix password\n-\n- Returns\n- -------\n- :obj:`str`\n- Netflix password\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.input(\n- heading=self.get_local_string(string_id=30004),\n- type=xbmcgui.INPUT_ALPHANUM,\n- option=xbmcgui.ALPHANUM_HIDE_INPUT)\n- return dialog\n-\n- def show_email_dialog(self):\n- \"\"\"Asks the user for its Netflix account email\n-\n- Returns\n- -------\n- term : :obj:`str`\n- Netflix account email\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.input(\n- heading=self.get_local_string(string_id=30005),\n- type=xbmcgui.INPUT_ALPHANUM)\n- return dialog\n-\n- def show_login_failed_notification(self):\n- \"\"\"Shows notification that the login failed\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30008),\n- message=self.get_local_string(string_id=30009),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=5000)\n- return dialog\n-\n- def show_request_error_notification(self):\n- \"\"\"Shows notification that a request error occured\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30051),\n- message=self.get_local_string(string_id=30052),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=5000)\n- return dialog\n-\n- def show_missing_inputstream_addon_notification(self):\n- \"\"\"Shows notification that the inputstream addon couldn't be found\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30028),\n- message=self.get_local_string(string_id=30029),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=5000)\n- return dialog\n-\n- def show_disabled_inputstream_addon_notification(self):\n- \"\"\"Shows notification that the inputstream addon isn't enabled.\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30028),\n- message=self.get_local_string(string_id=30046),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=5000)\n- return dialog\n-\n- def show_no_search_results_notification(self):\n- \"\"\"Shows notification that no search results could be found\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30011),\n- message=self.get_local_string(string_id=30013))\n- return dialog\n-\n- def show_no_seasons_notification(self):\n- \"\"\"Shows notification that no seasons be found\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30010),\n- message=self.get_local_string(string_id=30012))\n- return dialog\n-\n- def show_finally_remove(self, title, type, year):\n- \"\"\"Ask user for yes / no\n-\n- Returns\n- -------\n- bool\n- Answer yes/no\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- if year == '0000':\n- return dlg.yesno(self.get_local_string(string_id=30047), title)\n- dialog = dlg.yesno(\n- heading=self.get_local_string(string_id=30047),\n- line1=title + ' (' + str(year) + ')')\n- return dialog\n-\n- def show_local_db_updated(self):\n- \"\"\"Shows notification that local db was updated\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=15101),\n- message=self.get_local_string(string_id=30050))\n- return dialog\n-\n- def show_no_metadata_notification(self):\n- \"\"\"Shows notification that no metadata is available\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=14116),\n- message=self.get_local_string(string_id=195))\n- return dialog\n-\n- def show_autologin_enabled(self):\n- \"\"\"Shows notification that auto login is enabled\n-\n- Returns\n- -------\n- bool\n- Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=14116),\n- message=self.get_local_string(string_id=30058))\n- return dialog\n-\ndef set_setting(self, key, value):\n\"\"\"Public interface for the addons setSetting method\n@@ -658,9 +400,9 @@ class KodiHelper(object):\nself.set_setting('autologin_user', autologin_user)\nself.set_setting('autologin_id', autologin_id)\nself.set_setting('autologin_enable', 'True')\n- self.show_autologin_enabled()\n+ self.dialogs.show_autologin_enabled_notify()\nself.invalidate_memcache()\n- xbmc.executebuiltin('Container.Refresh')\n+ self.refresh()\ndef build_profiles_listing(self, profiles, action, build_url):\n\"\"\"\n@@ -1105,7 +847,7 @@ class KodiHelper(object):\nbool\nList could be build\n\"\"\"\n- self.show_no_seasons_notification()\n+ self.dialogs.show_no_seasons_notify()\nxbmcplugin.endOfDirectory(self.plugin_handle)\nreturn True\n@@ -1125,7 +867,7 @@ class KodiHelper(object):\nbool\nList could be build\n\"\"\"\n- self.show_no_search_results_notification()\n+ self.dialogs.show_no_search_results_notify()\nreturn xbmcplugin.endOfDirectory(self.plugin_handle)\ndef build_user_sub_listing(self, video_list_ids, type, action, build_url):\n@@ -1318,11 +1060,11 @@ class KodiHelper(object):\naddon = self.get_addon()\n(inputstream_addon, inputstream_enabled) = self.get_inputstream_addon()\nif inputstream_addon is None:\n- self.show_missing_inputstream_addon_notification()\n+ self.dialogs.show_is_missing_notify()\nself.log(msg='Inputstream addon not found')\nreturn False\nif not inputstream_enabled:\n- self.show_disabled_inputstream_addon_notification()\n+ self.dialogs.show_is_inactive_notify()\nself.log(msg='Inputstream addon not enabled')\nreturn False\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -86,12 +86,12 @@ class Navigation(object):\n# switch user account\nif action == 'toggle_adult_pin':\n- adult_pin = self.kodi_helper.show_adult_pin_dialog()\n+ adult_pin = self.kodi_helper.dialogs.show_adult_pin_dialog()\npin_correct = self._check_response(self.call_netflix_service({\n'method': 'send_adult_pin',\n'pin': adult_pin}))\nif pin_correct is not True:\n- return self.kodi_helper.show_wrong_adult_pin_notification()\n+ return self.kodi_helper.dialogs.show_invalid_pin_notify()\nreturn self.kodi_helper.toggle_adult_pin()\n# check if one of the before routing options decided to killthe routing\n@@ -151,7 +151,7 @@ class Navigation(object):\nreturn self.add_to_list(video_id=params['id'])\nelif action == 'export':\n# adds a title to the users list on Netflix\n- alt_title = self.kodi_helper.show_add_to_library_title_dialog(\n+ alt_title = self.kodi_helper.dialogs.show_add_library_title_dialog(\noriginal_title=urllib.unquote(params['title']).decode('utf8'))\nself.export_to_library(video_id=params['id'], alt_title=alt_title)\nreturn self.kodi_helper.refresh()\n@@ -162,16 +162,15 @@ class Navigation(object):\nelif action == 'update':\n# adds a title to the users list on Netflix\nself.remove_from_library(video_id=params['id'])\n- alt_title = self.kodi_helper.show_add_to_library_title_dialog(\n+ alt_title = self.kodi_helper.dialogs.show_add_library_title_dialog(\noriginal_title=urllib.unquote(params['title']).decode('utf8'))\nself.export_to_library(video_id=params['id'], alt_title=alt_title)\nreturn self.kodi_helper.refresh()\nelif action == 'removeexported':\n# adds a title to the users list on Netflix\n- term = self.kodi_helper.show_finally_remove(\n- title=params['title'],\n- type=params['type'],\n- year=params['year'])\n+ term = self.kodi_helper.show_finally_remove_modal(\n+ title=params.get('title'),\n+ year=params.get('year'))\nif params['type'] == 'movie' and str(term) == '1':\nself.library.remove_movie(\ntitle=params['title'].decode('utf-8'),\n@@ -184,7 +183,7 @@ class Navigation(object):\nelif action == 'updatedb':\n# adds a title to the users list on Netflix\nself.library.updatedb_from_exported()\n- self.kodi_helper.show_local_db_updated()\n+ self.kodi_helper.dialogs.show_db_updated_notify()\nreturn True\nelif action == 'user-items' and p_type_not_search_export:\n# display the lists (recommendations, genres, etc.)\n@@ -196,13 +195,13 @@ class Navigation(object):\nask_for_adult_pin = adult_setting.lower() == 'true'\nif ask_for_adult_pin is True:\nif self.check_for_adult_pin(params=params):\n- adult_pin = self.kodi_helper.show_adult_pin_dialog()\n+ pin = self.kodi_helper.dialogs.show_adult_pin_dialog()\npin_response = self.call_netflix_service({\n'method': 'send_adult_pin',\n- 'pin': adult_pin})\n+ 'pin': pin})\npin_correct = self._check_response(pin_response)\nif pin_correct is not True:\n- self.kodi_helper.show_wrong_adult_pin_notification()\n+ self.kodi_helper.dialogs.show_invalid_pin_notify()\nreturn True\nself.play_video(\nvideo_id=params['video_id'],\n@@ -292,7 +291,7 @@ class Navigation(object):\nactions=actions,\nbuild_url=self.build_url)\nreturn results\n- self.kodi_helper.show_no_search_results_notification()\n+ self.kodi_helper.dialogs.show_no_search_results_notify()\nreturn False\ndef show_user_list(self, type):\n@@ -492,7 +491,7 @@ class Navigation(object):\naction='video_lists',\nbuild_url=self.build_url)\nreturn listing\n- return self.kodi_helper.show_login_failed_notification()\n+ return self.kodi_helper.dialogs.show_login_failed_notify()\n@log\ndef rate_on_netflix(self, video_id):\n@@ -503,13 +502,13 @@ class Navigation(object):\nvideo_list_id : :obj:`str`\nID of the video list that should be displayed\n\"\"\"\n- rating = self.kodi_helper.show_rating_dialog()\n+ rating = self.kodi_helper.dialogs.show_rating_dialog()\nresult = self._check_response(self.call_netflix_service({\n'method': 'rate_video',\n'video_id': video_id,\n'rating': rating}))\nif result is False:\n- self.kodi_helper.show_request_error_notification()\n+ self.kodi_helper.dialogs.show_request_error_notify()\nreturn result\n@log\n@@ -526,7 +525,7 @@ class Navigation(object):\n'video_id': video_id}))\nif result:\nreturn self.kodi_helper.refresh()\n- return self.kodi_helper.show_request_error_notification()\n+ return self.kodi_helper.dialogs.show_request_error_notify()\n@log\ndef add_to_list(self, video_id):\n@@ -542,7 +541,7 @@ class Navigation(object):\n'video_id': video_id}))\nif result:\nreturn self.kodi_helper.refresh()\n- return self.kodi_helper.show_request_error_notification()\n+ return self.kodi_helper.dialogs.show_request_error_notify()\n@log\ndef export_to_library(self, video_id, alt_title):\n@@ -582,7 +581,7 @@ class Navigation(object):\nepisodes=episodes,\nbuild_url=self.build_url)\nreturn True\n- self.kodi_helper.show_no_metadata_notification()\n+ self.kodi_helper.dialogs.show_no_metadata_notify()\nreturn False\n@log\n@@ -606,7 +605,7 @@ class Navigation(object):\nif video['type'] == 'show':\nself.library.remove_show(title=video['title'])\nreturn True\n- self.kodi_helper.show_no_metadata_notification()\n+ self.kodi_helper.dialogs.show_no_metadata_notify()\nreturn False\n@log\n@@ -643,8 +642,8 @@ class Navigation(object):\nself._check_response(self.call_netflix_service({'method': 'logout'}))\nself.kodi_helper.set_setting(key='email', value='')\nself.kodi_helper.set_setting(key='password', value='')\n- raw_email = self.kodi_helper.show_email_dialog()\n- raw_password = self.kodi_helper.show_password_dialog()\n+ raw_email = self.kodi_helper.dialogs.show_email_dialog()\n+ raw_password = self.kodi_helper.dialogs.show_password_dialog()\nencoded_email = self.kodi_helper.encode(raw=raw_email)\nencoded_password = self.kodi_helper.encode(raw=raw_password)\nself.kodi_helper.set_setting(key='email', value=encoded_email)\n@@ -656,7 +655,7 @@ class Navigation(object):\nif self.establish_session(account=account) is not True:\nself.kodi_helper.set_setting(key='email', value='')\nself.kodi_helper.set_setting(key='password', value='')\n- return self.kodi_helper.show_login_failed_notification()\n+ return self.kodi_helper.dialogs.show_login_failed_notify()\nreturn True\ndef check_for_adult_pin(self, params):\n@@ -697,11 +696,11 @@ class Navigation(object):\ncredentials = self.kodi_helper.get_credentials()\n# check if we have user settings, if not, set em\nif credentials['email'] == '':\n- email = self.kodi_helper.show_email_dialog()\n+ email = self.kodi_helper.dialogs.show_email_dialog()\nself.kodi_helper.set_setting(key='email', value=email)\ncredentials['email'] = email\nif credentials['password'] == '':\n- password = self.kodi_helper.show_password_dialog()\n+ password = self.kodi_helper.dialogs.show_password_dialog()\nself.kodi_helper.set_setting(key='password', value=password)\ncredentials['password'] = password\n# check login & try to relogin if necessary\n@@ -709,7 +708,7 @@ class Navigation(object):\n'method': 'is_logged_in'}))\nif logged_in is False:\nif self.establish_session(account=credentials) is not True:\n- self.kodi_helper.show_login_failed_notification()\n+ self.kodi_helper.dialogs.show_login_failed_notify()\n# persist & load main menu selection\nif 'type' in params:\nself.kodi_helper.set_main_menu_selection(type=params['type'])\n@@ -756,7 +755,7 @@ class Navigation(object):\nreturn True\nhas_id = 'profile_id' in params\nreturn has_id and current_profile_id != params['profile_id']\n- self.kodi_helper.show_request_error_notification()\n+ self.kodi_helper.dialogs.show_request_error_notify()\nreturn False\ndef parse_paramters(self, paramstring):\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/kodihelper/Dialogs.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: asciidisco\n+# Module: Dialogs\n+# Created on: 16.10.2017\n+# License: MIT https://goo.gl/5bMj3H\n+\n+\"\"\"Kodi UI Dialogs\"\"\"\n+\n+import xbmcgui\n+\n+\n+class Dialogs(object):\n+ \"\"\"Kodi UI Dialogs\"\"\"\n+\n+ def __init__(self, get_local_string, custom_export_name, notify_time=5000):\n+ \"\"\"\n+ Sets the i18n string loader function and exprt name properties\n+\n+ :param original_title: Original title of the show\n+ :type original_title: str\n+ \"\"\"\n+ self.notify_time = notify_time\n+ self.get_local_string = get_local_string\n+ self.custom_export_name = custom_export_name\n+\n+ def show_rating_dialog(self):\n+ \"\"\"\n+ Asks the user for a movie rating\n+\n+ :returns: int - Movie rating between 0 & 10\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ heading = self.get_local_string(string_id=30019)\n+ heading += ' '\n+ heading += self.get_local_string(string_id=30022)\n+ return dlg.numeric(heading=heading, type=0)\n+\n+ def show_adult_pin_dialog(self):\n+ \"\"\"\n+ Asks the user for the adult pin\n+\n+ :returns: int - 4 digit adult pin needed for adult movies\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.input(\n+ heading=self.get_local_string(string_id=30002),\n+ type=xbmcgui.INPUT_NUMERIC)\n+ return dialog\n+\n+ def show_search_term_dialog(self):\n+ \"\"\"\n+ Asks the user for a term to query the netflix search for\n+\n+ :returns: str - Term to search for\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ term = dlg.input(\n+ heading=self.get_local_string(string_id=30003),\n+ type=xbmcgui.INPUT_ALPHANUM)\n+ if len(term) == 0:\n+ term = None\n+ return term\n+\n+ def show_add_library_title_dialog(self, original_title):\n+ \"\"\"\n+ Asks the user for an alternative title for the show/movie that\n+ gets exported to the local library\n+\n+ :param original_title: Original title of the show\n+ :type original_title: str\n+\n+ :returns: str - Title to persist\n+ \"\"\"\n+ if self.custom_export_name == 'true':\n+ return original_title\n+ dlg = xbmcgui.Dialog()\n+ custom_title = dlg.input(\n+ heading=self.get_local_string(string_id=30031),\n+ defaultt=original_title,\n+ type=xbmcgui.INPUT_ALPHANUM) or original_title\n+ return original_title or custom_title\n+\n+ def show_password_dialog(self):\n+ \"\"\"\n+ Asks the user for its Netflix password\n+\n+ :returns: str - Netflix password\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.input(\n+ heading=self.get_local_string(string_id=30004),\n+ type=xbmcgui.INPUT_ALPHANUM,\n+ option=xbmcgui.ALPHANUM_HIDE_INPUT)\n+ return dialog\n+\n+ def show_email_dialog(self):\n+ \"\"\"\n+ Asks the user for its Netflix account email\n+\n+ :returns: str - Netflix account email\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.input(\n+ heading=self.get_local_string(string_id=30005),\n+ type=xbmcgui.INPUT_ALPHANUM)\n+ return dialog\n+\n+ def show_login_failed_notify(self):\n+ \"\"\"\n+ Shows notification that the login failed\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30008),\n+ message=self.get_local_string(string_id=30009),\n+ icon=xbmcgui.NOTIFICATION_ERROR,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_request_error_notify(self):\n+ \"\"\"\n+ Shows notification that a request error occured\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30051),\n+ message=self.get_local_string(string_id=30052),\n+ icon=xbmcgui.NOTIFICATION_ERROR,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_is_missing_notify(self):\n+ \"\"\"\n+ Shows notification that the inputstream addon couldn't be found\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30028),\n+ message=self.get_local_string(string_id=30029),\n+ icon=xbmcgui.NOTIFICATION_ERROR,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_is_inactive_notify(self):\n+ \"\"\"\n+ Shows notification that the inputstream addon isn't enabled.\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30028),\n+ message=self.get_local_string(string_id=30046),\n+ icon=xbmcgui.NOTIFICATION_ERROR,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_invalid_pin_notify(self):\n+ \"\"\"\n+ Shows notification that a wrong adult pin was given\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30006),\n+ message=self.get_local_string(string_id=30007),\n+ icon=xbmcgui.NOTIFICATION_ERROR,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_no_search_results_notify(self):\n+ \"\"\"\n+ Shows notification that no search results could be found\n+\n+ :return: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30011),\n+ message=self.get_local_string(string_id=30013),\n+ icon=xbmcgui.NOTIFICATION_INFO,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_no_seasons_notify(self):\n+ \"\"\"\n+ Shows notification that no seasons be found\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=30010),\n+ message=self.get_local_string(string_id=30012),\n+ icon=xbmcgui.NOTIFICATION_INFO,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_db_updated_notify(self):\n+ \"\"\"\n+ Shows notification that local db was updated\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=15101),\n+ message=self.get_local_string(string_id=30050),\n+ icon=xbmcgui.NOTIFICATION_INFO,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_no_metadata_notify(self):\n+ \"\"\"\n+ Shows notification that no metadata is available\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=14116),\n+ message=self.get_local_string(string_id=195),\n+ icon=xbmcgui.NOTIFICATION_INFO,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_autologin_enabled_notify(self):\n+ \"\"\"\n+ Shows notification that auto login is enabled\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=self.get_local_string(string_id=14116),\n+ message=self.get_local_string(string_id=30058),\n+ icon=xbmcgui.NOTIFICATION_INFO,\n+ time=self.notify_time)\n+ return dialog\n+\n+ def show_finally_remove_modal(self, title, year='0000'):\n+ \"\"\"\n+ Ask if user wants to remove the item from the local library\n+\n+ :param title: Title of the show\n+ :type title: str\n+ :param year: Year of the show\n+ :type year: str\n+\n+ :returns: bool - Answer yes/no\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ if year == '0000':\n+ dialog = dlg.yesno(\n+ heading=self.get_local_string(string_id=30047),\n+ line1=title)\n+ return dialog\n+ dialog = dlg.yesno(\n+ heading=self.get_local_string(string_id=30047),\n+ line1=title + ' (' + str(year) + ')')\n+ return dialog\n"
},
{
"change_type": "ADD",
"old_path": "resources/lib/kodihelper/__init__.py",
"new_path": "resources/lib/kodihelper/__init__.py",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "resources/test/test_KodiHelper.py",
"new_path": "resources/test/test_KodiHelper.py",
"diff": "@@ -30,149 +30,6 @@ class KodiHelperTestCase(unittest.TestCase):\nfirst=kodi_helper.decode('UElth5ymr6hRVIderI80WpSTteTFDeWB3vr7JK/N9QqAuNvriQGZRznH+KCPyiCS'),\nsecond='foo')\n- def test_show_rating_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_rating_dialog(),\n- second='')\n-\n- def test_show_adult_pin_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_adult_pin_dialog(),\n- second='')\n-\n- def test_show_search_term_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_search_term_dialog(),\n- second=None)\n-\n- @mock.patch('xbmcgui.Dialog.input')\n- def test_show_search_term_dialog_not_empty(self, mock_dialog_input):\n- \"\"\"ADD ME\"\"\"\n- mock_dialog_input.return_value = 'a'\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_search_term_dialog(),\n- second='a')\n-\n- def test_show_add_to_library_title_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_add_to_library_title_dialog('foo'),\n- second='foo')\n-\n- def test_show_add_to_library_title_dialog_orig(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- kodi_helper.custom_export_name = 'true'\n- self.assertEqual(\n- first=kodi_helper.show_add_to_library_title_dialog('foo'),\n- second='foo')\n-\n- def test_show_password_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_password_dialog(),\n- second='')\n-\n- def test_show_email_dialog(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_email_dialog(),\n- second='')\n-\n- def test_show_login_failed_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_login_failed_notification(),\n- second=None)\n-\n- def test_show_wrong_adult_pin_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_wrong_adult_pin_notification(),\n- second=None)\n-\n- def test_show_missing_inputstream_addon_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_missing_inputstream_addon_notification(),\n- second=None)\n-\n- def test_show_disabled_inputstream_addon_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_disabled_inputstream_addon_notification(),\n- second=None)\n-\n- def test_show_no_search_results_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_no_search_results_notification(),\n- second=None)\n-\n- def test_show_no_seasons_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_no_seasons_notification(),\n- second=None)\n-\n- def test_request_error_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_request_error_notification(),\n- second=None)\n-\n- def test_show_finally_remove(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_finally_remove(title='', type='', year=''),\n- second=True)\n-\n- def test_show_finally_remove_with_year(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_finally_remove(title='', type='', year='0000'),\n- second=True)\n-\n- def test_show_local_db_updated(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_local_db_updated(),\n- second=None)\n-\n- def test_show_no_metadata_notification(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_no_metadata_notification(),\n- second=None)\n-\n- def test_show_autologin_enabled(self):\n- \"\"\"ADD ME\"\"\"\n- kodi_helper = KodiHelper()\n- self.assertEqual(\n- first=kodi_helper.show_autologin_enabled(),\n- second=None)\n-\ndef test_refresh(self):\n\"\"\"ADD ME\"\"\"\nkodi_helper = KodiHelper()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/test/test_KodiHelper_Dialogs.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Module: KodiHelper.Dialogs\n+# Author: asciidisco\n+# Created on: 11.10.2017\n+# License: MIT https://goo.gl/5bMj3H\n+\n+\"\"\"Tests for the `KodiHelper.Dialogs` module\"\"\"\n+\n+import unittest\n+import mock\n+from resources.lib.KodiHelper import KodiHelper\n+from resources.lib.kodihelper.Dialogs import Dialogs\n+\n+\n+class KodiHelperDialogsTestCase(unittest.TestCase):\n+ \"\"\"Tests for the `KodiHelper.Dialogs` module\"\"\"\n+\n+ def test_show_rating_dialog(self):\n+ \"\"\"Can call rating dialog\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_rating_dialog(),\n+ second='')\n+\n+ def test_show_adult_pin_dialog(self):\n+ \"\"\"Can call adult pin dialog\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_adult_pin_dialog(),\n+ second='')\n+\n+ def test_show_search_term_dialog(self):\n+ \"\"\"Can call input search term dialog (without value)\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_search_term_dialog(),\n+ second=None)\n+\n+ @mock.patch('xbmcgui.Dialog.input')\n+ def test_show_search_term_dialog_with_value(self, mock_dialog_input):\n+ \"\"\"Can call input search term dialog (with value)\"\"\"\n+ mock_dialog_input.return_value = 'a'\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_search_term_dialog(),\n+ second='a')\n+\n+ def test_show_add_to_library_title_dialog(self):\n+ \"\"\"Can call input library title dialog (without export)\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_add_library_title_dialog(\n+ original_title='foo'),\n+ second='foo')\n+\n+ def test_show_add_library_title_dialog_export_true(self):\n+ \"\"\"Can call input library title dialog (with export)\"\"\"\n+ kodi_helper = KodiHelper()\n+ kodi_helper.dialogs.custom_export_name = 'true'\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_add_library_title_dialog(\n+ original_title='foo'),\n+ second='foo')\n+\n+ def test_show_password_dialog(self):\n+ \"\"\"Can call input password dialog\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_password_dialog(),\n+ second='')\n+\n+ def test_show_email_dialog(self):\n+ \"\"\"Can call input email dialog\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_email_dialog(),\n+ second='')\n+\n+ def test_show_login_failed_notify(self):\n+ \"\"\"Can call login failed notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_login_failed_notify(),\n+ second=None)\n+\n+ def test_show_request_error_notify(self):\n+ \"\"\"Can call request error notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_request_error_notify(),\n+ second=None)\n+\n+ def test_show_is_missing_notify(self):\n+ \"\"\"Can call inputstream not installed notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_is_missing_notify(),\n+ second=None)\n+\n+ def test_show_no_search_results_notify(self):\n+ \"\"\"Can call no search results notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_no_search_results_notify(),\n+ second=None)\n+\n+ def test_show_is_inactive_notify(self):\n+ \"\"\"Can call inputstream inactive (disabled) notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_is_inactive_notify(),\n+ second=None)\n+\n+ def test_show_invalid_pin_notify(self):\n+ \"\"\"Can call invalid adult pin notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_invalid_pin_notify(),\n+ second=None)\n+\n+ def test_show_no_seasons_notify(self):\n+ \"\"\"Can call no seasons available notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_no_seasons_notify(),\n+ second=None)\n+\n+ def test_show_db_updated_notify(self):\n+ \"\"\"Can call local db update notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_db_updated_notify(),\n+ second=None)\n+\n+ def test_show_no_metadata_notify(self):\n+ \"\"\"Can call no metadata notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_no_metadata_notify(),\n+ second=None)\n+\n+ def test_show_autologin_enabled_notify(self):\n+ \"\"\"Can call autologin enabled notification\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_autologin_enabled_notify(),\n+ second=None)\n+\n+ def test_show_finally_remove_modal(self):\n+ \"\"\"Can call finally remove from exported db modal\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_finally_remove_modal(title='foo', year='2015'),\n+ second=True)\n+\n+ def test_show_finally_remove_modal_with_empty_year(self):\n+ \"\"\"Can call finally remove from exported db modal with default year\"\"\"\n+ kodi_helper = KodiHelper()\n+ self.assertEqual(\n+ first=kodi_helper.dialogs.show_finally_remove_modal(title='foo'),\n+ second=True)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | refctor(Dialogs): Moves all dialog ui related methods into their own subclass |
106,021 | 19.10.2017 10:06:10 | 14,400 | 84dce43ba513feb24ff501640c6886875f3c594c | Fixed parsing and decryption of chunked responses | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -13,6 +13,7 @@ import json\nimport time\nimport base64\nimport random\n+import re\nfrom Cryptodome.Random import get_random_bytes\nfrom Cryptodome.Hash import HMAC, SHA256\nfrom Cryptodome.Cipher import PKCS1_OAEP\n@@ -231,7 +232,7 @@ class MSL(object):\nresp = self.__parse_chunked_msl_response(resp.text)\nself.kodi_helper.log(\nmsg='Parsed chunked Response: ' + json.dumps(resp))\n- data = self.__decrypt_payload_chunk(resp['payloads'][0])\n+ data = self.__decrypt_payload_chunks(resp['payloads'])\nreturn self.__tranform_to_dash(data)\nreturn False\n@@ -277,7 +278,7 @@ class MSL(object):\nexcept ValueError:\n# json() failed so we have a chunked json response\nresp = self.__parse_chunked_msl_response(resp.text)\n- data = self.__decrypt_payload_chunk(resp['payloads'][0])\n+ data = self.__decrypt_payload_chunks(resp['payloads'])\nif data['success'] is True:\nreturn data['result']['licenses'][0]['data']\nelse:\n@@ -286,8 +287,10 @@ class MSL(object):\nreturn False\nreturn False\n- def __decrypt_payload_chunk(self, payloadchunk):\n- payloadchunk = json.JSONDecoder().decode(payloadchunk)\n+ def __decrypt_payload_chunks(self, payloadchunks):\n+ decrypted_payload = ''\n+ for chunk in payloadchunks:\n+ payloadchunk = json.JSONDecoder().decode(chunk)\npayload = payloadchunk.get('payload')\ndecoded_payload = base64.standard_b64decode(payload)\nencryption_envelope = json.JSONDecoder().decode(decoded_payload)\n@@ -308,10 +311,11 @@ class MSL(object):\ndata = zlib.decompress(decoded_data, 16 + zlib.MAX_WBITS)\nelse:\ndata = base64.standard_b64decode(data)\n+ decrypted_payload += data\n- data = json.JSONDecoder().decode(data)[1]['payload']['data']\n- data = base64.standard_b64decode(data)\n- return json.JSONDecoder().decode(data)\n+ decrypted_payload = json.JSONDecoder().decode(decrypted_payload)[1]['payload']['data']\n+ decrypted_payload = base64.standard_b64decode(decrypted_payload)\n+ return json.JSONDecoder().decode(decrypted_payload)\ndef __tranform_to_dash(self, manifest):\n@@ -476,25 +480,9 @@ class MSL(object):\nreturn urls[key]\ndef __parse_chunked_msl_response(self, message):\n- i = 0\n- opencount = 0\n- closecount = 0\n- header = \"\"\n- payloads = []\n- old_end = 0\n-\n- while i < len(message):\n- if message[i] == '{':\n- opencount = opencount + 1\n- if message[i] == '}':\n- closecount = closecount + 1\n- if opencount == closecount:\n- if header == \"\":\n- header = message[:i]\n- old_end = i + 1\n- else:\n- payloads.append(message[old_end:i + 1])\n- i += 1\n+ header = message.split('}}')[0] + '}}'\n+ payloads = re.split(',\\\"signature\\\":\\\"[0-9A-Za-z=/+]+\\\"}', message.split('}}')[1])\n+ payloads = [x + '}' for x in payloads][:-1]\nreturn {\n'header': header,\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed parsing and decryption of chunked responses |
105,979 | 21.10.2017 12:55:22 | -7,200 | a22fdfa4ccc1d6fba9632e6f3d97edab4c867f90 | fix(NetflixSession): Unconvertable expires key | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -238,6 +238,7 @@ class NetflixSession(object):\nfor domains in cookies[0]:\nfor domain in cookies[0][domains].keys():\nfor cookie_key in cookies[0][domains][domain]:\n+ if cookies[0][domains][domain][cookie_key].expires is not None:\nexp = int(cookies[0][domains][domain][cookie_key].expires)\nif expires > exp:\nexpires = exp\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(NetflixSession): Unconvertable expires key |
105,979 | 21.10.2017 13:02:08 | -7,200 | 312e65511ad423aefb423a200e9bf5ddab0f169c | fix(paths): Use xbmcvfs to store & acces data in the fs | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "# Created on: 26.01.2017\n# License: MIT https://goo.gl/5bMj3H\n-import os\n+import re\nimport sys\nimport zlib\nimport gzip\n@@ -13,7 +13,6 @@ import json\nimport time\nimport base64\nimport random\n-import re\nfrom Cryptodome.Random import get_random_bytes\nfrom Cryptodome.Hash import HMAC, SHA256\nfrom Cryptodome.Cipher import PKCS1_OAEP\n@@ -22,6 +21,7 @@ from Cryptodome.Util import Padding\nfrom Cryptodome.Cipher import AES\nfrom StringIO import StringIO\nfrom datetime import datetime\n+import xbmcvfs\nimport requests\nimport xml.etree.ElementTree as ET\n@@ -59,7 +59,7 @@ class MSL(object):\n\"\"\"\nself.kodi_helper = kodi_helper\ntry:\n- os.mkdir(self.kodi_helper.msl_data_path)\n+ xbmcvfs.mkdir(path=self.kodi_helper.msl_data_path)\nexcept OSError:\npass\n@@ -769,7 +769,7 @@ class MSL(object):\n:param filename: The filename\n:return: True if so\n\"\"\"\n- return os.path.isfile(msl_data_path + filename)\n+ return xbmcvfs.exists(path=msl_data_path + filename)\n@staticmethod\ndef save_file(msl_data_path, filename, content):\n@@ -778,9 +778,10 @@ class MSL(object):\n:param filename: The filename\n:param content: The content of the file\n\"\"\"\n- with open(msl_data_path + filename, 'w') as file_:\n- file_.write(content)\n- file_.flush()\n+\n+ file_handle = xbmcvfs.File(msl_data_path + filename, 'w', True)\n+ file_content = file_handle.write(content)\n+ file_handle.close()\n@staticmethod\ndef load_file(msl_data_path, filename):\n@@ -789,6 +790,7 @@ class MSL(object):\n:param filename: The file to load\n:return: The content of the file\n\"\"\"\n- with open(msl_data_path + filename) as file_:\n- file_content = file_.read()\n+ file_handle = xbmcvfs.File(msl_data_path + filename)\n+ file_content = file_handle.read()\n+ file_handle.close()\nreturn file_content\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(paths): Use xbmcvfs to store & acces data in the fs |
105,979 | 21.10.2017 13:27:24 | -7,200 | ca4ce810314c022f7fbc6d78bd2368a0db6a3190 | fix(login): Fixes issues with login not working | [
{
"change_type": "MODIFY",
"old_path": "makefile",
"new_path": "makefile",
"diff": "@@ -10,11 +10,11 @@ COVERAGE_FILE = ./.coverage\nCOVERAGE_DIR = ./coverage\nREPORT_DIR = ./report\nDOCS_DIR = ./docs\n-FLAKE_FILES = ./addon.py ./service.py ./setup.py ./resources/lib/utils.py ./resources/lib/MSLHttpRequestHandler.py ./resources/lib/NetflixHttpRequestHandler.py ./resources/lib/Navigation.py ./resources/lib/kodihelper/Dialogs.py\n-RADON_FILES = resources/lib/*.py resources/lib/kodihelper/*.py ./addon.py ./service.py\n-PYLINT_FILES = addon service setup resources.lib.kodihelper.Dialogs resources.lib.MSLHttpRequestHandler resources.lib.NetflixHttpRequestHandler resources.lib.utils\n+FLAKE_FILES = ./addon.py ./service.py ./setup.py ./resources/lib/utils.py ./resources/lib/MSLHttpRequestHandler.py ./resources/lib/NetflixHttpRequestHandler.py ./resources/lib/Navigation.py ./resources/lib/kodi/Dialogs.py\n+RADON_FILES = resources/lib/*.py resources/lib/kodi/*.py ./addon.py ./service.py\n+PYLINT_FILES = addon service setup resources.lib.kodi.Dialogs resources.lib.MSLHttpRequestHandler resources.lib.NetflixHttpRequestHandler resources.lib.utils\nLINT_REPORT_FILE = ./report/lint.html\n-TEST_OPTIONS = -s --cover-package=resources.lib.utils --cover-package=resources.lib.NetflixSession --cover-package=resources.lib.Navigation --cover-package=resources.lib.MSL --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.kodihelper.Dialogs --cover-package=resources.lib.Library --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.Library --cover-package=resources.lib.NetflixHttpRequestHandler --cover-package=resources.lib.NetflixHttpSubRessourceHandler --cover-erase --with-coverage --cover-branches\n+TEST_OPTIONS = -s --cover-package=resources.lib.utils --cover-package=resources.lib.NetflixSession --cover-package=resources.lib.Navigation --cover-package=resources.lib.MSL --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.kodi.Dialogs --cover-package=resources.lib.Library --cover-package=resources.lib.KodiHelper --cover-package=resources.lib.Library --cover-package=resources.lib.NetflixHttpRequestHandler --cover-package=resources.lib.NetflixHttpSubRessourceHandler --cover-erase --with-coverage --cover-branches\nI18N_FILES = resources/language/**/*.po\nall: clean lint test docs\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -19,7 +19,7 @@ import xbmcgui\nimport xbmcplugin\nfrom xbmcaddon import Addon\nfrom resources.lib.MSL import MSL\n-from resources.lib.kodihelper.Dialogs import Dialogs\n+from resources.lib.kodi.Dialogs import Dialogs\nfrom utils import get_user_agent, uniq_id\nfrom UniversalAnalytics import Tracker\ntry:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -779,7 +779,9 @@ class MSL(object):\n:param content: The content of the file\n\"\"\"\n- file_handle = xbmcvfs.File(msl_data_path + filename, 'w', True)\n+ file_handle = xbmcvfs.File(\n+ filepath=msl_data_path + filename,\n+ mode='w')\nfile_content = file_handle.write(content)\nfile_handle.close()\n@@ -790,7 +792,8 @@ class MSL(object):\n:param filename: The file to load\n:return: The content of the file\n\"\"\"\n- file_handle = xbmcvfs.File(msl_data_path + filename)\n+ file_handle = xbmcvfs.File(\n+ filepath=msl_data_path + filename)\nfile_content = file_handle.read()\nfile_handle.close()\nreturn file_content\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -626,7 +626,7 @@ class Navigation(object):\n\"\"\"\nis_logged_in = self._check_response(self.call_netflix_service({\n'method': 'is_logged_in'}))\n- if is_logged_in:\n+ if is_logged_in is True:\nreturn True\nelse:\ncheck = self._check_response(self.call_netflix_service({\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"new_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"diff": "@@ -64,7 +64,7 @@ class NetflixHttpSubRessourceHandler(object):\n\"\"\"\nemail = self.credentials.get('email', '')\npassword = self.credentials.get('password', '')\n- if email != '' and password != '':\n+ if email == '' and password == '':\nreturn False\nreturn self.netflix_session.is_logged_in(account=self.credentials)\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/kodihelper/Dialogs.py",
"new_path": "resources/lib/kodi/Dialogs.py",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "resources/lib/kodihelper/__init__.py",
"new_path": "resources/lib/kodi/__init__.py",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "resources/test/test_KodiHelper_Dialogs.py",
"new_path": "resources/test/test_KodiHelper_Dialogs.py",
"diff": "import unittest\nimport mock\nfrom resources.lib.KodiHelper import KodiHelper\n-from resources.lib.kodihelper.Dialogs import Dialogs\n+from resources.lib.kodi.Dialogs import Dialogs\nclass KodiHelperDialogsTestCase(unittest.TestCase):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(login): Fixes issues with login not working |
105,979 | 21.10.2017 13:53:46 | -7,200 | 2c5511f31f2bc8c51e3cc8e79af31b0384a2432b | fix(NetflixSession): Fix quality indicator check | [
{
"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.12.3\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.12.4\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<email>public at asciidisco dot com</email>\n<forum>https://www.kodinerds.net/index.php/Thread/55612-PreRelease-Plugin-Netflix-Inputstream/</forum>\n<source>https://github.com/asciidisco/plugin.video.netflix</source>\n- <news>v0.12.3 (2017-10-21)\n-- Fix problems with login\n-- Fix problems with evaluating cookie expiration\n-- Fix problem with Android filesystem and python interpreter\n+ <news>v0.12.4 (2017-10-21)\n+- Fix problems with quality indicator\n</news>\n</extension>\n</addon>\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -1102,9 +1102,9 @@ class NetflixSession(object):\nQuality of the video\n\"\"\"\nquality = '720'\n- if video['delivery']['hasHD']:\n+ if video.get('delivery', {}).get('hasHD', None):\nquality = '1080'\n- if video['delivery']['hasUltraHD']:\n+ if video.get('delivery', {}).get('hasUltraHD', None):\nquality = '4000'\nreturn quality\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(NetflixSession): Fix quality indicator check |
106,018 | 23.10.2017 21:25:28 | -7,200 | 5e8966eb69f8889c3558f33f45f2d4ba41c0a723 | fix search and exported on user main menu | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -64,7 +64,7 @@ class Navigation(object):\n\"\"\"\nparams = self.parse_paramters(paramstring=paramstring)\naction = params.get('action', None)\n- p_type = params.get('action', None)\n+ p_type = params.get('type', None)\np_type_not_search_export = p_type != 'search' and p_type != 'exported'\n# open foreign settings dialog\n@@ -209,7 +209,7 @@ class Navigation(object):\ninfoLabels=params.get('infoLabels', {}))\nelif action == 'user-items' and params['type'] == 'search':\n# if the user requested a search, ask for the term\n- term = self.kodi_helper.show_search_term_dialog()\n+ term = self.kodi_helper.dialogs.show_search_term_dialog()\nif term:\nresult_folder = self.kodi_helper.build_search_result_folder(\nbuild_url=self.build_url,\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix search and exported on user main menu |
106,018 | 24.10.2017 00:28:29 | -7,200 | a7fe779c2233a77812890cecb134f8b143f8907e | fix missing dialogs link | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -168,7 +168,7 @@ class Navigation(object):\nreturn self.kodi_helper.refresh()\nelif action == 'removeexported':\n# adds a title to the users list on Netflix\n- term = self.kodi_helper.show_finally_remove_modal(\n+ term = self.kodi_helper.dialogs.show_finally_remove_modal(\ntitle=params.get('title'),\nyear=params.get('year'))\nif params['type'] == 'movie' and str(term) == '1':\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix missing dialogs link |
105,979 | 24.10.2017 14:42:19 | -7,200 | 7cb916204e129b390d77e6a8cacaa56fa84bc7bd | fix(search): Adapt new Netflix search API | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -638,7 +638,7 @@ class KodiHelper(object):\n'action': actions[video['type']],\n'show_id': video_list_id\n}\n- params['pin'] = (True, False)[int(video['maturity']['level']) >= 1000]\n+ params['pin'] = (True, False)[int(video.get('maturity', {}).get('level', 1001)) >= 1000]\nif 'tvshowtitle' in infos:\ntitle = infos.get('tvshowtitle', '').encode('utf-8')\nparams['tvshowtitle'] = base64.urlsafe_b64encode(title)\n@@ -1163,18 +1163,20 @@ class KodiHelper(object):\n'poster': ''\n})\n- if 'boxarts' in dict(entry).keys():\n+ if 'boxarts' in dict(entry).keys() and isinstance(entry.get('boxarts'), dict):\n+ big = entry.get('boxarts', {}).get('big')\n+ small = entry.get('boxarts', {}).get('small')\nart.update({\n- 'poster': entry['boxarts']['big'],\n- 'landscape': entry['boxarts']['big'],\n- 'thumb': entry['boxarts']['small'],\n- 'fanart': entry['boxarts']['big']\n+ 'poster': big or small,\n+ 'landscape': big or small,\n+ 'thumb': big or small,\n+ 'fanart': big or small\n})\n# Download image for exported listing\nif 'title' in entry:\nself.library.download_image_file(\ntitle=entry['title'].encode('utf-8'),\n- url=str(entry['boxarts']['big']))\n+ url=str(big))\nif 'interesting_moment' in dict(entry).keys():\nart.update({\n@@ -1188,7 +1190,8 @@ class KodiHelper(object):\nif 'poster' in dict(entry).keys():\nart.update({'poster': entry['poster']})\nli.setArt(art)\n- self.library.write_artdata_file(video_id=str(entry['id']), content=art)\n+ vid_id = entry.get('id', entry.get('summary', {}).get('id'))\n+ self.library.write_artdata_file(video_id=str(vid_id), content=art)\nreturn li\ndef _generate_entry_info(self, entry, li, base_info={}):\n@@ -1244,7 +1247,7 @@ class KodiHelper(object):\ninfos.update({'mpaa': entry['mpaa']})\nelse:\nif entry.get('maturity', None) is not None:\n- if entry['maturity']['board'] is not None and entry['maturity']['value'] is not None:\n+ if entry.get('maturity', {}).get('board') is not None and entry.get('maturity', {}).get('value') is not None:\ninfos.update({'mpaa': str(entry['maturity']['board'].encode('utf-8')) + '-' + str(entry['maturity']['value'].encode('utf-8'))})\nif 'rating' in entry_keys:\ninfos.update({'rating': int(entry['rating']) * 2})\n@@ -1344,7 +1347,7 @@ class KodiHelper(object):\nif 'type' in entry_keys:\n# add/remove movie\nif entry['type'] == 'movie':\n- action_type = 'remove_from_library' if self.library.movie_exists(title=entry['title'], year=entry['year']) else 'export_to_library'\n+ action_type = 'remove_from_library' if self.library.movie_exists(title=entry['title'], year=entry.get('year', 0000)) else 'export_to_library'\nitems.append(action[action_type])\n# Add update option\nif action_type == 'remove_from_library':\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"new_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"diff": "@@ -374,38 +374,15 @@ class NetflixHttpSubRessourceHandler(object):\nTransformed response of the remote call\n\"\"\"\nterm = params.get('term', [''])[0]\n- has_search_results = False\nraw_search_results = self.netflix_session.fetch_search_results(\nsearch_str=term)\n- # check for any errors\n- if 'error' in raw_search_results:\n- return raw_search_results\n-\n# determine if we found something\n- if 'search' in raw_search_results['value']:\n- for key in raw_search_results['value']['search'].keys():\n- if self.netflix_session._is_size_key(key=key) is False:\n- has_search_results = raw_search_results['value']['search'][key]['titles']['length'] > 0\n- if has_search_results is False:\n- if raw_search_results['value']['search'][key].get('suggestions', False) is not False:\n- for entry in raw_search_results['value']['search'][key]['suggestions']:\n- if self.netflix_session._is_size_key(key=entry) is False:\n- if raw_search_results['value']['search'][key]['suggestions'][entry]['relatedvideos']['length'] > 0:\n- has_search_results = True\n-\n- # display that we haven't found a thing\n- if has_search_results is False:\n+ videos = raw_search_results.get('value', {}).get('videos', {})\n+ result_size = len(videos.keys())\n+ # check for any errors\n+ if 'error' in raw_search_results or result_size == 0:\nreturn []\n-\n# list the search results\nsearch_results = self.netflix_session.parse_search_results(\nresponse_data=raw_search_results)\n- # add more menaingful data to the search results\n- raw_contents = self.netflix_session.fetch_video_list_information(\n- video_ids=search_results.keys())\n- # check for any errors\n- if 'error' in raw_contents:\n- return raw_contents\n- video_list = self.netflix_session.parse_video_list(\n- response_data=raw_contents)\n- return video_list\n+ return search_results\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -619,13 +619,10 @@ class NetflixSession(object):\nshow = self.parse_show_list_entry(\nid=entry_id,\nentry=raw_search_results.get(entry_id))\n- response_data = self.fetch_show_information(\n- id=entry_id,\n- type=show.get(entry_id, {}).get('type'))\n- show_info = self.parse_show_information(\n- id=entry_id,\n- response_data=response_data)\n- show[entry_id].update(show_info)\n+ #show_info = self.parse_show_information(\n+ # id=entry_id,\n+ # response_data=raw_search_results.get(entry_id))\n+ #show[entry_id].update(show_info)\nsearch_results.update(show)\nreturn search_results\n@@ -1465,7 +1462,7 @@ class NetflixSession(object):\nresponse=response,\ncomponent='Video list ids')\n- def fetch_search_results(self, search_str, list_from=0, list_to=10):\n+ def fetch_search_results(self, search_str, list_from=0, list_to=48):\n\"\"\"\nFetches the JSON which contains the results for the given search query\n@@ -1485,61 +1482,24 @@ class NetflixSession(object):\n:obj:`dict` of :obj:`dict` of :obj:`str`\nRaw Netflix API call response or api call error\n\"\"\"\n- # properly encode the search string\n- encoded_search_string = quote(search_str)\n+ # reusable query items\n+ item_path = ['search', 'byTerm', '|' + search_str]\n+ item_titles = ['titles', list_to]\n+ item_suggestions = ['suggestions', list_to]\n+ item_pagination = [{'from': list_from, 'to': list_to}]\npaths = [\n- [\n- 'search',\n- encoded_search_string,\n- 'titles',\n- {'from': list_from, 'to': list_to},\n- ['summary', 'title']\n- ],\n- [\n- 'search',\n- encoded_search_string,\n- 'titles',\n- {'from': list_from, 'to': list_to},\n- 'boxarts',\n- '_342x192',\n- 'jpg'\n- ],\n- [\n- 'search',\n- encoded_search_string,\n- 'titles',\n- ['id', 'length', 'name', 'trackIds', 'requestId']\n- ],\n- [\n- 'search',\n- encoded_search_string,\n- 'suggestions',\n- 0,\n- 'relatedvideos',\n- {'from': list_from, 'to': list_to},\n- ['summary', 'title']\n- ],\n- [\n- 'search',\n- encoded_search_string,\n- 'suggestions',\n- 0,\n- 'relatedvideos',\n- {'from': list_from, 'to': list_to},\n- 'boxarts',\n- '_342x192',\n- 'jpg'\n- ],\n- [\n- 'search',\n- encoded_search_string,\n- 'suggestions',\n- 0,\n- 'relatedvideos',\n- ['id', 'length', 'name', 'trackIds', 'requestId']\n- ]\n- ]\n+ item_path + item_titles + item_pagination + ['reference', ['summary', 'releaseYear', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue', 'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount', 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'watched', 'delivery', 'seasonList', 'current']],\n+ item_path + item_titles + item_pagination + ['reference', 'bb2OGLogo', '_400x90', 'png'],\n+ item_path + item_titles + item_pagination + ['reference', 'boxarts', '_342x192', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'boxarts', '_1280x720', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'storyarts', '_1632x873', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'interestingMoment', '_665x375', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'artWorkByType', 'BILLBOARD', '_1280x720', 'jpg'],\n+ item_path + item_titles + [['referenceId', 'id', 'length', 'name', 'trackIds', 'requestId', 'regularSynopsis', 'evidence']],\n+ item_path + item_suggestions + item_pagination + ['summary', 'releaseYear', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue', 'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount', 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'watched', 'delivery', 'seasonList', 'current'],\n+ item_path + item_suggestions + [['length', 'referenceId', 'trackId']]]\n+\nresponse = self._path_request(paths=paths)\nreturn self._process_response(\nresponse=response,\n@@ -2240,7 +2200,7 @@ class NetflixSession(object):\nif user_data is None:\nreturn None\nself.user_data = user_data\n- self.esn = user_data.get('esn')\n+ self.esn = self._parse_esn_data(user_data)\nself.api_data = {\n'API_BASE_URL': user_data.get('API_BASE_URL'),\n'API_ROOT': user_data.get('API_ROOT'),\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(search): Adapt new Netflix search API |
105,983 | 24.10.2017 15:28:50 | -7,200 | 0fbe3bb5e7acabe73f963b337c218876abe90255 | Fix assistive audio streams | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -405,7 +405,7 @@ class MSL(object):\n# Multiple Adaption Set for audio\nfor audio_track in manifest['audioTracks']:\nimpaired = 'false'\n- if audio_track.get('trackType') != 'ASSISTIVE':\n+ if audio_track.get('trackType') == 'ASSISTIVE':\nimpaired = 'true'\naudio_adaption_set = ET.SubElement(\nparent=period,\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix assistive audio streams |
105,979 | 24.10.2017 17:55:05 | -7,200 | dad1f7fa7f602c0cd127b6d488a9765cfc148625 | fix(search): Add proper item props to search results, reduce search to 1 request | [
{
"change_type": "MODIFY",
"old_path": ".travis.yml",
"new_path": ".travis.yml",
"diff": "@@ -9,7 +9,7 @@ script:\n- pip install pycryptodomex\n- make all\n- touch ./_build/.nojekyll\n- - if [ \"$TRAVIS_BRANCH\" == \"master\" ]; then codeclimate-test-reporter; fi\n+ - if [ \"$TRAVIS_BRANCH\" == \"master\" ]; then codeclimate-test-reporter; else exit 0; fi\ndeploy:\n- provider: pages\n"
},
{
"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.12.5\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.12.6\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<email>public at asciidisco dot com</email>\n<forum>https://www.kodinerds.net/index.php/Thread/55612-PreRelease-Plugin-Netflix-Inputstream/</forum>\n<source>https://github.com/asciidisco/plugin.video.netflix</source>\n- <news>v0.12.5 (2017-10-24)\n-- Fix problems with Android ESN\n-- Adapt to new Netflix search API\n+ <news>v0.12.6 (2017-10-24)\n+- Fix problems with wrongly tagged audio channels\n+- Add proper item props to search results, reduce search to 1 request\n</news>\n</extension>\n</addon>\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1162,7 +1162,10 @@ class KodiHelper(object):\n'fanart': '',\n'poster': ''\n})\n-\n+ self.log(entry)\n+ if 'boxarts' in dict(entry).keys() and not isinstance(entry.get('boxarts'), dict):\n+ big = entry.get('boxarts', '')\n+ small = big\nif 'boxarts' in dict(entry).keys() and isinstance(entry.get('boxarts'), dict):\nbig = entry.get('boxarts', {}).get('big')\nsmall = entry.get('boxarts', {}).get('small')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"new_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"diff": "@@ -383,6 +383,6 @@ class NetflixHttpSubRessourceHandler(object):\nif 'error' in raw_search_results or result_size == 0:\nreturn []\n# list the search results\n- search_results = self.netflix_session.parse_search_results(\n+ search_results = self.netflix_session.parse_video_list(\nresponse_data=raw_search_results)\nreturn search_results\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix(search): Add proper item props to search results, reduce search to 1 request |
105,979 | 24.10.2017 18:02:00 | -7,200 | b2d54782d2a747adf1b3c115458f9f5878ccacd9 | ci(travis): Fixes build error | [
{
"change_type": "MODIFY",
"old_path": ".travis.yml",
"new_path": ".travis.yml",
"diff": "@@ -9,7 +9,7 @@ script:\n- pip install pycryptodomex\n- make all\n- touch ./_build/.nojekyll\n- - if [ \"$TRAVIS_BRANCH\" == \"master\" ]; then codeclimate-test-reporter; else exit 0; fi\n+ - if [ \"$TRAVIS_BRANCH\" == \"master\" ]; then make rere; else exit 0; fi\ndeploy:\n- provider: pages\n"
},
{
"change_type": "MODIFY",
"old_path": "makefile",
"new_path": "makefile",
"diff": "-.PHONY: all test clean docs clean-pyc clean-report clean-docs clean-coverage\n+.PHONY: all test clean docs clean-pyc clean-report clean-docs clean-coverage rere\n.DEFAULT_GOAL := all\nSPHINXBUILD = sphinx-build\n@@ -52,6 +52,8 @@ docs:\ntest:\nnosetests $(TEST_DIR) $(TEST_OPTIONS) --cover-html --cover-html-dir=$(COVERAGE_DIR)\n+rere:\n+ codeclimate-test-reporter\nhelp:\n@echo \" clean-pyc\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | ci(travis): Fixes build error |
106,027 | 27.10.2017 17:57:40 | -7,200 | b45098b9fd5d4cb0574c31343f7847fb061e944c | fix fetch_episodes_by_season | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -1298,10 +1298,10 @@ class NetflixSession(object):\n'id': episode['summary']['id'],\n'episode': episode['summary']['episode'],\n'season': episode['summary']['season'],\n- 'plot': episode['info']['synopsis'],\n- 'duration': episode['info']['runtime'],\n- 'title': episode['info']['title'],\n- 'year': episode['info']['releaseYear'],\n+ 'plot': episode['synopsis'],\n+ 'duration': episode['runtime'],\n+ 'title': episode['title'],\n+ 'year': episode['releaseYear'],\n'genres': self.parse_genres_for_video(\nvideo=episode,\ngenres=genres),\n@@ -1309,7 +1309,7 @@ class NetflixSession(object):\n'maturity': episode['maturity'],\n'playcount': (0, 1)[episode.get('watched')],\n'rating': rating,\n- 'thumb': episode['info']['interestingMoments']['url'],\n+ 'thumb': episode['interestingMoment']['_665x375']['jpg']['url'],\n'fanart': moment,\n'poster': episode['boxarts']['_1280x720']['jpg']['url'],\n'banner': episode['boxarts']['_342x192']['jpg']['url'],\n@@ -1552,7 +1552,7 @@ class NetflixSession(object):\nRaw Netflix API call response or api call error\n\"\"\"\npaths = [\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, ['summary', 'queue', 'info', 'maturity', 'userRating', 'bookmarkPosition', 'creditOffset', 'watched', 'delivery']],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, ['summary','synopsis','title','runtime', 'releaseYear', 'queue', 'info', 'maturity', 'userRating', 'bookmarkPosition', 'creditOffset', 'watched', 'delivery']],\n# ['videos', season_id, 'cast', {'from': 0, 'to': 15}, ['id', 'name']],\n# ['videos', season_id, 'cast', 'summary'],\n# ['videos', season_id, 'genres', {'from': 0, 'to': 5}, ['id', 'name']],\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix fetch_episodes_by_season |
105,979 | 27.10.2017 20:49:58 | -7,200 | cf3bec87311a8d868557eb5a2138fe6edb2232a7 | chorer(version): Version bump | [
{
"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.12.6\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.12.7\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<email>public at asciidisco dot com</email>\n<forum>https://www.kodinerds.net/index.php/Thread/55612-PreRelease-Plugin-Netflix-Inputstream/</forum>\n<source>https://github.com/asciidisco/plugin.video.netflix</source>\n- <news>v0.12.6 (2017-10-24)\n-- Fix problems with wrongly tagged audio channels\n-- Add proper item props to search results, reduce search to 1 request\n+ <news>v0.12.6 (2017-10-27)\n+- Adapt the Netflix API changes for episode/season lists\n</news>\n</extension>\n</addon>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | chorer(version): Version bump |
105,989 | 08.02.2018 16:59:24 | -3,600 | 2cc138650a5ad448234d487e146c794cfed74e2e | Automatically mark library items as watched | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -45,6 +45,9 @@ class KodiHelper(object):\nConsumes all the configuration data from Kodi as well as\nturns data into lists of folders and videos\"\"\"\n+ TAGGED_WINDOW_ID = 10000\n+ PROP_NETFLIX_PLAY = 'is_netflix_play'\n+\ndef __init__(self, plugin_handle=None, base_url=None):\n\"\"\"\nFetches all needed info from Kodi &\n@@ -1136,6 +1139,10 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\nsucceeded=True,\nlistitem=play_item)\n+\n+ #set window property to enable recognition of playbacks initiated by this addon\n+ xbmcgui.Window(self.TAGGED_WINDOW_ID).setProperty(self.PROP_NETFLIX_PLAY, 'true')\n+\nreturn resolved\ndef _generate_art_info(self, entry, li):\n@@ -1526,7 +1533,7 @@ class KodiHelper(object):\nin_season = episode['season'] == showseason\nin_episode = episode['episode'] == showepisode\nif in_season and in_episode:\n- infos = {}\n+ infos = {'mediatype': 'episode', 'dbid': episode['episodeid']}\nif 'plot' in episode and len(episode['plot']) > 0:\ninfos.update({\n'plot': episode['plot'],\n@@ -1564,7 +1571,7 @@ class KodiHelper(object):\nresult = json_result.get('result', None)\nif result is not None and 'moviedetails' in result:\nresult = result.get('moviedetails', {})\n- infos = {}\n+ infos = {'mediatype': 'movie', 'dbid': movieid}\nif 'genre' in result and len(result['genre']) > 0:\ninfos.update({'genre': json_result['genre']})\nif 'plot' in result and len(result['plot']) > 0:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/KodiMonitor.py",
"diff": "+# pylint: skip-file\n+# -*- coding: utf-8 -*-\n+# Module: KodiHelper\n+# Created on: 13.01.2017\n+\n+import xbmc\n+import xbmcgui\n+import json\n+\n+\n+class KodiMonitor(xbmc.Monitor):\n+\n+ def __init__(self, kodi_helper):\n+ super(KodiMonitor, self).__init__()\n+ self.kodi_helper = kodi_helper\n+ self.video_info = None\n+ self.progress = 0\n+\n+ def update_playback_progress(self):\n+ if self.video_info is not None:\n+ player_id = self.get_active_video_player()\n+\n+ if player_id is not None:\n+ method = 'Player.GetProperties'\n+ params = {\n+ 'playerid': player_id,\n+ 'properties': ['percentage']\n+ }\n+\n+ response = self.json_rpc(method, params)\n+\n+ if 'result' in response:\n+ self.progress = response['result']['percentage']\n+ self.kodi_helper.log(\n+ msg='Current playback progress is {}%'.format(\n+ self.progress)\n+ )\n+ else:\n+ self.kodi_helper.log(\n+ msg='Could not update playback progress'\n+ )\n+\n+ def onNotification(self, sender, method, data):\n+ data = json.loads(unicode(data, 'utf-8', errors='ignore'))\n+\n+ if method == 'Player.OnPlay':\n+ self.on_playback_started(data.get('item', None))\n+ elif method == 'Player.OnStop':\n+ self.on_playback_stopped(data['end'])\n+\n+ def on_playback_started(self, item):\n+ self.kodi_helper.log(\n+ msg='Playback started, waiting for player - item: {}'.format(item)\n+ )\n+\n+ # wait for player to start playing video\n+ xbmc.sleep(7500)\n+ player_id = self.get_active_video_player()\n+\n+ if self.is_netflix_play() and player_id is not None:\n+ self.video_info = self.get_video_info(player_id, item)\n+ self.progress = 0\n+ else:\n+ self.kodi_helper.log(\n+ msg='Playback is not from Netflix or it suddenly stopped'\n+ )\n+\n+ def on_playback_stopped(self, ended):\n+ if self.video_info is not None and self.is_netflix_play():\n+ self.kodi_helper.log(msg='Netflix playback stopped')\n+\n+ if self.progress >= 90:\n+ self.increment_playcount(\n+ self.video_info['dbtype'],\n+ self.video_info['dbid'],\n+ self.video_info['playcount']\n+ )\n+ else:\n+ self.kodi_helper.log(\n+ msg='Progress insufficient, not marking as watched'\n+ )\n+ else:\n+ self.kodi_helper.log(msg='Playback was not from Netflix')\n+\n+ self.video_info = None\n+ self.progress = 0\n+\n+ def increment_playcount(self, dbtype, dbid, playcount=0):\n+ new_playcount = playcount + 1\n+\n+ self.kodi_helper.log(\n+ msg='Incrementing playcount of {} with dbid {} to {}'.format(\n+ dbtype, dbid, new_playcount),\n+ level=xbmc.LOGNOTICE\n+ )\n+\n+ method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n+ params = {\n+ '{}id'.format(dbtype): dbid,\n+ 'playcount': new_playcount\n+ }\n+\n+ return self.json_rpc(method, params)\n+\n+ def get_active_video_player(self):\n+ method = 'Player.GetActivePlayers'\n+ resp = self.json_rpc(method)\n+\n+ if 'result' in resp:\n+ for player in resp['result']:\n+ if player['type'] == 'video':\n+ return player['playerid']\n+\n+ return None\n+\n+ def get_video_info(self, player_id, fallback_data):\n+ method = 'Player.GetItem'\n+ params = {\n+ 'playerid': player_id,\n+ 'properties': [\n+ 'playcount',\n+ 'title',\n+ 'year',\n+ 'showtitle',\n+ 'season',\n+ 'episode'\n+ ]\n+ }\n+\n+ resp = self.json_rpc(method, params)\n+\n+ if 'result' in resp and 'item' in resp['result']:\n+ item = resp['result']['item']\n+\n+ self.kodi_helper.log(\n+ msg=u'Got info from player: {}'.format(item)\n+ )\n+\n+ dbid = item.get('id', None)\n+ dbtype = item.get('type', None)\n+\n+ if dbtype is not None and dbid is not None:\n+ playcount = item['playcount']\n+ video_info = {\n+ 'dbtype': dbtype,\n+ 'dbid': dbid,\n+ 'playcount': playcount\n+ }\n+ self.kodi_helper.log(\n+ msg='Found video info from player: {}'.format(video_info)\n+ )\n+\n+ if video_info['dbtype'] in ['episode', 'movie']:\n+ return video_info\n+ else:\n+ self.kodi_helper.log(msg='Not playing an episode or movie')\n+ return None\n+\n+ video_info = self.get_video_info_fallback(fallback_data)\n+\n+ if video_info is not None:\n+ self.kodi_helper.log(\n+ msg='Found video info by fallback: {}'.format(video_info)\n+ )\n+ else:\n+ self.kodi_helper.log(\n+ msg='Could not get video info',\n+ level=xbmc.LOGERROR\n+ )\n+\n+ return video_info\n+\n+ def get_video_info_fallback(self, data):\n+ self.kodi_helper.log(\n+ msg='Using fallback lookup method for video info (BAD)',\n+ level=xbmc.LOGWARNING\n+ )\n+ return None\n+\n+ def is_netflix_play(self):\n+ return xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).getProperty(\n+ self.kodi_helper.PROP_NETFLIX_PLAY\n+ ) is not None\n+\n+ def json_rpc(self, method, params=None):\n+ req = {\n+ 'jsonrpc': '2.0',\n+ 'method': method,\n+ 'id': 1,\n+ 'params': params or {}\n+ }\n+\n+ jsonrequest = json.dumps(req)\n+ self.kodi_helper.log(msg='Sending request: {}'.format(jsonrequest))\n+\n+ jsonresponse = unicode(\n+ xbmc.executeJSONRPC(jsonrequest),\n+ 'utf-8',\n+ errors='ignore'\n+ )\n+ self.kodi_helper.log(msg='Received response: {}'.format(jsonresponse))\n+\n+ return json.loads(jsonresponse)\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "import threading\nimport socket\nfrom SocketServer import TCPServer\n-from xbmc import Monitor\nfrom resources.lib.KodiHelper import KodiHelper\n+from resources.lib.KodiMonitor import KodiMonitor\nfrom resources.lib.MSLHttpRequestHandler import MSLHttpRequestHandler\nfrom resources.lib.NetflixHttpRequestHandler import NetflixHttpRequestHandler\n@@ -56,7 +56,7 @@ NS_SERVER.server_activate()\nNS_SERVER.timeout = 1\nif __name__ == '__main__':\n- MONITOR = Monitor()\n+ MONITOR = KodiMonitor(KODI_HELPER)\n# start thread for MLS servie\nMSL_THREAD = threading.Thread(target=MSL_SERVER.serve_forever)\n@@ -70,6 +70,8 @@ if __name__ == '__main__':\n# kill the services if kodi monitor tells us to\nwhile not MONITOR.abortRequested():\n+ MONITOR.update_playback_progress()\n+\nif MONITOR.waitForAbort(5):\nMSL_SERVER.shutdown()\nNS_SERVER.shutdown()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Automatically mark library items as watched |
105,989 | 08.02.2018 20:31:43 | -3,600 | eae327d021bb904083f94200116f404374021809 | Added fallback lookup method | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -54,8 +54,15 @@ class KodiMonitor(xbmc.Monitor):\n)\n# wait for player to start playing video\n- xbmc.sleep(7500)\n+ xbmc.sleep(3000)\nplayer_id = self.get_active_video_player()\n+ retries = 0\n+\n+ while player_id is None and retries < 3:\n+ # wait and retry up to three times if player is very slow\n+ xbmc.sleep(3000)\n+ player_id = self.get_active_video_player()\n+ retries += 1\nif self.is_netflix_play() and player_id is not None:\nself.video_info = self.get_video_info(player_id, item)\n@@ -121,6 +128,7 @@ class KodiMonitor(xbmc.Monitor):\n'playcount',\n'title',\n'year',\n+ 'tvshowid',\n'showtitle',\n'season',\n'episode'\n@@ -128,6 +136,7 @@ class KodiMonitor(xbmc.Monitor):\n}\nresp = self.json_rpc(method, params)\n+ item = None\nif 'result' in resp and 'item' in resp['result']:\nitem = resp['result']['item']\n@@ -156,7 +165,7 @@ class KodiMonitor(xbmc.Monitor):\nself.kodi_helper.log(msg='Not playing an episode or movie')\nreturn None\n- video_info = self.get_video_info_fallback(fallback_data)\n+ video_info = self.get_video_info_fallback(item, fallback_data)\nif video_info is not None:\nself.kodi_helper.log(\n@@ -170,11 +179,136 @@ class KodiMonitor(xbmc.Monitor):\nreturn video_info\n- def get_video_info_fallback(self, data):\n+ def get_video_info_fallback(self, item, fallback_data):\n+ \"\"\"\n+ Finds video info using a more inaccurate matching approach. Tries to\n+ use as much info returned by the player in `item` to do the lookup.\n+ If that fails, the most generic fallback is used by just matching\n+ against titles / show names and season episode numbers.\"\"\"\n+\n+ if (item is not None or\n+ (fallback_data is not None and 'title' in fallback_data)):\nself.kodi_helper.log(\n- msg='Using fallback lookup method for video info (BAD)',\n+ msg='Using inaccurate fallback lookup method for video info',\nlevel=xbmc.LOGWARNING\n)\n+\n+ # Kinda weird way to prevent duplicate code, feel free to improve:\n+ # If there's a dbtype given, we want to use the associated lookup\n+ # function first, to save time. If it returns None, we still want\n+ # the other one to be called.\n+ dbtype = item.get('type', 'episode')\n+ if dbtype not in ['episode', 'movie']:\n+ # Coerce into known value\n+ dbtype = 'episode'\n+ other_dbtype = ['episode', 'movie']\n+ other_dbtype.remove(dbtype)\n+ other_dbtype = other_dbtype[0]\n+ self.kodi_helper.log(\n+ msg='Lookup priority: 1) {} 2) {}'.format(dbtype, other_dbtype)\n+ )\n+ lookup_functions = {\n+ 'episode': self.find_episode_info,\n+ 'movie': self.find_movie_info\n+ }\n+\n+ return (\n+ lookup_functions[dbtype](item, fallback_data) or\n+ lookup_functions[other_dbtype](item, fallback_data)\n+ )\n+ else:\n+ return None\n+\n+ def find_episode_info(self, item, fallback_data):\n+ method = 'VideoLibrary.GetEpisodes'\n+ params = {\n+ 'properties': [\n+ 'playcount',\n+ 'tvshowid',\n+ 'showtitle',\n+ 'season',\n+ 'episode'\n+ ]\n+ }\n+\n+ showtitle = None\n+ tvshowid = None\n+ season = None\n+ episode = None\n+ title = None\n+\n+ if item is not None:\n+ if 'tvshowid' in item and item['tvshowid'] > 0:\n+ tvshowid = item['tvshowid']\n+ params['tvshowid'] = tvshowid\n+ if 'showtitle' in item and item['showtitle']:\n+ showtitle = item['showtitle']\n+ if 'season' in item and item['season'] > 0:\n+ season = item['season']\n+ params['season'] = season\n+ if 'episode' in item and item['episode'] > 0:\n+ episode = item['episode']\n+ if 'label' in item and item['label']:\n+ title = item['label']\n+ elif fallback_data is not None:\n+ title = fallback_data.get('title', '')\n+\n+ resp = self.json_rpc(method, params)\n+\n+ if 'result' in resp and 'episodes' in resp['result']:\n+ for episode in resp['result']['episodes']:\n+ episode_meta = 'S%02dE%02d' % (\n+ episode['season'],\n+ episode['episode']\n+ )\n+\n+ if ((tvshowid == episode['tvshowid'] or\n+ showtitle == episode['showtitle']) and\n+ season == episode['season'] and\n+ episode == episode['episode'] or\n+ (episode_meta in title and\n+ episode['showtitle'] in title)):\n+ return {\n+ 'dbtype': 'episode',\n+ 'dbid': episode['episodeid'],\n+ 'playcount': episode['playcount']\n+ }\n+ else:\n+ return None\n+\n+ def find_movie_info(self, item, fallback_data):\n+ method = 'VideoLibrary.GetMovies'\n+ params = {\n+ 'properties': ['playcount', 'year', 'title']\n+ }\n+\n+ title = ''\n+\n+ if item is not None:\n+ title = item.get(\n+ 'title',\n+ fallback_data.get(\n+ 'title',\n+ ''\n+ ) if fallback_data is not None else ''\n+ )\n+\n+ if 'year' in item:\n+ params['filter'] = {'year': item['year']}\n+\n+ resp = self.json_rpc(method, params)\n+\n+ if 'result' in resp and 'movies' in resp['result']:\n+ for movie in resp['result']['movies']:\n+ movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n+ self.kodi_helper.log(u'Matching {}'.format(movie_meta))\n+ if movie_meta == title or movie['label'] in title:\n+ return {\n+ 'dbtype': 'movie',\n+ 'dbid': movie['movieid'],\n+ 'playcount': movie['playcount']\n+ }\n+ else:\nreturn None\ndef is_netflix_play(self):\n@@ -191,13 +325,13 @@ class KodiMonitor(xbmc.Monitor):\n}\njsonrequest = json.dumps(req)\n- self.kodi_helper.log(msg='Sending request: {}'.format(jsonrequest))\n+ self.kodi_helper.log(msg=u'Sending request: {}'.format(jsonrequest))\njsonresponse = unicode(\nxbmc.executeJSONRPC(jsonrequest),\n'utf-8',\nerrors='ignore'\n)\n- self.kodi_helper.log(msg='Received response: {}'.format(jsonresponse))\n+ self.kodi_helper.log(msg=u'Received response: {}'.format(jsonresponse))\nreturn json.loads(jsonresponse)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added fallback lookup method |
105,989 | 09.02.2018 12:04:32 | -3,600 | bcaadc19891a3b75b732cdd059126e8ef89d78fb | Improve handling of non-netflix playbacks | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -46,7 +46,8 @@ class KodiHelper(object):\nturns data into lists of folders and videos\"\"\"\nTAGGED_WINDOW_ID = 10000\n- PROP_NETFLIX_PLAY = 'is_netflix_play'\n+ PROP_NETFLIX_PLAY = 'netflix_playback'\n+ PROP_PLAYBACK_INIT = 'initialized'\ndef __init__(self, plugin_handle=None, base_url=None):\n\"\"\"\n@@ -1140,8 +1141,11 @@ class KodiHelper(object):\nsucceeded=True,\nlistitem=play_item)\n- #set window property to enable recognition of playbacks initiated by this addon\n- xbmcgui.Window(self.TAGGED_WINDOW_ID).setProperty(self.PROP_NETFLIX_PLAY, 'true')\n+ # set window property to enable recognition of playbacks\n+ xbmcgui.Window(self.TAGGED_WINDOW_ID).setProperty(\n+ self.PROP_NETFLIX_PLAY,\n+ self.PROP_PLAYBACK_INIT\n+ )\nreturn resolved\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -10,6 +10,8 @@ import json\nclass KodiMonitor(xbmc.Monitor):\n+ PROP_PLAYBACK_TRACKING = 'tracking'\n+\ndef __init__(self, kodi_helper):\nsuper(KodiMonitor, self).__init__()\nself.kodi_helper = kodi_helper\n@@ -64,16 +66,23 @@ class KodiMonitor(xbmc.Monitor):\nplayer_id = self.get_active_video_player()\nretries += 1\n- if self.is_netflix_play() and player_id is not None:\n+ if self.is_initialized_playback() and player_id is not None:\nself.video_info = self.get_video_info(player_id, item)\nself.progress = 0\n+ xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\n+ self.kodi_helper.PROP_NETFLIX_PLAY,\n+ self.PROP_PLAYBACK_TRACKING\n+ )\nelse:\n+ # Clean up remnants from unproperly stopped previous playbacks\n+ xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\n+ self.kodi_helper.PROP_NETFLIX_PLAY, 'notnetflix')\nself.kodi_helper.log(\nmsg='Playback is not from Netflix or it suddenly stopped'\n)\ndef on_playback_stopped(self, ended):\n- if self.video_info is not None and self.is_netflix_play():\n+ if self.video_info is not None and self.is_tracking_playback():\nself.kodi_helper.log(msg='Netflix playback stopped')\nif self.progress >= 90:\n@@ -89,6 +98,8 @@ class KodiMonitor(xbmc.Monitor):\nelse:\nself.kodi_helper.log(msg='Playback was not from Netflix')\n+ xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\n+ self.kodi_helper.PROP_NETFLIX_PLAY, 'stopped')\nself.video_info = None\nself.progress = 0\n@@ -311,10 +322,16 @@ class KodiMonitor(xbmc.Monitor):\nelse:\nreturn None\n- def is_netflix_play(self):\n+ def is_initialized_playback(self):\n+ return self.is_playback_status(self.kodi_helper.PROP_PLAYBACK_INIT)\n+\n+ def is_tracking_playback(self):\n+ return self.is_playback_status(self.PROP_PLAYBACK_TRACKING)\n+\n+ def is_playback_status(self, status):\nreturn xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).getProperty(\nself.kodi_helper.PROP_NETFLIX_PLAY\n- ) is not None\n+ ) == status\ndef json_rpc(self, method, params=None):\nreq = {\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Improve handling of non-netflix playbacks |
105,989 | 14.02.2018 16:31:06 | -3,600 | d868d87b1ced22e70ed6398d3dfbc0178c5c755b | Add saving resume points to Kodi library | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -26,7 +26,7 @@ class KodiMonitor(xbmc.Monitor):\nmethod = 'Player.GetProperties'\nparams = {\n'playerid': player_id,\n- 'properties': ['percentage']\n+ 'properties': ['percentage', 'time']\n}\nresponse = self.json_rpc(method, params)\n@@ -37,6 +37,23 @@ class KodiMonitor(xbmc.Monitor):\nmsg='Current playback progress is {}%'.format(\nself.progress)\n)\n+ time = response['result']['time']\n+ playtime_seconds = time['hours'] * 3600 + \\\n+ time['minutes'] * 60 + time['seconds']\n+ if self.save_resume_bookmark(\n+ playtime_seconds,\n+ self.video_info['dbtype'],\n+ self.video_info['dbid']\n+ ):\n+ self.kodi_helper.log(\n+ msg='Saved bookmark at {} seconds'.format(\n+ playtime_seconds)\n+ )\n+ else:\n+ self.kodi_helper.log(\n+ msg='Could not save bookmark',\n+ level=xbmc.LOGWARNING\n+ )\nelse:\nself.kodi_helper.log(\nmsg='Could not update playback progress'\n@@ -118,7 +135,16 @@ class KodiMonitor(xbmc.Monitor):\n'playcount': new_playcount\n}\n- return self.json_rpc(method, params)\n+ return self.is_ok(self.json_rpc(method, params))\n+\n+ def save_resume_bookmark(self, time, dbtype, dbid):\n+ method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n+ params = {\n+ '{}id'.format(dbtype): dbid,\n+ 'resume': {'position': time}\n+ }\n+\n+ return self.is_ok(self.json_rpc(method, params))\ndef get_active_video_player(self):\nmethod = 'Player.GetActivePlayers'\n@@ -352,3 +378,9 @@ class KodiMonitor(xbmc.Monitor):\nself.kodi_helper.log(msg=u'Received response: {}'.format(jsonresponse))\nreturn json.loads(jsonresponse)\n+\n+ def is_ok(self, jsonrpc_response):\n+ return (\n+ 'result' in jsonrpc_response and\n+ jsonrpc_response['result'] == 'OK'\n+ )\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add saving resume points to Kodi library |
106,003 | 16.02.2018 17:49:10 | -3,600 | 5166e7d1d4465036623d97a6cb38be5184b6e8df | Added autorefresh for video_list_id in case no video_list_id was given.
This makes it possible for skinners to create a container with contents of the addons f.e. widgets.
Used parts of im85288's pull request but made a few corrections. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -415,6 +415,9 @@ class Navigation(object):\nuser_data = self._check_response(self.call_netflix_service({\n'method': 'get_user_data'}))\nif user_data:\n+ user_list = ['queue', 'topTen', 'netflixOriginals', 'trendingNow', 'newRelease', 'popularTitles']\n+ if str(type) in user_list and video_list_id == None:\n+ video_list_id = self.refresh_list_id_for_type(type)\nfor i in range(0, 4):\nitems = self._check_response(self.call_netflix_service({\n'method': 'fetch_video_list',\n@@ -480,6 +483,20 @@ class Navigation(object):\nreturn listing\nreturn False\n+ @log\n+ def refresh_list_id_for_type(self,type):\n+ \"\"\"The list_ids are not static so may need refreshed for example when stored as a widget\"\"\"\n+ user_data = self._check_response(self.call_netflix_service({\n+ 'method': 'get_user_data'}))\n+ video_list_ids = self._check_response(self.call_netflix_service({\n+ 'method': 'fetch_video_list_ids',\n+ 'guid': user_data['guid'],\n+ 'cache': True}))\n+ if video_list_ids:\n+ for video_list_id in video_list_ids['user']:\n+ if video_list_ids['user'][video_list_id]['name'] == type:\n+ return str(video_list_ids['user'][video_list_id]['id'])\n+\n@log\ndef show_profiles(self):\n\"\"\"List the profiles for the active account\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added autorefresh for video_list_id in case no video_list_id was given.
This makes it possible for skinners to create a container with contents of the addons f.e. widgets.
Used parts of im85288's pull request but made a few corrections. |
106,003 | 16.02.2018 18:17:33 | -3,600 | e2c6052b1c68b58078739c1675f27bcd20217678 | fixup code climate | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -415,9 +415,10 @@ class Navigation(object):\nuser_data = self._check_response(self.call_netflix_service({\n'method': 'get_user_data'}))\nif user_data:\n- user_list = ['queue', 'topTen', 'netflixOriginals', 'trendingNow', 'newRelease', 'popularTitles']\n- if str(type) in user_list and video_list_id == None:\n- video_list_id = self.refresh_list_id_for_type(type)\n+ user_list = ['queue', 'topTen', 'netflixOriginals',\n+ 'trendingNow', 'newRelease', 'popularTitles']\n+ if str(type) in user_list and video_list_id is None:\n+ video_list_id = self.list_id_for_type(type)\nfor i in range(0, 4):\nitems = self._check_response(self.call_netflix_service({\n'method': 'fetch_video_list',\n@@ -484,8 +485,8 @@ class Navigation(object):\nreturn False\n@log\n- def refresh_list_id_for_type(self,type):\n- \"\"\"The list_ids are not static so may need refreshed for example when stored as a widget\"\"\"\n+ def list_id_for_type(self, type):\n+ \"\"\"Get the list_ids for a given type\"\"\"\nuser_data = self._check_response(self.call_netflix_service({\n'method': 'get_user_data'}))\nvideo_list_ids = self._check_response(self.call_netflix_service({\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fixup code climate |
106,016 | 29.01.2018 18:35:21 | -3,600 | 24c690274e25da3f878b3df84a39a8c8b58aa97e | Implement inputstreamhelper | [
{
"change_type": "MODIFY",
"old_path": "addon.xml",
"new_path": "addon.xml",
"diff": "<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<import addon=\"script.module.pycryptodome\" version=\"3.4.3\"/>\n- <import addon=\"inputstream.adaptive\" version=\"2.0.0\"/>\n+ <import addon=\"script.module.inputstreamhelper\" version=\"0.3.3\"/>\n</requires>\n<extension point=\"xbmc.python.pluginsource\" library=\"addon.py\">\n<provides>video</provides>\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -17,6 +17,7 @@ from Cryptodome.Util import Padding\nimport xbmc\nimport xbmcgui\nimport xbmcplugin\n+import inputstreamhelper\nfrom xbmcaddon import Addon\nfrom resources.lib.MSL import MSL\nfrom resources.lib.kodi.Dialogs import Dialogs\n@@ -1058,14 +1059,8 @@ class KodiHelper(object):\n\"\"\"\nself.set_esn(esn)\naddon = self.get_addon()\n- (inputstream_addon, inputstream_enabled) = self.get_inputstream_addon()\n- if inputstream_addon is None:\n- self.dialogs.show_is_missing_notify()\n- self.log(msg='Inputstream addon not found')\n- return False\n- if not inputstream_enabled:\n- self.dialogs.show_is_inactive_notify()\n- self.log(msg='Inputstream addon not enabled')\n+ is_helper = inputstreamhelper.Helper('mpd', drm='widevine')\n+ if not is_helper.check_inputstream():\nreturn False\n# track play event\n@@ -1084,23 +1079,23 @@ class KodiHelper(object):\nplay_item.setContentLookup(False)\nplay_item.setMimeType('application/dash+xml')\nplay_item.setProperty(\n- key=inputstream_addon + '.stream_headers',\n+ key=is_helper.inputstream_addon + '.stream_headers',\nvalue='user-agent=' + get_user_agent())\nplay_item.setProperty(\n- key=inputstream_addon + '.license_type',\n+ key=is_helper.inputstream_addon + '.license_type',\nvalue='com.widevine.alpha')\nplay_item.setProperty(\n- key=inputstream_addon + '.manifest_type',\n+ key=is_helper.inputstream_addon + '.manifest_type',\nvalue='mpd')\nplay_item.setProperty(\n- key=inputstream_addon + '.license_key',\n+ key=is_helper.inputstream_addon + '.license_key',\nvalue=msl_service_url + '/license?id=' + video_id + '||b{SSM}!b{SID}|')\nplay_item.setProperty(\n- key=inputstream_addon + '.server_certificate',\n+ key=is_helper.inputstream_addon + '.server_certificate',\nvalue='Cr0CCAMSEOVEukALwQ8307Y2+LVP+0MYh/HPkwUijgIwggEKAoIBAQDm875btoWUbGqQD8eAGuBlGY+Pxo8YF1LQR+Ex0pDONMet8EHslcZRBKNQ/09RZFTP0vrYimyYiBmk9GG+S0wB3CRITgweNE15cD33MQYyS3zpBd4z+sCJam2+jj1ZA4uijE2dxGC+gRBRnw9WoPyw7D8RuhGSJ95OEtzg3Ho+mEsxuE5xg9LM4+Zuro/9msz2bFgJUjQUVHo5j+k4qLWu4ObugFmc9DLIAohL58UR5k0XnvizulOHbMMxdzna9lwTw/4SALadEV/CZXBmswUtBgATDKNqjXwokohncpdsWSauH6vfS6FXwizQoZJ9TdjSGC60rUB2t+aYDm74cIuxAgMBAAE6EHRlc3QubmV0ZmxpeC5jb20SgAOE0y8yWw2Win6M2/bw7+aqVuQPwzS/YG5ySYvwCGQd0Dltr3hpik98WijUODUr6PxMn1ZYXOLo3eED6xYGM7Riza8XskRdCfF8xjj7L7/THPbixyn4mULsttSmWFhexzXnSeKqQHuoKmerqu0nu39iW3pcxDV/K7E6aaSr5ID0SCi7KRcL9BCUCz1g9c43sNj46BhMCWJSm0mx1XFDcoKZWhpj5FAgU4Q4e6f+S8eX39nf6D6SJRb4ap7Znzn7preIvmS93xWjm75I6UBVQGo6pn4qWNCgLYlGGCQCUm5tg566j+/g5jvYZkTJvbiZFwtjMW5njbSRwB3W4CrKoyxw4qsJNSaZRTKAvSjTKdqVDXV/U5HK7SaBA6iJ981/aforXbd2vZlRXO/2S+Maa2mHULzsD+S5l4/YGpSt7PnkCe25F+nAovtl/ogZgjMeEdFyd/9YMYjOS4krYmwp3yJ7m9ZzYCQ6I8RQN4x/yLlHG5RH/+WNLNUs6JAZ0fFdCmw=')\nplay_item.setProperty(\nkey='inputstreamaddon',\n- value=inputstream_addon)\n+ value=is_helper.inputstream_addon)\n# check if we have a bookmark e.g. start offset position\nif int(start_offset) > 0:\n@@ -1401,36 +1396,6 @@ class KodiHelper(object):\nlocString = locString.encode('utf-8')\nreturn locString\n- def get_inputstream_addon(self):\n- \"\"\"Checks if the inputstream addon is installed & enabled.\n- Returns the type of the inputstream addon used and if it's enabled,\n- or None if not found.\n-\n- Returns\n- -------\n- :obj:`tuple` of obj:`str` and bool, or None\n- Inputstream addon and if it's enabled, or None\n- \"\"\"\n- is_type = 'inputstream.adaptive'\n- is_enabled = False\n- payload = {\n- 'jsonrpc': '2.0',\n- 'id': 1,\n- 'method': 'Addons.GetAddonDetails',\n- 'params': {\n- 'addonid': is_type,\n- 'properties': ['enabled']\n- }\n- }\n- response = xbmc.executeJSONRPC(json.dumps(payload))\n- data = json.loads(response)\n- if 'error' not in data.keys():\n- if isinstance(data.get('result'), dict):\n- if isinstance(data.get('result').get('addon'), dict):\n- is_enabled = data.get('result').get('addon').get('enabled')\n- return (is_type, is_enabled)\n- return (None, is_enabled)\n-\ndef movietitle_to_id(self, title):\nquery = {\n\"jsonrpc\": \"2.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -893,6 +893,5 @@ class Navigation(object):\ndef open_settings(self, url):\n\"\"\"Opens a foreign settings dialog\"\"\"\n- (is_addon, _) = self.kodi_helper.get_inputstream_addon()\n- url = is_addon if url == 'is' else url\n+ url = 'inputstream.adaptive' if url == 'is' else url\nreturn Addon(url).openSettings()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/Dialogs.py",
"new_path": "resources/lib/kodi/Dialogs.py",
"diff": "@@ -133,34 +133,6 @@ class Dialogs(object):\ntime=self.notify_time)\nreturn dialog\n- def show_is_missing_notify(self):\n- \"\"\"\n- Shows notification that the inputstream addon couldn't be found\n-\n- :returns: bool - Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30028),\n- message=self.get_local_string(string_id=30029),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=self.notify_time)\n- return dialog\n-\n- def show_is_inactive_notify(self):\n- \"\"\"\n- Shows notification that the inputstream addon isn't enabled.\n-\n- :returns: bool - Dialog shown\n- \"\"\"\n- dlg = xbmcgui.Dialog()\n- dialog = dlg.notification(\n- heading=self.get_local_string(string_id=30028),\n- message=self.get_local_string(string_id=30046),\n- icon=xbmcgui.NOTIFICATION_ERROR,\n- time=self.notify_time)\n- return dialog\n-\ndef show_invalid_pin_notify(self):\n\"\"\"\nShows notification that a wrong adult pin was given\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)\"/>\n<setting type=\"sep\"/>\n- <setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"RunPlugin(plugin://plugin.video.netflix/?mode=openSettings&url=is)\" option=\"close\"/>\n+ <setting id=\"is_settings\" type=\"action\" label=\"30035\" action=\"RunPlugin(plugin://plugin.video.netflix/?mode=openSettings&url=is)\" enable=\"System.HasAddon(inputstream.adaptive)\" option=\"close\"/>\n</category>\n<category label=\"30025\">\n<setting id=\"enablelibraryfolder\" type=\"bool\" label=\"30026\" default=\"false\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Implement inputstreamhelper |
105,985 | 17.03.2018 09:37:59 | -3,600 | 8090520658360893d5fdc6439f9f6dbf2a0e2653 | Fix list_id with reference
Thx to securus | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -1419,21 +1419,21 @@ class NetflixSession(object):\nlist_to = FETCH_VIDEO_REQUEST_COUNT\npaths = [\n- ['lists', list_id, {'from': list_from, 'to': list_to}, ['summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue', 'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount', 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'watched', 'delivery']],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'cast', {'from': 0, 'to': 15}, ['id', 'name']],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'cast', 'summary'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'genres', {'from': 0, 'to': 5}, ['id', 'name']],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'genres', 'summary'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'tags', {'from': 0, 'to': 9}, ['id', 'name']],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'tags', 'summary'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, ['creators', 'directors'], {'from': 0, 'to': 49}, ['id', 'name']],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, ['creators', 'directors'], 'summary'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'bb2OGLogo', '_400x90', 'png'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'boxarts', '_1280x720', 'jpg'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'storyarts', '_1632x873', 'jpg'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'interestingMoment', '_665x375', 'jpg'],\n- ['lists', list_id, {'from': list_from, 'to': list_to}, 'artWorkByType', 'BILLBOARD', '_1280x720', 'jpg']\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", ['summary', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue', 'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount', 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'watched', 'delivery']],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'cast', {'from': 0, 'to': 15}, ['id', 'name']],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'cast', 'summary'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'genres', {'from': 0, 'to': 5}, ['id', 'name']],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'genres', 'summary'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'tags', {'from': 0, 'to': 9}, ['id', 'name']],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'tags', 'summary'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", ['creators', 'directors'], {'from': 0, 'to': 49}, ['id', 'name']],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", ['creators', 'directors'], 'summary'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'bb2OGLogo', '_400x90', 'png'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', '_342x192', 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', '_1280x720', 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'storyarts', '_1632x873', 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', '_665x375', 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'artWorkByType', 'BILLBOARD', '_1280x720', 'jpg']\n]\nresponse = self._path_request(paths=paths)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix list_id with reference
Thx to securus |
105,992 | 18.03.2018 10:22:39 | -3,600 | 9acbed03d030529f208b85aa4a9fd37e4023cc35 | Version bump (0.12.8) | [
{
"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.12.7\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.12.8\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump (0.12.8) |
105,989 | 19.03.2018 11:52:54 | -3,600 | 006d6218773073f37b4dfac83680b7ee4f6f46c4 | Add resuming from bookmarks saved in Kodi library | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1126,15 +1126,17 @@ class KodiHelper(object):\nshowid=id,\nshowseason=infoLabels['season'],\nshowepisode=infoLabels['episode'])\n- if details is not False:\n- play_item.setInfo('video', details[0])\n- play_item.setArt(details[1])\nif infoLabels['mediatype'] != 'episode':\nid = self.movietitle_to_id(title=infoLabels['title'])\ndetails = self.get_movie_content_by_id(movieid=id)\n+\nif details is not False:\nplay_item.setInfo('video', details[0])\nplay_item.setArt(details[1])\n+ resume_point = details[0].get('resume')\n+ if resume_point is not None:\n+ play_item.setProperty(\n+ 'StartOffset', str(resume_point) + '.0')\nresolved = xbmcplugin.setResolvedUrl(\nhandle=self.plugin_handle,\n@@ -1516,7 +1518,7 @@ class KodiHelper(object):\ndef get_show_content_by_id(self, showid, showseason, showepisode):\nshowseason = int(showseason)\nshowepisode = int(showepisode)\n- props = [\"season\", \"episode\", \"plot\", \"fanart\", \"art\"]\n+ props = [\"season\", \"episode\", \"plot\", \"fanart\", \"art\", \"resume\"]\nquery = {\n\"jsonrpc\": \"2.0\",\n\"method\": \"VideoLibrary.GetEpisodes\",\n@@ -1538,6 +1540,8 @@ class KodiHelper(object):\nin_episode = episode['episode'] == showepisode\nif in_season and in_episode:\ninfos = {'mediatype': 'episode', 'dbid': episode['episodeid']}\n+ if 'resume' in episode:\n+ infos.update('resume', episode['resume'])\nif 'plot' in episode and len(episode['plot']) > 0:\ninfos.update({\n'plot': episode['plot'],\n@@ -1564,7 +1568,8 @@ class KodiHelper(object):\n\"plot\",\n\"fanart\",\n\"thumbnail\",\n- \"art\"]\n+ \"art\",\n+ \"resume\"]\n},\n\"id\": \"libMovies\"\n}\n@@ -1576,6 +1581,8 @@ class KodiHelper(object):\nif result is not None and 'moviedetails' in result:\nresult = result.get('moviedetails', {})\ninfos = {'mediatype': 'movie', 'dbid': movieid}\n+ if 'resume' in result:\n+ infos.update('resume', result['resume'])\nif 'genre' in result and len(result['genre']) > 0:\ninfos.update({'genre': json_result['genre']})\nif 'plot' in result and len(result['plot']) > 0:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add resuming from bookmarks saved in Kodi library |
105,989 | 19.03.2018 14:20:11 | -3,600 | 68dae99f4f8ca6db0e3de1a3aabc087308f18230 | Fixed issues due to change in RPC API | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -277,12 +277,10 @@ class KodiMonitor(xbmc.Monitor):\nif item is not None:\nif 'tvshowid' in item and item['tvshowid'] > 0:\ntvshowid = item['tvshowid']\n- params['tvshowid'] = tvshowid\nif 'showtitle' in item and item['showtitle']:\nshowtitle = item['showtitle']\nif 'season' in item and item['season'] > 0:\nseason = item['season']\n- params['season'] = season\nif 'episode' in item and item['episode'] > 0:\nepisode = item['episode']\nif 'label' in item and item['label']:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed issues due to change in RPC API |
105,989 | 19.03.2018 14:20:31 | -3,600 | c08c99e56f01a296c54da3563c17ec76a293a3f6 | Improved retrieval of bookmarks (still not working due to Kodi internal StartOffset bug, but keeping it if this ever gets fixed). | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1131,12 +1131,12 @@ class KodiHelper(object):\ndetails = self.get_movie_content_by_id(movieid=id)\nif details is not False:\n+ if 'resume' in details[0]:\n+ resume_point = details[0].pop('resume')\n+ play_item.setProperty(\n+ 'StartOffset', str(resume_point))\nplay_item.setInfo('video', details[0])\nplay_item.setArt(details[1])\n- resume_point = details[0].get('resume')\n- if resume_point is not None:\n- play_item.setProperty(\n- 'StartOffset', str(resume_point) + '.0')\nresolved = xbmcplugin.setResolvedUrl(\nhandle=self.plugin_handle,\n@@ -1540,8 +1540,8 @@ class KodiHelper(object):\nin_episode = episode['episode'] == showepisode\nif in_season and in_episode:\ninfos = {'mediatype': 'episode', 'dbid': episode['episodeid']}\n- if 'resume' in episode:\n- infos.update('resume', episode['resume'])\n+ if 'resume' in episode and episode['resume']['position'] > 0:\n+ infos['resume'] = episode['resume']['position']\nif 'plot' in episode and len(episode['plot']) > 0:\ninfos.update({\n'plot': episode['plot'],\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Improved retrieval of bookmarks (still not working due to Kodi internal StartOffset bug, but keeping it if this ever gets fixed). |
105,989 | 19.03.2018 17:11:29 | -3,600 | aad4ceacc76d162532a4971a5d112af68513ef14 | Added metadata fetching for individual episodes on export to library. Fixes | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -630,9 +630,9 @@ class KodiHelper(object):\nlabel=video['title'],\niconImage=self.default_fanart)\n# add some art to the item\n- li = self._generate_art_info(entry=video, li=li)\n+ li.setArt(self._generate_art_info(entry=video))\n# add list item info\n- li, infos = self._generate_entry_info(entry=video, li=li)\n+ li, infos = self._generate_listitem_info(entry=video, li=li)\nli = self._generate_context_menu_items(entry=video, li=li)\n# lists can be mixed with shows & movies, therefor we need to check if its a movie, so play it right away\nif video_list[video_list_id]['type'] == 'movie':\n@@ -961,9 +961,9 @@ class KodiHelper(object):\nfor season in seasons_sorted:\nli = xbmcgui.ListItem(label=season['text'])\n# add some art to the item\n- li = self._generate_art_info(entry=season, li=li)\n+ li.setArt(self._generate_art_info(entry=season))\n# add list item info\n- li, infos = self._generate_entry_info(\n+ li, infos = self._generate_listitem_info(\nentry=season,\nli=li,\nbase_info={'mediatype': 'season'})\n@@ -1020,9 +1020,9 @@ class KodiHelper(object):\nfor episode in episodes_sorted:\nli = xbmcgui.ListItem(label=episode['title'])\n# add some art to the item\n- li = self._generate_art_info(entry=episode, li=li)\n+ li.setArt(self._generate_art_info(entry=episode))\n# add list item info\n- li, infos = self._generate_entry_info(\n+ li, infos = self._generate_listitem_info(\nentry=episode,\nli=li,\nbase_info={'mediatype': 'episode'})\n@@ -1173,21 +1173,18 @@ class KodiHelper(object):\nlistitem=play_item)\nreturn resolved\n- def _generate_art_info(self, entry, li):\n+ def _generate_art_info(self, entry):\n\"\"\"Adds the art info from an entry to a Kodi list item\nParameters\n----------\nentry : :obj:`dict` of :obj:`str`\n- Entry that should be turned into a list item\n-\n- li : :obj:`XMBC.ListItem`\n- Kodi list item instance\n+ Entry that art dict should be generated for\nReturns\n-------\n- :obj:`XMBC.ListItem`\n- Kodi list item instance\n+ :obj:`dict` of :obj:`str`\n+ Dictionary containing art info\n\"\"\"\nart = {'fanart': self.default_fanart}\n# Cleanup art\n@@ -1197,7 +1194,6 @@ class KodiHelper(object):\n'fanart': '',\n'poster': ''\n})\n- self.log(entry)\nif 'boxarts' in dict(entry).keys() and not isinstance(entry.get('boxarts'), dict):\nbig = entry.get('boxarts', '')\nsmall = big\n@@ -1227,31 +1223,36 @@ class KodiHelper(object):\nart.update({'fanart': entry['fanart']})\nif 'poster' in dict(entry).keys():\nart.update({'poster': entry['poster']})\n- li.setArt(art)\nvid_id = entry.get('id', entry.get('summary', {}).get('id'))\nself.library.write_artdata_file(video_id=str(vid_id), content=art)\n- return li\n+ return art\n+\n+ def _generate_listitem_info(self, entry, li, base_info={}):\n+ infos, li_infos = self._generate_entry_info(entry, base_info)\n+ li.setInfo('video', infos)\n+ if li_infos.get('is_playable'):\n+ li.setProperty('IsPlayable', 'true')\n+ li.addStreamInfo('video', li_infos['quality'])\n+ return li, infos\n- def _generate_entry_info(self, entry, li, base_info={}):\n+ def _generate_entry_info(self, entry, base_info={}):\n\"\"\"Adds the item info from an entry to a Kodi list item\nParameters\n----------\nentry : :obj:`dict` of :obj:`str`\n- Entry that should be turned into a list item\n-\n- li : :obj:`XMBC.ListItem`\n- Kodi list item instance\n+ Entry that info dict should be generated for\nbase_info : :obj:`dict` of :obj:`str`\nAdditional info that overrules the entry info\nReturns\n-------\n- :obj:`XMBC.ListItem`\n- Kodi list item instance\n+ :obj:`dict` of :obj:`str`\n+ Dictionary containing info labels\n\"\"\"\ninfos = base_info\n+ li_infos = {}\nentry_keys = entry.keys()\n# Cleanup item info\ninfos.update({\n@@ -1268,8 +1269,7 @@ class KodiHelper(object):\n'mediatype': '',\n'playcount': '',\n'episode': '',\n- 'year': '',\n- 'tvshowtitle': ''\n+ 'year': ''\n})\nif 'cast' in entry_keys and len(entry['cast']) > 0:\n@@ -1305,12 +1305,13 @@ class KodiHelper(object):\ninfos.update({'title': entry['title']})\nif 'type' in entry_keys:\nif entry['type'] == 'movie' or entry['type'] == 'episode':\n- li.setProperty('IsPlayable', 'true')\n+ li_infos['is_playable'] = True\nelif entry['type'] == 'show':\ninfos.update({'tvshowtitle': entry['title']})\nif 'mediatype' in entry_keys:\n- if entry['mediatype'] == 'movie' or entry['mediatype'] == 'episode':\n- li.setProperty('IsPlayable', 'true')\n+ if (entry['mediatype'] == 'movie' or\n+ entry['mediatype'] == 'episode'):\n+ li_infos['is_playable'] = True\ninfos.update({'mediatype': entry['mediatype']})\nif 'watched' in entry_keys and entry.get('watched') is True:\ninfos.update({'playcount': 1})\n@@ -1328,13 +1329,15 @@ class KodiHelper(object):\nquality = {'width': '1280', 'height': '720'}\nif entry['quality'] == '1080':\nquality = {'width': '1920', 'height': '1080'}\n- li.addStreamInfo('video', quality)\n+ li_infos['quality'] = quality\nif 'tvshowtitle' in entry_keys:\n- title = base64.urlsafe_b64decode(entry.get('tvshowtitle', ''))\n- infos.update({'tvshowtitle': title.decode('utf-8')})\n- li.setInfo('video', infos)\n- self.library.write_metadata_file(video_id=str(entry['id']), content=infos)\n- return li, infos\n+ title = entry.get('tvshowtitle', '')\n+ if not isinstance(title, unicode):\n+ title = base64.urlsafe_b64decode(title).decode('utf-8')\n+ infos.update({'tvshowtitle': title})\n+ self.library.write_metadata_file(\n+ video_id=str(entry['id']), content=infos)\n+ return infos, li_infos\ndef _generate_context_menu_items(self, entry, li):\n\"\"\"Adds context menue items to a Kodi list item\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -570,6 +570,25 @@ class Navigation(object):\nif video['type'] == 'show':\nepisodes = []\nfor season in video['seasons']:\n+ user_data = (\n+ self._check_response(\n+ self.call_netflix_service(\n+ {'method': 'get_user_data'})))\n+ episode_list = (\n+ self._check_response(\n+ self.call_netflix_service({\n+ 'method': 'fetch_episodes_by_season',\n+ 'season_id': season['id'],\n+ 'guid': user_data['guid'],\n+ 'cache': True})))\n+ if episode_list:\n+ for episode in episode_list.itervalues():\n+ episode['tvshowtitle'] = video['title']\n+ self.log(msg='EPISODE: {}'.format(episode))\n+ self.kodi_helper._generate_art_info(entry=episode)\n+ self.kodi_helper._generate_entry_info(\n+ entry=episode,\n+ base_info={'mediatype': 'episode'})\nfor episode in season['episodes']:\nepisodes.append({\n'season': season['seq'],\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added metadata fetching for individual episodes on export to library. Fixes #283 |
105,989 | 19.03.2018 17:26:04 | -3,600 | 7dc2d9dc06e63acc4fea83afab8e70b1e456b2c3 | Removed logging call left over from debugging. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -584,7 +584,6 @@ class Navigation(object):\nif episode_list:\nfor episode in episode_list.itervalues():\nepisode['tvshowtitle'] = video['title']\n- self.log(msg='EPISODE: {}'.format(episode))\nself.kodi_helper._generate_art_info(entry=episode)\nself.kodi_helper._generate_entry_info(\nentry=episode,\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Removed logging call left over from debugging. |
105,989 | 20.03.2018 16:47:13 | -3,600 | b67b58fd513df77e2a817b4fe77c39696872f011 | Code cleanup and improve code climate | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "-# pylint: skip-file\n# -*- coding: utf-8 -*-\n-# Module: KodiHelper\n-# Created on: 13.01.2017\n+# Author: caphm\n+# Module: KodiMonitor\n+# Created on: 08.02.2018\n+# License: MIT https://goo.gl/5bMj3H\n+\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n+\n+import json\nimport xbmc\nimport xbmcgui\n-import json\n+\n+from resources.lib.utils import noop, log\n+\n+\n+def _get_safe_with_fallback(item, fallback, itemkey='title',\n+ fallbackkey='title', default=''):\n+ try:\n+ return item.get(itemkey) or fallback.get(fallbackkey)\n+ except AttributeError:\n+ return default\nclass KodiMonitor(xbmc.Monitor):\n+ \"\"\"\n+ Tracks status and progress of video playbacks initiated by the addon and\n+ saves bookmarks and watched state for the associated items into the Kodi\n+ library.\n+ \"\"\"\nPROP_PLAYBACK_TRACKING = 'tracking'\n- def __init__(self, kodi_helper):\n+ def __init__(self, kodi_helper, log_fn=noop):\nsuper(KodiMonitor, self).__init__()\nself.kodi_helper = kodi_helper\nself.video_info = None\nself.progress = 0\n+ self.log = log_fn\n+\n+ def is_initialized_playback(self):\n+ \"\"\"\n+ Indicates if a playback was initiated by the netflix addon by\n+ checking the appropriate window property set by KodiHelper.\n+ \"\"\"\n+ return self._is_playback_status(self.kodi_helper.PROP_PLAYBACK_INIT)\n+\n+ def is_tracking_playback(self):\n+ \"\"\"\n+ Indicates if an ongoing playback is actively tracked by an\n+ instance of this class.\n+ \"\"\"\n+ return (self.video_info is not None and\n+ self._is_playback_status(self.PROP_PLAYBACK_TRACKING))\ndef update_playback_progress(self):\n- if self.video_info is not None:\n- player_id = self.get_active_video_player()\n+ \"\"\"\n+ Updates the internal progress status of a tracked playback\n+ and saves bookmarks to Kodi library.\n+ \"\"\"\n+ if not self.is_tracking_playback():\n+ return\n- if player_id is not None:\n- method = 'Player.GetProperties'\n- params = {\n+ player_id = self._get_active_video_player()\n+ try:\n+ progress = self._json_rpc('Player.GetProperties', {\n'playerid': player_id,\n'properties': ['percentage', 'time']\n- }\n-\n- response = self.json_rpc(method, params)\n-\n- if 'result' in response:\n- self.progress = response['result']['percentage']\n- self.kodi_helper.log(\n- msg='Current playback progress is {}%'.format(\n- self.progress)\n- )\n- time = response['result']['time']\n- playtime_seconds = time['hours'] * 3600 + \\\n- time['minutes'] * 60 + time['seconds']\n- if self.save_resume_bookmark(\n- playtime_seconds,\n- self.video_info['dbtype'],\n- self.video_info['dbid']\n- ):\n- self.kodi_helper.log(\n- msg='Saved bookmark at {} seconds'.format(\n- playtime_seconds)\n- )\n- else:\n- self.kodi_helper.log(\n- msg='Could not save bookmark',\n- level=xbmc.LOGWARNING\n- )\n- else:\n- self.kodi_helper.log(\n- msg='Could not update playback progress'\n- )\n+ })\n+ except IOError:\n+ return\n+ playtime_seconds = (progress['time']['hours'] * 3600 +\n+ progress['time']['minutes'] * 60 +\n+ progress['time']['seconds'])\n+ self._update_item_details({'resume': {'position': playtime_seconds}})\n+ self.progress = progress['percentage']\ndef onNotification(self, sender, method, data):\n+ \"\"\"\n+ Callback for Kodi notifications that handles and dispatches playback\n+ started and playback stopped events.\n+ \"\"\"\n+ # pylint: disable=unused-argument, invalid-name\ndata = json.loads(unicode(data, 'utf-8', errors='ignore'))\n-\nif method == 'Player.OnPlay':\n- self.on_playback_started(data.get('item', None))\n+ self._on_playback_started(data.get('item', None))\nelif method == 'Player.OnStop':\n- self.on_playback_stopped(data['end'])\n+ self._on_playback_stopped()\n- def on_playback_started(self, item):\n- self.kodi_helper.log(\n- msg='Playback started, waiting for player - item: {}'.format(item)\n- )\n-\n- # wait for player to start playing video\n- xbmc.sleep(3000)\n- player_id = self.get_active_video_player()\n- retries = 0\n-\n- while player_id is None and retries < 3:\n- # wait and retry up to three times if player is very slow\n+ @log\n+ def _on_playback_started(self, item):\n+ for _ in range(1, 5):\nxbmc.sleep(3000)\n- player_id = self.get_active_video_player()\n- retries += 1\n+ player_id = self._get_active_video_player()\n+ if player_id is not None:\n+ break\n- if self.is_initialized_playback() and player_id is not None:\n- self.video_info = self.get_video_info(player_id, item)\n+ if player_id is not None and self.is_initialized_playback():\n+ self.video_info = self._get_video_info(player_id, item)\nself.progress = 0\nxbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\nself.kodi_helper.PROP_NETFLIX_PLAY,\n- self.PROP_PLAYBACK_TRACKING\n- )\n+ self.PROP_PLAYBACK_TRACKING)\n+ self.log('Tracking playback of {}'.format(self.video_info))\nelse:\n- # Clean up remnants from unproperly stopped previous playbacks\n+ # Clean up remnants from improperly stopped previous playbacks.\n+ # Clearing the window property does not work as expected, thus\n+ # we overwrite it with an arbitrary value\nxbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\nself.kodi_helper.PROP_NETFLIX_PLAY, 'notnetflix')\n- self.kodi_helper.log(\n- msg='Playback is not from Netflix or it suddenly stopped'\n- )\n-\n- def on_playback_stopped(self, ended):\n- if self.video_info is not None and self.is_tracking_playback():\n- self.kodi_helper.log(msg='Netflix playback stopped')\n-\n+ reason = ('Playback not initiated by netflix plugin'\n+ if self.is_initialized_playback() else\n+ 'Unable to obtain active video player')\n+ self.log('Not tracking playback: {}'.format(reason))\n+\n+ @log\n+ def _on_playback_stopped(self):\n+ if self.is_tracking_playback():\nif self.progress >= 90:\n- self.increment_playcount(\n- self.video_info['dbtype'],\n- self.video_info['dbid'],\n- self.video_info['playcount']\n- )\n- else:\n- self.kodi_helper.log(\n- msg='Progress insufficient, not marking as watched'\n- )\n+ new_playcount = self.video_info.get('playcount', 0) + 1\n+ self._update_item_details({'playcount': new_playcount})\n+ action = 'marking {} as watched.'.format(self.video_info)\nelse:\n- self.kodi_helper.log(msg='Playback was not from Netflix')\n+ action = ('not marking {} as watched, progress too little'\n+ .format(self.video_info))\n+ self.log('Tracked playback stopped: {}'.format(action))\nxbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).setProperty(\nself.kodi_helper.PROP_NETFLIX_PLAY, 'stopped')\nself.video_info = None\nself.progress = 0\n- def increment_playcount(self, dbtype, dbid, playcount=0):\n- new_playcount = playcount + 1\n-\n- self.kodi_helper.log(\n- msg='Incrementing playcount of {} with dbid {} to {}'.format(\n- dbtype, dbid, new_playcount),\n- level=xbmc.LOGNOTICE\n- )\n-\n- method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n- params = {\n- '{}id'.format(dbtype): dbid,\n- 'playcount': new_playcount\n- }\n-\n- return self.is_ok(self.json_rpc(method, params))\n+ def _get_active_video_player(self):\n+ return next((player['playerid']\n+ for player in self._json_rpc('Player.GetActivePlayers')\n+ if player['type'] == 'video'), None)\n- def save_resume_bookmark(self, time, dbtype, dbid):\n- method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n- params = {\n- '{}id'.format(dbtype): dbid,\n- 'resume': {'position': time}\n- }\n-\n- return self.is_ok(self.json_rpc(method, params))\n-\n- def get_active_video_player(self):\n- method = 'Player.GetActivePlayers'\n- resp = self.json_rpc(method)\n-\n- if 'result' in resp:\n- for player in resp['result']:\n- if player['type'] == 'video':\n- return player['playerid']\n-\n- return None\n-\n- def get_video_info(self, player_id, fallback_data):\n- method = 'Player.GetItem'\n- params = {\n+ @log\n+ def _get_video_info(self, player_id, fallback_data):\n+ info = self._json_rpc('Player.GetItem',\n+ {\n'playerid': player_id,\n- 'properties': [\n- 'playcount',\n- 'title',\n- 'year',\n- 'tvshowid',\n- 'showtitle',\n- 'season',\n- 'episode'\n- ]\n- }\n-\n- resp = self.json_rpc(method, params)\n- item = None\n-\n- if 'result' in resp and 'item' in resp['result']:\n- item = resp['result']['item']\n-\n- self.kodi_helper.log(\n- msg=u'Got info from player: {}'.format(item)\n- )\n-\n- dbid = item.get('id', None)\n- dbtype = item.get('type', None)\n-\n- if dbtype is not None and dbid is not None:\n- playcount = item['playcount']\n- video_info = {\n- 'dbtype': dbtype,\n- 'dbid': dbid,\n- 'playcount': playcount\n- }\n- self.kodi_helper.log(\n- msg='Found video info from player: {}'.format(video_info)\n- )\n-\n- if video_info['dbtype'] in ['episode', 'movie']:\n- return video_info\n- else:\n- self.kodi_helper.log(msg='Not playing an episode or movie')\n- return None\n-\n- video_info = self.get_video_info_fallback(item, fallback_data)\n-\n+ 'properties': ['playcount', 'title', 'year',\n+ 'tvshowid', 'showtitle',\n+ 'season', 'episode']\n+ }).get('item', {})\n+ try:\n+ return {'dbtype': info['type'], 'dbid': info['id'],\n+ 'playcount': info.get('playcount', 0)}\n+ except KeyError:\n+ video_info = (self._guess_episode(info, fallback_data) or\n+ self._guess_movie(info, fallback_data))\nif video_info is not None:\n- self.kodi_helper.log(\n- msg='Found video info by fallback: {}'.format(video_info)\n- )\n+ self.log('Obtained video info by guessing: {}'\n+ .format(video_info))\nelse:\n- self.kodi_helper.log(\n- msg='Could not get video info',\n- level=xbmc.LOGERROR\n- )\n-\n+ self.log('Unable to obtain video info.', xbmc.LOGERROR)\nreturn video_info\n- def get_video_info_fallback(self, item, fallback_data):\n- \"\"\"\n- Finds video info using a more inaccurate matching approach. Tries to\n- use as much info returned by the player in `item` to do the lookup.\n- If that fails, the most generic fallback is used by just matching\n- against titles / show names and season episode numbers.\"\"\"\n-\n- if (item is not None or\n- (fallback_data is not None and 'title' in fallback_data)):\n- self.kodi_helper.log(\n- msg='Using inaccurate fallback lookup method for video info',\n- level=xbmc.LOGWARNING\n- )\n-\n- # Kinda weird way to prevent duplicate code, feel free to improve:\n- # If there's a dbtype given, we want to use the associated lookup\n- # function first, to save time. If it returns None, we still want\n- # the other one to be called.\n- dbtype = item.get('type', 'episode')\n- if dbtype not in ['episode', 'movie']:\n- # Coerce into known value\n- dbtype = 'episode'\n- other_dbtype = ['episode', 'movie']\n- other_dbtype.remove(dbtype)\n- other_dbtype = other_dbtype[0]\n- self.kodi_helper.log(\n- msg='Lookup priority: 1) {} 2) {}'.format(dbtype, other_dbtype)\n- )\n- lookup_functions = {\n- 'episode': self.find_episode_info,\n- 'movie': self.find_movie_info\n- }\n-\n- return (\n- lookup_functions[dbtype](item, fallback_data) or\n- lookup_functions[other_dbtype](item, fallback_data)\n- )\n- else:\n- return None\n-\n- def find_episode_info(self, item, fallback_data):\n- method = 'VideoLibrary.GetEpisodes'\n- params = {\n- 'properties': [\n- 'playcount',\n- 'tvshowid',\n- 'showtitle',\n- 'season',\n- 'episode'\n- ]\n- }\n-\n- showtitle = None\n- tvshowid = None\n- season = None\n- episode = None\n- title = None\n-\n- if item is not None:\n- if 'tvshowid' in item and item['tvshowid'] > 0:\n- tvshowid = item['tvshowid']\n- if 'showtitle' in item and item['showtitle']:\n- showtitle = item['showtitle']\n- if 'season' in item and item['season'] > 0:\n- season = item['season']\n- if 'episode' in item and item['episode'] > 0:\n- episode = item['episode']\n- if 'label' in item and item['label']:\n- title = item['label']\n- elif fallback_data is not None:\n- title = fallback_data.get('title', '')\n-\n- resp = self.json_rpc(method, params)\n-\n- if 'result' in resp and 'episodes' in resp['result']:\n- for episode in resp['result']['episodes']:\n- episode_meta = 'S%02dE%02d' % (\n- episode['season'],\n- episode['episode']\n- )\n-\n- if ((tvshowid == episode['tvshowid'] or\n- showtitle == episode['showtitle']) and\n- season == episode['season'] and\n- episode == episode['episode'] or\n- (episode_meta in title and\n- episode['showtitle'] in title)):\n- return {\n- 'dbtype': 'episode',\n- 'dbid': episode['episodeid'],\n- 'playcount': episode['playcount']\n- }\n- else:\n+ @log\n+ def _guess_episode(self, item, fallback_data):\n+ title = _get_safe_with_fallback(item, fallback_data, itemkey='label')\n+ resp = self._json_rpc('VideoLibrary.GetEpisodes',\n+ {'properties': ['playcount', 'tvshowid',\n+ 'showtitle', 'season',\n+ 'episode']})\n+ for episode in resp.get('episodes', []):\n+ try:\n+ matches_show = (item.get('tvshowid') == episode['tvshowid'] or\n+ item.get('showtitle') == episode['showtitle'])\n+ matches_season = item.get('season') == episode['season']\n+ matches_episode = item.get('episode') == episode['episode']\n+ matches_explicitly = (matches_show and matches_season and\n+ matches_episode)\n+ except AttributeError:\n+ matches_explicitly = False\n+\n+ episode_meta = 'S%02dE%02d' % (episode['season'],\n+ episode['episode'])\n+ matches_meta = (episode['showtitle'] in title and\n+ episode_meta in title)\n+\n+ if matches_explicitly or matches_meta:\n+ return {'dbtype': 'episode', 'dbid': episode['episodeid'],\n+ 'playcount': episode['playcount']}\nreturn None\n- def find_movie_info(self, item, fallback_data):\n- method = 'VideoLibrary.GetMovies'\n- params = {\n- 'properties': ['playcount', 'year', 'title']\n- }\n-\n- title = ''\n-\n- if item is not None:\n- title = item.get(\n- 'title',\n- fallback_data.get(\n- 'title',\n- ''\n- ) if fallback_data is not None else ''\n- )\n-\n- if 'year' in item:\n+ @log\n+ def _guess_movie(self, item, fallback_data):\n+ title = _get_safe_with_fallback(item, fallback_data)\n+ params = {'properties': ['playcount', 'year', 'title']}\n+ try:\nparams['filter'] = {'year': item['year']}\n-\n- resp = self.json_rpc(method, params)\n-\n- if 'result' in resp and 'movies' in resp['result']:\n- for movie in resp['result']['movies']:\n+ except (TypeError, KeyError):\n+ pass\n+ resp = self._json_rpc('VideoLibrary.GetMovies', params)\n+ for movie in resp.get('movies', []):\nmovie_meta = '%s (%d)' % (movie['label'], movie['year'])\n- self.kodi_helper.log(u'Matching {}'.format(movie_meta))\nif movie_meta == title or movie['label'] in title:\n- return {\n- 'dbtype': 'movie',\n- 'dbid': movie['movieid'],\n- 'playcount': movie['playcount']\n- }\n- else:\n+ return {'dbtype': 'movie', 'dbid': movie['movieid'],\n+ 'playcount': movie['playcount']}\nreturn None\n- def is_initialized_playback(self):\n- return self.is_playback_status(self.kodi_helper.PROP_PLAYBACK_INIT)\n-\n- def is_tracking_playback(self):\n- return self.is_playback_status(self.PROP_PLAYBACK_TRACKING)\n+ def _update_item_details(self, properties):\n+ method = ('VideoLibrary.Set{}Details'\n+ .format(self.video_info['dbtype'].capitalize()))\n+ params = {'{}id'.format(self.video_info['dbtype']):\n+ self.video_info['dbid']}\n+ params.update(properties)\n+ self._json_rpc(method, params)\n- def is_playback_status(self, status):\n+ def _is_playback_status(self, status):\nreturn xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).getProperty(\n- self.kodi_helper.PROP_NETFLIX_PLAY\n- ) == status\n-\n- def json_rpc(self, method, params=None):\n- req = {\n- 'jsonrpc': '2.0',\n- 'method': method,\n- 'id': 1,\n- 'params': params or {}\n- }\n-\n- jsonrequest = json.dumps(req)\n- self.kodi_helper.log(msg=u'Sending request: {}'.format(jsonrequest))\n-\n- jsonresponse = unicode(\n- xbmc.executeJSONRPC(jsonrequest),\n- 'utf-8',\n- errors='ignore'\n- )\n- self.kodi_helper.log(msg=u'Received response: {}'.format(jsonresponse))\n-\n- return json.loads(jsonresponse)\n-\n- def is_ok(self, jsonrpc_response):\n- return (\n- 'result' in jsonrpc_response and\n- jsonrpc_response['result'] == 'OK'\n- )\n+ self.kodi_helper.PROP_NETFLIX_PLAY) == status\n+\n+ def _json_rpc(self, method, params=None):\n+ request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n+ 'params': params or {}}\n+ request = json.dumps(request_data)\n+ self.log(u'Sending request: {}'.format(request))\n+ response = json.loads(unicode(xbmc.executeJSONRPC(request), 'utf-8',\n+ errors='ignore'))\n+ self.log(u'Received response: {}'.format(response))\n+ if 'error' in response:\n+ raise IOError('JSONRPC-Error {}: {}'\n+ .format(response['error']['code'],\n+ response['error']['message']))\n+ return response['result']\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -56,7 +56,7 @@ NS_SERVER.server_activate()\nNS_SERVER.timeout = 1\nif __name__ == '__main__':\n- MONITOR = KodiMonitor(KODI_HELPER)\n+ MONITOR = KodiMonitor(KODI_HELPER, KODI_HELPER.log)\n# start thread for MLS servie\nMSL_THREAD = threading.Thread(target=MSL_SERVER.serve_forever)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Code cleanup and improve code climate |
105,989 | 21.03.2018 23:17:42 | -3,600 | 9247518182e42babf1f716da4695553449cdedc7 | Fix KeyError when setting art received via JSON-RPC and reset bookmark when marking as watched (to show proper indicator in default skin) | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1540,18 +1540,22 @@ class KodiHelper(object):\nin_episode = episode['episode'] == showepisode\nif in_season and in_episode:\ninfos = {'mediatype': 'episode', 'dbid': episode['episodeid']}\n- if 'resume' in episode and episode['resume']['position'] > 0:\n+ if episode['resume']['position'] > 0:\ninfos['resume'] = episode['resume']['position']\n- if 'plot' in episode and len(episode['plot']) > 0:\n- infos.update({\n- 'plot': episode['plot'],\n- 'genre': showid[1]})\n+ infos.update({'plot': episode['plot'],\n+ 'genre': showid[1]}\n+ if episode.get('plot') else {})\n+\nart = {}\n- if 'fanart' in episode and len(episode['fanart']) > 0:\n- art.update({'fanart': episode['fanart']})\n- if 'art' in episode and len(episode['art']['season.poster']) > 0:\n- art.update({\n- 'thumb': episode['art']['season.poster']})\n+ art.update({'fanart': episode['fanart']}\n+ if episode.get('fanart') else {})\n+ if 'art' in episode:\n+ if episode['art'].get('thumb'):\n+ art.update({'thumb': episode['art']['thumb']})\n+ if episode['art'].get('tvshow.poster'):\n+ art.update({'poster': episode['art']['tvshow.poster']})\n+ if episode['art'].get('tvshow.banner'):\n+ art.update({'banner': episode['art']['tvshow.banner']})\nreturn infos, art\nreturn False\nexcept Exception:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -117,7 +117,8 @@ class KodiMonitor(xbmc.Monitor):\nif self.is_tracking_playback():\nif self.progress >= 90:\nnew_playcount = self.video_info.get('playcount', 0) + 1\n- self._update_item_details({'playcount': new_playcount})\n+ self._update_item_details({'playcount': new_playcount,\n+ 'resume': {'position': 0}})\naction = 'marking {} as watched.'.format(self.video_info)\nelse:\naction = ('not marking {} as watched, progress too little'\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix KeyError when setting art received via JSON-RPC and reset bookmark when marking as watched (to show proper indicator in default skin) |
105,989 | 21.03.2018 23:32:14 | -3,600 | ad0a5be4980c2fc9969a864284c5579781d9f2be | Fixed KeyError when quality information is not provided | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1232,6 +1232,7 @@ class KodiHelper(object):\nli.setInfo('video', infos)\nif li_infos.get('is_playable'):\nli.setProperty('IsPlayable', 'true')\n+ if 'quality' in li_infos:\nli.addStreamInfo('video', li_infos['quality'])\nreturn li, infos\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed KeyError when quality information is not provided |
105,989 | 22.03.2018 17:29:13 | -3,600 | 40f93b223710f5d2d929aa076945d6aa2e8637b5 | More codeclimate | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -52,55 +52,62 @@ def _get_active_video_player():\nNone)\n-def _match_episode(item, episode, fallback_data):\n- title = _get_safe_with_fallback(item, fallback_data, itemkey='label')\n+def _first_match_or_none(mediatype, item, candidates, item_fb, match_fn):\n+ return next(({'dbtype': mediatype,\n+ 'dbid': candidate['{}id'.format(mediatype)],\n+ 'playcount': candidate['playcount']}\n+ for candidate in candidates\n+ if match_fn(item, candidate, item_fb)),\n+ None)\n+\n+\n+def _match_movie(item, movie, fallback_data):\n+ title = _get_safe_with_fallback(item, fallback_data)\n+ movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n+ return movie_meta == title or movie['label'] in title\n+\n+\n+def _match_episode_explicitly(item, candidate):\ntry:\n- matches_show = (item.get('tvshowid') == episode['tvshowid'] or\n- item.get('showtitle') == episode['showtitle'])\n- matches_season = item.get('season') == episode['season']\n- matches_episode = item.get('episode') == episode['episode']\n- matches_explicitly = (matches_show and matches_season and\n- matches_episode)\n+ matches_show = (item.get('tvshowid') == candidate['tvshowid'] or\n+ item.get('showtitle') == candidate['showtitle'])\n+ matches_season = item.get('season') == candidate['season']\n+ matches_episode = item.get('episode') == candidate['episode']\n+ return matches_show and matches_season and matches_episode\nexcept AttributeError:\n- matches_explicitly = False\n+ return False\n+\n- episode_meta = 'S%02dE%02d' % (episode['season'],\n- episode['episode'])\n- matches_meta = (episode['showtitle'] in title and\n- episode_meta in title)\n- return matches_explicitly or matches_meta\n+def _match_episode_by_title(title, candidate):\n+ episode_meta = 'S%02dE%02d' % (candidate['season'],\n+ candidate['episode'])\n+ return candidate['showtitle'] in title and episode_meta in title\n-def _guess_episode(item, fallback_data):\n+def _match_episode(item, candidate, item_fb):\n+ title = _get_safe_with_fallback(item, item_fb, itemkey='label')\n+ return (_match_episode_explicitly(item, candidate) or\n+ _match_episode_by_title(title, candidate))\n+\n+\n+def _guess_episode(item, item_fb):\nresp = _json_rpc('VideoLibrary.GetEpisodes',\n{'properties': ['playcount', 'tvshowid',\n'showtitle', 'season',\n'episode']})\n- return next(({'dbtype': 'episode', 'dbid': episode['episodeid'],\n- 'playcount': episode['playcount']}\n- for episode in resp.get('episodes', [])\n- if _match_episode(item, episode, fallback_data)),\n- None)\n+ return _first_match_or_none('episode', item, resp.get('episodes', []),\n+ item_fb, _match_episode)\n-def _match_movie(item, movie, fallback_data):\n- title = _get_safe_with_fallback(item, fallback_data)\n- movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n- return movie_meta == title or movie['label'] in title\n-\n-\n-def _guess_movie(item, fallback_data):\n+def _guess_movie(item, item_fb):\nparams = {'properties': ['playcount', 'year', 'title']}\ntry:\nparams['filter'] = {'year': item['year']}\nexcept (TypeError, KeyError):\npass\nresp = _json_rpc('VideoLibrary.GetMovies', params)\n- return next(({'dbtype': 'movie', 'dbid': movie['movieid'],\n- 'playcount': movie['playcount']}\n- for movie in resp.get('movies', [])\n- if _match_movie(item, movie, fallback_data)),\n- None)\n+ return _first_match_or_none('movie', item, resp.get('movies', []),\n+ item_fb, _match_movie)\nclass KodiMonitor(xbmc.Monitor):\n@@ -134,13 +141,14 @@ class KodiMonitor(xbmc.Monitor):\nreturn (self.video_info is not None and\nself._is_playback_status(self.PROP_PLAYBACK_TRACKING))\n+ @log\ndef update_playback_progress(self):\n\"\"\"\nUpdates the internal progress status of a tracked playback\nand saves bookmarks to Kodi library.\n\"\"\"\nif not self.is_tracking_playback():\n- return\n+ return None\nplayer_id = _get_active_video_player()\ntry:\n@@ -149,12 +157,12 @@ class KodiMonitor(xbmc.Monitor):\n'properties': ['percentage', 'time']\n})\nexcept IOError:\n- return\n- playtime_seconds = (progress['time']['hours'] * 3600 +\n+ return None\n+ elapsed = (progress['time']['hours'] * 3600 +\nprogress['time']['minutes'] * 60 +\nprogress['time']['seconds'])\n- self._update_item_details({'resume': {'position': playtime_seconds}})\nself.progress = progress['percentage']\n+ return self._update_item_details({'resume': {'position': elapsed}})\ndef onNotification(self, sender, method, data):\n\"\"\"\n@@ -221,17 +229,10 @@ class KodiMonitor(xbmc.Monitor):\nreturn {'dbtype': info['type'], 'dbid': info['id'],\n'playcount': info.get('playcount', 0)}\nexcept KeyError:\n- video_info = (self._guess_episode(info, fallback_data) or\n- self._guess_movie(info, fallback_data))\n- if video_info is None:\n- self.log('Unable to obtain video info (fallback_data={})'\n- .format(fallback_data),\n- xbmc.LOGERROR)\n- else:\n- self.log('Obtained video info by guessing ({})'\n- .format(video_info),\n+ self.log('Guessing video info (fallback={})'.format(fallback_data),\nxbmc.LOGWARNING)\n- return video_info\n+ return (self._guess_episode(info, fallback_data) or\n+ self._guess_movie(info, fallback_data))\n@log\ndef _update_item_details(self, properties):\n@@ -240,7 +241,7 @@ class KodiMonitor(xbmc.Monitor):\nparams = {'{}id'.format(self.video_info['dbtype']):\nself.video_info['dbid']}\nparams.update(properties)\n- _json_rpc(method, params)\n+ return _json_rpc(method, params)\ndef _is_playback_status(self, status):\nreturn xbmcgui.Window(self.kodi_helper.TAGGED_WINDOW_ID).getProperty(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | More codeclimate |
105,989 | 22.03.2018 18:27:11 | -3,600 | b9ceaf63738b4e48bcfe9ec87a1601d42499902b | Also attach title (and tvshowtitle if episode) from database to infoLabels | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -1523,7 +1523,8 @@ class KodiHelper(object):\ndef get_show_content_by_id(self, showid, showseason, showepisode):\nshowseason = int(showseason)\nshowepisode = int(showepisode)\n- props = [\"season\", \"episode\", \"plot\", \"fanart\", \"art\", \"resume\"]\n+ props = [\"title\", \"showtitle\", \"season\", \"episode\", \"plot\", \"fanart\",\n+ \"art\", \"resume\"]\nquery = {\n\"jsonrpc\": \"2.0\",\n\"method\": \"VideoLibrary.GetEpisodes\",\n@@ -1545,7 +1546,9 @@ class KodiHelper(object):\nin_episode = episode['episode'] == showepisode\nif in_season and in_episode:\ninfos = {'mediatype': 'episode',\n- 'dbid': episode['episodeid']}\n+ 'dbid': episode['episodeid'],\n+ 'tvshowtitle': episode['showtitle'],\n+ 'title': episode['title']}\nif episode['resume']['position'] > 0:\ninfos['resume'] = episode['resume']['position']\ninfos.update({'plot': episode['plot'],\n@@ -1579,6 +1582,7 @@ class KodiHelper(object):\n\"params\": {\n\"movieid\": movieid,\n\"properties\": [\n+ \"title\",\n\"genre\",\n\"plot\",\n\"fanart\",\n@@ -1595,7 +1599,8 @@ class KodiHelper(object):\nresult = json_result.get('result', None)\nif result is not None and 'moviedetails' in result:\nresult = result.get('moviedetails', {})\n- infos = {'mediatype': 'movie', 'dbid': movieid}\n+ infos = {'mediatype': 'movie', 'dbid': movieid,\n+ 'title': result['title']}\nif 'resume' in result:\ninfos.update('resume', result['resume'])\nif 'genre' in result and len(result['genre']) > 0:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Also attach title (and tvshowtitle if episode) from database to infoLabels |
106,018 | 22.03.2018 18:58:48 | -3,600 | 47bd3ed3d2c8037c8597c543e6ac6a262b2ea05a | add view for exported | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -267,3 +267,8 @@ msgstr \"\"\nmsgctxt \"#30062\"\nmsgid \"Enable/disable adult pin. Active:\"\nmsgstr \"\"\n+\n+msgctxt \"#30065\"\n+msgid \"View for exported\"\n+msgstr \"\"\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -38,6 +38,7 @@ VIEW_MOVIE = 'movie'\nVIEW_SHOW = 'show'\nVIEW_SEASON = 'season'\nVIEW_EPISODE = 'episode'\n+VIEW_EXPORTED = 'exported'\nCONTENT_FOLDER = 'files'\nCONTENT_MOVIE = 'movies'\n@@ -383,7 +384,7 @@ class KodiHelper(object):\ncontent : :obj:`str`\nType of content in container\n- (folder, movie, show, season, episode, login)\n+ (folder, movie, show, season, episode, login, exported)\n\"\"\"\ncustom_view = self.get_addon().getSetting('customview')\n@@ -780,7 +781,7 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_FOLDER)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n- self.set_custom_view(VIEW_FOLDER)\n+ self.set_custom_view(VIEW_EXPORTED)\nreturn True\ndef build_search_result_folder(self, build_url, term):\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"viewmodeshow\" type=\"number\" label=\"30041\" enable=\"eq(-4,true)\" default=\"504\"/>\n<setting id=\"viewmodeseason\" type=\"number\" label=\"30042\" enable=\"eq(-5,true)\" default=\"504\"/>\n<setting id=\"viewmodeepisode\" type=\"number\" label=\"30043\" enable=\"eq(-6,true)\" default=\"55\"/>\n+ <setting id=\"viewmodeexported\" type=\"number\" label=\"30065\" enable=\"eq(-7,true)\" default=\"504\"/>\n</category>\n<category label=\"30023\">\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | add view for exported |
105,989 | 20.03.2018 11:36:20 | -3,600 | d5444adc3f21e3e087e7a25199246051a06e8e93 | Add updates of exported shows (export new episodes to library) | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -267,3 +267,11 @@ msgstr \"\"\nmsgctxt \"#30062\"\nmsgid \"Enable/disable adult pin. Active:\"\nmsgstr \"\"\n+\n+msgctxt \"#30063\"\n+msgid \"new episodes added to library\"\n+msgstr \"\"\n+\n+msgctxt \"#30064\"\n+msgid \"Export new episodes\"\n+msgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -82,6 +82,7 @@ class KodiHelper(object):\nself.custom_export_name = addon.getSetting('customexportname')\nself.show_update_db = addon.getSetting('show_update_db')\nself.default_fanart = addon.getAddonInfo('fanart')\n+ self.icon = addon.getAddonInfo('icon')\nself.bs = 32\nself.crypt_key = uniq_id()\nself.library = None\n@@ -719,6 +720,15 @@ class KodiHelper(object):\nList could be build\n\"\"\"\naction = ['remove_from_library', self.get_local_string(30030), 'remove']\n+\n+ xbmcplugin.addDirectoryItem(\n+ handle=self.plugin_handle,\n+ url=build_url({'action': 'export-new-episodes',\n+ 'inbackground': True}),\n+ listitem=xbmcgui.ListItem(\n+ label=self.get_local_string(30030),\n+ iconImage=self.default_fanart),\n+ isFolder=False)\nlisting = content\nfor video in listing[0]:\nyear = self.library.get_exported_movie_year(title=video)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -7,6 +7,7 @@ import os\nimport re\nimport time\nimport threading\n+import xbmc\nimport xbmcgui\nimport xbmcvfs\nimport requests\n@@ -370,7 +371,8 @@ class Library(object):\ntime.sleep(1)\nprogress.close()\n- def add_show(self, title, alt_title, episodes, build_url):\n+ def add_show(self, netflix_id, title, alt_title, episodes, build_url,\n+ in_background=False):\n\"\"\"Adds a show to the local db, generates & persists the strm files\nNote: Can also used to store complete seasons or single episodes,\n@@ -395,18 +397,22 @@ class Library(object):\nfolder = re.sub(r'[?|$|!|:|#]', r'', alt_title.encode('utf-8'))\nshow_dir = self.kodi_helper.check_folder_path(\npath=os.path.join(self.tvshow_path, folder))\n- progress = xbmcgui.DialogProgress()\n+ progress = self._create_progress_dialog(in_background)\nprogress.create(self.kodi_helper.get_local_string(650), show_meta)\n- count = 1\nif not xbmcvfs.exists(show_dir):\nxbmcvfs.mkdirs(show_dir)\nif self.show_exists(title) is False:\nself.db[self.series_label][show_meta] = {\n+ 'netflix_id': netflix_id,\n'seasons': [],\n'episodes': [],\n'alt_title': alt_title}\n- episode_count_total = len(episodes)\n- step = round(100.0 / episode_count_total, 1)\n+ episodes = [episode for episode in episodes\n+ if not self.episode_exists(title, episode['season'],\n+ episode['episode'])]\n+ if len(episodes) == 0:\n+ return False\n+ step = round(100.0 / len(episodes), 1)\npercent = step\nfor episode in episodes:\ndesc = self.kodi_helper.get_local_string(20373) + ': '\n@@ -430,8 +436,26 @@ class Library(object):\nself._update_local_db(filename=self.db_filepath, db=self.db)\ntime.sleep(1)\nprogress.close()\n+ if in_background:\n+ self.kodi_helper.dialogs.show_episodes_added_notify(\n+ title, len(episodes), self.kodi_helper.icon)\nreturn show_dir\n+ def _create_progress_dialog(self, is_noop):\n+ if is_noop:\n+ class NoopDialog():\n+ def create(self, title, subtitle):\n+ return noop()\n+\n+ def update(self, **kwargs):\n+ return noop()\n+\n+ def close(self):\n+ return noop()\n+\n+ return NoopDialog()\n+ return xbmcgui.DialogProgress()\n+\ndef _add_episode(self, title, show_dir, season, episode, video_id, build_url):\n\"\"\"\nAdds a single episode to the local DB,\n@@ -659,6 +683,9 @@ class Library(object):\nshows = xbmcvfs.listdir(tvshow_path)\nreturn movies + shows\n+ def list_exported_shows(self):\n+ return self.db[self.series_label]\n+\ndef get_exported_movie_year(self, title):\n\"\"\"Return year of given exported movie\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -180,6 +180,8 @@ class Navigation(object):\nself.library.remove_show(title=params['title'].decode('utf-8'))\nself.kodi_helper.refresh()\nreturn True\n+ elif action == 'export-new-episodes':\n+ return self.export_new_episodes()\nelif action == 'updatedb':\n# adds a title to the users list on Netflix\nself.library.updatedb_from_exported()\n@@ -544,7 +546,7 @@ class Navigation(object):\nreturn self.kodi_helper.dialogs.show_request_error_notify()\n@log\n- def export_to_library(self, video_id, alt_title):\n+ def export_to_library(self, video_id, alt_title, in_background=False):\n\"\"\"Adds an item to the local library\nParameters\n@@ -576,10 +578,12 @@ class Navigation(object):\n'episode': episode['seq'],\n'id': episode['id']})\nself.library.add_show(\n+ netflix_id=video_id,\ntitle=video['title'],\nalt_title=alt_title,\nepisodes=episodes,\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ in_background=in_background)\nreturn True\nself.kodi_helper.dialogs.show_no_metadata_notify()\nreturn False\n@@ -608,6 +612,25 @@ class Navigation(object):\nself.kodi_helper.dialogs.show_no_metadata_notify()\nreturn False\n+ @log\n+ def export_new_episodes(self):\n+ no_errors = True\n+ for title, meta in self.library.list_exported_shows().iteritems():\n+ try:\n+ self.log('Exporting new episodes of {} (id={})'\n+ .format(title, meta['netflix_id']))\n+ self.export_to_library(\n+ video_id=meta['netflix_id'], alt_title=title,\n+ in_background=params.get('inbackground', False))\n+ except KeyError:\n+ no_errors = False\n+ self.log(\n+ ('Missing netflix_id for {}. Remove and re-add to '\n+ 'library to fix this.').format(title), xbmc.LOGERROR)\n+ xbmc.executebuiltin(\n+ 'UpdateLibrary(video, {})'.format(self.library.tvshow_path))\n+ return no_errors\n+\n@log\ndef establish_session(self, account):\n\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/Dialogs.py",
"new_path": "resources/lib/kodi/Dialogs.py",
"diff": "@@ -231,6 +231,21 @@ class Dialogs(object):\ntime=self.notify_time)\nreturn dialog\n+ def show_episodes_added_notify(self, showtitle, episodes, icon):\n+ \"\"\"\n+ Shows notification that new episodes were added to the library\n+\n+ :returns: bool - Dialog shown\n+ \"\"\"\n+ dlg = xbmcgui.Dialog()\n+ dialog = dlg.notification(\n+ heading=showtitle,\n+ message='{} {}'.format(episodes,\n+ self.get_local_string(string_id=30063)),\n+ icon=icon,\n+ time=self.notify_time)\n+ return dialog\n+\ndef show_autologin_enabled_notify(self):\n\"\"\"\nShows notification that auto login is enabled\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add updates of exported shows (export new episodes to library) |
105,989 | 24.03.2018 15:39:20 | -3,600 | 0c2249dd9624b92f8e140923a326960a90eac38e | Schedule updates and automatically trigger them | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -275,3 +275,43 @@ msgstr \"\"\nmsgctxt \"#30064\"\nmsgid \"Export new episodes\"\nmsgstr \"\"\n+\n+msgctxt \"#30064\"\n+msgid \"Export new episodes\"\n+msgstr \"\"\n+\n+msgctxt \"#30065\"\n+msgid \"Auto-update\"\n+msgstr \"\"\n+\n+msgctxt \"#30066\"\n+msgid \"never\"\n+msgstr \"\"\n+\n+msgctxt \"#30067\"\n+msgid \"daily\"\n+msgstr \"\"\n+\n+msgctxt \"#30068\"\n+msgid \"every other day\"\n+msgstr \"\"\n+\n+msgctxt \"#30069\"\n+msgid \"every 5 days\"\n+msgstr \"\"\n+\n+msgctxt \"#30070\"\n+msgid \"weekly\"\n+msgstr \"\"\n+\n+msgctxt \"#30071\"\n+msgid \"Time of Day\"\n+msgstr \"\"\n+\n+msgctxt \"#30072\"\n+msgid \"Only start after 5 minutes of idle\"\n+msgstr \"\"\n+\n+msgctxt \"#30073\"\n+msgid \"Check every X minutes if update scheduled\"\n+msgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -16,6 +16,7 @@ import json\nimport urllib\nimport urllib2\nfrom urlparse import parse_qsl, urlparse\n+from datetime import datetime\nimport xbmc\nfrom xbmcaddon import Addon\nimport resources.lib.NetflixSession as Netflix\n@@ -181,7 +182,7 @@ class Navigation(object):\nself.kodi_helper.refresh()\nreturn True\nelif action == 'export-new-episodes':\n- return self.export_new_episodes()\n+ return self.export_new_episodes(params.get('inbackground', False))\nelif action == 'updatedb':\n# adds a title to the users list on Netflix\nself.library.updatedb_from_exported()\n@@ -613,22 +614,27 @@ class Navigation(object):\nreturn False\n@log\n- def export_new_episodes(self):\n+ def export_new_episodes(self, in_background):\nno_errors = True\n+ update_started_at = datetime.today().strftime('%Y-%m-%d %H:%M')\n+ self.kodi_helper.set_setting('update_running', update_started_at)\nfor title, meta in self.library.list_exported_shows().iteritems():\ntry:\nself.log('Exporting new episodes of {} (id={})'\n.format(title, meta['netflix_id']))\nself.export_to_library(\nvideo_id=meta['netflix_id'], alt_title=title,\n- in_background=params.get('inbackground', False))\n+ in_background=in_background)\nexcept KeyError:\nno_errors = False\nself.log(\n- ('Missing netflix_id for {}. Remove and re-add to '\n- 'library to fix this.').format(title), xbmc.LOGERROR)\n+ ('Cannot export new episodes for {}, missing netflix_id. '\n+ 'Remove and re-add to library to fix this.')\n+ .format(title), xbmc.LOGERROR)\nxbmc.executebuiltin(\n'UpdateLibrary(video, {})'.format(self.library.tvshow_path))\n+ self.kodi_helper.set_setting('update_running', 'false')\n+ self.kodi_helper.set_setting('last_update', update_started_at[0:10])\nreturn no_errors\n@log\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<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=\"customexportname\" type=\"bool\" label=\"30036\" default=\"false\"/>\n+ <setting label=\"30065\" type=\"lsep\"/>\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</category>\n<category label=\"30037\">\n<setting id=\"customview\" type=\"bool\" label=\"30038\" default=\"false\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "import threading\nimport socket\nfrom SocketServer import TCPServer\n-from xbmc import Monitor\n+from datetime import datetime, timedelta\n+import xbmc\nfrom resources.lib.KodiHelper import KodiHelper\nfrom resources.lib.MSLHttpRequestHandler import MSLHttpRequestHandler\nfrom resources.lib.NetflixHttpRequestHandler import NetflixHttpRequestHandler\n@@ -29,60 +30,174 @@ def select_unused_port():\nreturn port\n+def strp(value, form):\n+ \"\"\"\n+ Helper function to safely create datetime objects from strings\n+\n+ :return: datetime - parsed datetime object\n+ \"\"\"\n+ # pylint: disable=broad-except\n+ from time import strptime\n+ def_value = datetime.utcfromtimestamp(0)\n+ try:\n+ return datetime.strptime(value, form)\n+ except TypeError:\n+ try:\n+ return datetime(*(strptime(value, form)[0:6]))\n+ except ValueError:\n+ return def_value\n+ except Exception:\n+ return def_value\n+\n+\n+class NetflixService(object):\n+ \"\"\"\n+ Netflix addon service\n+ \"\"\"\n+ def __init__(self):\n# init kodi helper (for logging)\n-KODI_HELPER = KodiHelper()\n+ self.kodi_helper = KodiHelper()\n+\n+ self.last_schedule_check = datetime.now()\n+ self.schedule_check_interval = int(self.kodi_helper.get_setting(\n+ 'schedule_check_interval'))\n+ self.startidle = 0\n+ self.freq = int('0' + self.kodi_helper.get_setting('auto_update'))\n# pick & store a port for the MSL service\n-MSL_PORT = select_unused_port()\n-KODI_HELPER.set_setting('msl_service_port', str(MSL_PORT))\n-KODI_HELPER.log(msg='[MSL] Picked Port: ' + str(MSL_PORT))\n+ msl_port = select_unused_port()\n+ self.kodi_helper.set_setting('msl_service_port', str(msl_port))\n+ self.kodi_helper.log(msg='[MSL] Picked Port: ' + str(msl_port))\n# pick & store a port for the internal Netflix HTTP proxy service\n-NS_PORT = select_unused_port()\n-KODI_HELPER.set_setting('netflix_service_port', str(NS_PORT))\n-KODI_HELPER.log(msg='[NS] Picked Port: ' + str(NS_PORT))\n+ ns_port = select_unused_port()\n+ self.kodi_helper.set_setting('netflix_service_port', str(ns_port))\n+ self.kodi_helper.log(msg='[NS] Picked Port: ' + str(ns_port))\n# server defaults\nTCPServer.allow_reuse_address = True\n# configure the MSL Server\n-MSL_SERVER = TCPServer(('127.0.0.1', MSL_PORT), MSLHttpRequestHandler)\n-MSL_SERVER.server_activate()\n-MSL_SERVER.timeout = 1\n+ self.msl_server = TCPServer(('127.0.0.1', msl_port),\n+ MSLHttpRequestHandler)\n+ self.msl_server.server_activate()\n+ self.msl_server.timeout = 1\n# configure the Netflix Data Server\n-NS_SERVER = TCPServer(('127.0.0.1', NS_PORT), NetflixHttpRequestHandler)\n-NS_SERVER.server_activate()\n-NS_SERVER.timeout = 1\n-\n-if __name__ == '__main__':\n- MONITOR = Monitor()\n+ self.ns_server = TCPServer(('127.0.0.1', ns_port),\n+ NetflixHttpRequestHandler)\n+ self.ns_server.server_activate()\n+ self.ns_server.timeout = 1\n+ def _start_servers(self):\n# start thread for MLS servie\n- MSL_THREAD = threading.Thread(target=MSL_SERVER.serve_forever)\n- MSL_THREAD.daemon = True\n- MSL_THREAD.start()\n+ msl_thread = threading.Thread(target=self.msl_server.serve_forever)\n+ msl_thread.daemon = True\n+ msl_thread.start()\n# start thread for Netflix HTTP service\n- NS_THREAD = threading.Thread(target=NS_SERVER.serve_forever)\n- NS_THREAD.daemon = True\n- NS_THREAD.start()\n-\n- # kill the services if kodi monitor tells us to\n- while not MONITOR.abortRequested():\n- if MONITOR.waitForAbort(5):\n- MSL_SERVER.shutdown()\n- NS_SERVER.shutdown()\n- break\n+ ns_thread = threading.Thread(target=self.ns_server.serve_forever)\n+ ns_thread.daemon = True\n+ ns_thread.start()\n+ def _shutdown(self):\n# MSL service shutdown sequence\n- MSL_SERVER.server_close()\n- MSL_SERVER.socket.close()\n- MSL_SERVER.shutdown()\n- KODI_HELPER.log(msg='Stopped MSL Service')\n+ self.msl_server.server_close()\n+ self.msl_server.socket.close()\n+ self.msl_server.shutdown()\n+ self.kodi_helper.log(msg='Stopped MSL Service')\n# Netflix service shutdown sequence\n- NS_SERVER.server_close()\n- NS_SERVER.socket.close()\n- NS_SERVER.shutdown()\n- KODI_HELPER.log(msg='Stopped HTTP Service')\n+ self.ns_server.server_close()\n+ self.ns_server.socket.close()\n+ self.ns_server.shutdown()\n+ self.kodi_helper.log(msg='Stopped HTTP Service')\n+\n+ def _is_idle(self):\n+ if self.kodi_helper.get_setting('wait_idle') != 'true':\n+ return True\n+\n+ lastidle = xbmc.getGlobalIdleTime()\n+ if xbmc.Player().isPlaying():\n+ self.startidle = lastidle\n+ if lastidle < self.startidle:\n+ self.startidle = 0\n+ idletime = lastidle - self.startidle\n+ return idletime >= 300\n+\n+ def _update_running(self):\n+ update = self.kodi_helper.get_setting('update_running') or 'false'\n+ if update != 'false':\n+ starttime = strp(update, '%Y-%m-%d %H:%M')\n+ if (starttime + timedelta(hours=6)) <= datetime.now():\n+ self.kodi_helper.set_setting('update_running', 'false')\n+ self.kodi_helper.log(\n+ 'Canceling previous library update - duration > 6 hours',\n+ xbmc.LOGWARNING)\n+ else:\n+ self.kodi_helper.log('DB Update already running')\n+ return True\n+ return False\n+\n+ def run(self):\n+ \"\"\"\n+ Main loop. Runs until xbmc.Monitor requests abort\n+ \"\"\"\n+ self._start_servers()\n+ monitor = xbmc.Monitor()\n+ while not monitor.abortRequested():\n+ try:\n+ if self.library_update_scheduled() and self._is_idle():\n+ self.update_library()\n+ except RuntimeError as exc:\n+ self.kodi_helper.log(\n+ 'RuntimeError: {}'.format(exc), xbmc.LOGERROR)\n+ if monitor.waitForAbort(5):\n+ break\n+ self._shutdown()\n+\n+ def library_update_scheduled(self):\n+ \"\"\"\n+ Checks if the scheduled time for a library update has been reached\n+ \"\"\"\n+ now = datetime.now()\n+ next_schedule_check = (self.last_schedule_check +\n+ timedelta(\n+ minutes=self.schedule_check_interval))\n+\n+ if not self.freq or now <= next_schedule_check:\n+ self.kodi_helper.log('Auto-update disabled or schedule check '\n+ 'interval not complete yet ({} / {}).'\n+ .format(now, next_schedule_check))\n+ return False\n+\n+ self.last_schedule_check = now\n+ time = self.kodi_helper.get_setting('update_time') or '00:00'\n+ lastrun_date = (self.kodi_helper.get_setting('last_update') or\n+ '1970-01-01')\n+\n+ lastrun_full = lastrun_date + ' ' + time[0:5]\n+ lastrun = strp(lastrun_full, '%Y-%m-%d %H:%M')\n+ freqdays = [0, 1, 2, 5, 7][self.freq]\n+ nextrun = lastrun + timedelta(days=freqdays)\n+\n+ self.kodi_helper.log(\n+ 'It\\'s currently {}, next run is scheduled for {}'\n+ .format(now, nextrun))\n+\n+ return now >= nextrun\n+\n+ def update_library(self):\n+ \"\"\"\n+ Triggers an update of the local Kodi library\n+ \"\"\"\n+ if not self._update_running():\n+ self.kodi_helper.log('Triggering library update', xbmc.LOGNOTICE)\n+ xbmc.executebuiltin(\n+ ('XBMC.RunPlugin(plugin://{}/?action=export-new-episodes'\n+ '&inbackground=True)')\n+ .format(self.kodi_helper.get_addon().getAddonInfo('id')))\n+\n+\n+if __name__ == '__main__':\n+ NetflixService().run()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Schedule updates and automatically trigger them |
105,989 | 25.03.2018 17:06:08 | -7,200 | 84220a2ae1d94a2655bccbc133aa200577f99bab | Added verbose debug logging | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -114,10 +114,12 @@ class Library(object):\nVideo fallback title for m3u\n\"\"\"\n+ self.log('Writing {}'.format(path))\nf = xbmcvfs.File(path, 'w')\nf.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\\n')\nf.write(url)\nf.close()\n+ self.log('Successfully wrote {}'.format(path))\ndef write_metadata_file(self, video_id, content):\n\"\"\"Writes the metadata file that caches grabbed content from netflix\n@@ -400,17 +402,24 @@ class Library(object):\nprogress = self._create_progress_dialog(in_background)\nprogress.create(self.kodi_helper.get_local_string(650), show_meta)\nif not xbmcvfs.exists(show_dir):\n+ self.log('Created show folder {}'.format(show_dir))\nxbmcvfs.mkdirs(show_dir)\nif self.show_exists(title) is False:\n+ self.log('Show does not exists, adding entry to internal library')\nself.db[self.series_label][show_meta] = {\n'netflix_id': netflix_id,\n'seasons': [],\n'episodes': [],\n'alt_title': alt_title}\n+ else:\n+ self.log('Show is present in internal library: {}'\n+ .format(self.db[self.series_label][show_meta]))\nepisodes = [episode for episode in episodes\nif not self.episode_exists(title, episode['season'],\nepisode['episode'])]\n+ self.log('Episodes to export: {}'.format(episodes))\nif len(episodes) == 0:\n+ self.log('No episodes to export, exiting')\nreturn False\nstep = round(100.0 / len(episodes), 1)\npercent = step\n@@ -485,8 +494,14 @@ class Library(object):\nepisode = int(episode)\ntitle = re.sub(r'[?|$|!|:|#]', r'', title)\n+ self.log('Adding S{}E{} (id={}) of {} (dest={})'\n+ .format(season, episode, video_id, title, show_dir))\n+\n# add season\nif self.season_exists(title=title, season=season) is False:\n+ self.log(\n+ 'Season {} does not exist, adding entry to internal library.'\n+ .format(season))\nself.db[self.series_label][title]['seasons'].append(season)\n# add episode\n@@ -496,12 +511,17 @@ class Library(object):\nseason=season,\nepisode=episode)\nif episode_exists is False:\n+ self.log(\n+ 'S{}E{} does not exist, adding entry to internal library.'\n+ .format(season, episode))\nself.db[self.series_label][title]['episodes'].append(episode_meta)\n# create strm file\nfilename = episode_meta + '.strm'\nfilepath = os.path.join(show_dir, filename)\nif xbmcvfs.exists(filepath):\n+ self.log('strm file {} already exists, not writing it'\n+ .format(filepath))\nreturn\nurl = build_url({'action': 'play_video', 'video_id': video_id})\nself.write_strm_file(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Added verbose debug logging |
106,018 | 25.03.2018 23:03:12 | -7,200 | adefeb012fc2c83f14221ed65e6fc190db626470 | fix conflict with pr | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -268,7 +268,7 @@ msgctxt \"#30062\"\nmsgid \"Enable/disable adult pin. Active:\"\nmsgstr \"\"\n-msgctxt \"#30065\"\n+msgctxt \"#30074\"\nmsgid \"View for exported\"\nmsgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"viewmodeshow\" type=\"number\" label=\"30041\" enable=\"eq(-4,true)\" default=\"504\"/>\n<setting id=\"viewmodeseason\" type=\"number\" label=\"30042\" enable=\"eq(-5,true)\" default=\"504\"/>\n<setting id=\"viewmodeepisode\" type=\"number\" label=\"30043\" enable=\"eq(-6,true)\" default=\"55\"/>\n- <setting id=\"viewmodeexported\" type=\"number\" label=\"30065\" enable=\"eq(-7,true)\" default=\"504\"/>\n+ <setting id=\"viewmodeexported\" type=\"number\" label=\"30074\" enable=\"eq(-7,true)\" default=\"504\"/>\n</category>\n<category label=\"30023\">\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix conflict with pr #317 |
105,989 | 26.03.2018 10:27:44 | -7,200 | 9a19680bc7aa3118143e4b228aec59a0639ce41a | Fixed unicode issue in logging call, duplicate str in strings.po and listitem label (wrong string id) | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -276,10 +276,6 @@ msgctxt \"#30064\"\nmsgid \"Export new episodes\"\nmsgstr \"\"\n-msgctxt \"#30064\"\n-msgid \"Export new episodes\"\n-msgstr \"\"\n-\nmsgctxt \"#30065\"\nmsgid \"Auto-update\"\nmsgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -726,7 +726,7 @@ class KodiHelper(object):\nurl=build_url({'action': 'export-new-episodes',\n'inbackground': True}),\nlistitem=xbmcgui.ListItem(\n- label=self.get_local_string(30030),\n+ label=self.get_local_string(30064),\niconImage=self.default_fanart),\nisFolder=False)\nlisting = content\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -495,7 +495,8 @@ class Library(object):\ntitle = re.sub(r'[?|$|!|:|#]', r'', title)\nself.log('Adding S{}E{} (id={}) of {} (dest={})'\n- .format(season, episode, video_id, title, show_dir))\n+ .format(season, episode, video_id, title.encode('utf-8'),\n+ show_dir))\n# add season\nif self.season_exists(title=title, season=season) is False:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fixed unicode issue in logging call, duplicate str in strings.po and listitem label (wrong string id) |
106,018 | 28.03.2018 10:44:55 | -7,200 | 506a4e8715e0019eece38e4bcd63406cb6a528e2 | fix unicode bugs | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -621,7 +621,7 @@ class Navigation(object):\nfor title, meta in self.library.list_exported_shows().iteritems():\ntry:\nself.log('Exporting new episodes of {} (id={})'\n- .format(title, meta['netflix_id']))\n+ .format(title.encode('utf-8'), meta['netflix_id']))\nself.export_to_library(\nvideo_id=meta['netflix_id'], alt_title=title,\nin_background=in_background)\n@@ -630,7 +630,7 @@ class Navigation(object):\nself.log(\n('Cannot export new episodes for {}, missing netflix_id. '\n'Remove and re-add to library to fix this.')\n- .format(title), xbmc.LOGERROR)\n+ .format(title.encode('utf-8')), xbmc.LOGERROR)\nxbmc.executebuiltin(\n'UpdateLibrary(video, {})'.format(self.library.tvshow_path))\nself.kodi_helper.set_setting('update_running', 'false')\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix unicode bugs |
105,989 | 28.03.2018 13:57:44 | -7,200 | 5be257f4be8e77aebc1645dbca4f3e360bd44c10 | Fetch netflix id if it's missing in internal db. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -414,6 +414,12 @@ class Library(object):\nelse:\nself.log('Show is present in internal library: {}'\n.format(self.db[self.series_label][show_meta]))\n+ if 'netflix_id' not in self.db[self.series_label][show_meta]:\n+ self.db[self.series_label][show_meta]['netflix_id'] = netflix_id\n+ self._update_local_db(filename=self.db_filepath, db=self.db)\n+ self.log('Added missing netflix_id={} for {} to internal library.'\n+ .format(netflix_id, title.encode('utf-8')),\n+ xbmc.LOGNOTICE)\nepisodes = [episode for episode in episodes\nif not self.episode_exists(title, episode['season'],\nepisode['episode'])]\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -12,12 +12,15 @@ for the Kodi view & the Netflix model\n\"\"\"\nimport ast\n+import re\n+import os\nimport json\nimport urllib\nimport urllib2\nfrom urlparse import parse_qsl, urlparse\nfrom datetime import datetime\nimport xbmc\n+import xbmcvfs\nfrom xbmcaddon import Addon\nimport resources.lib.NetflixSession as Netflix\nfrom resources.lib.utils import noop, log\n@@ -615,27 +618,47 @@ class Navigation(object):\n@log\ndef export_new_episodes(self, in_background):\n- no_errors = True\nupdate_started_at = datetime.today().strftime('%Y-%m-%d %H:%M')\nself.kodi_helper.set_setting('update_running', update_started_at)\nfor title, meta in self.library.list_exported_shows().iteritems():\ntry:\n- self.log('Exporting new episodes of {} (id={})'\n- .format(title.encode('utf-8'), meta['netflix_id']))\n- self.export_to_library(\n- video_id=meta['netflix_id'], alt_title=title,\n- in_background=in_background)\n+ netflix_id = meta.get('netflix_id',\n+ self._get_netflix_id(meta['alt_title']))\nexcept KeyError:\n- no_errors = False\nself.log(\n- ('Cannot export new episodes for {}, missing netflix_id. '\n+ ('Cannot determine netflix id for {}. '\n'Remove and re-add to library to fix this.')\n.format(title.encode('utf-8')), xbmc.LOGERROR)\n+ continue\n+ self.log('Exporting new episodes of {} (id={})'\n+ .format(title.encode('utf-8'), netflix_id))\n+ self.export_to_library(video_id=netflix_id, alt_title=title,\n+ in_background=in_background)\nxbmc.executebuiltin(\n'UpdateLibrary(video, {})'.format(self.library.tvshow_path))\nself.kodi_helper.set_setting('update_running', 'false')\nself.kodi_helper.set_setting('last_update', update_started_at[0:10])\n- return no_errors\n+ return True\n+\n+ def _get_netflix_id(self, showtitle):\n+ show_dir = self.kodi_helper.check_folder_path(\n+ path=os.path.join(self.library.tvshow_path, showtitle))\n+ try:\n+ filepath = next(os.path.join(show_dir, fn)\n+ for fn in xbmcvfs.listdir(show_dir)[1]\n+ if 'strm' in fn)\n+ except StopIteration:\n+ raise KeyError\n+\n+ self.log('Reading contents of {}'.format(filepath.encode('utf-8')))\n+ f = xbmcvfs.File(filepath)\n+ buf = f.read()\n+ f.close()\n+ episode_id = re.search(r'video_id=(\\d+)', buf).group(1)\n+ show_metadata = self._check_response(self.call_netflix_service({\n+ 'method': 'fetch_metadata',\n+ 'video_id': episode_id}))\n+ return show_metadata['video']['id']\n@log\ndef establish_session(self, account):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fetch netflix id if it's missing in internal db. |
106,018 | 01.04.2018 16:25:29 | -7,200 | 1eb4728a5ed91ac939da5cdff4d44b23f033867a | fix again unicode bugs | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -114,12 +114,12 @@ class Library(object):\nVideo fallback title for m3u\n\"\"\"\n- self.log('Writing {}'.format(path))\n+ self.log('Writing {}'.format(path.encode('utf-8')))\nf = xbmcvfs.File(path, 'w')\nf.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\\n')\nf.write(url)\nf.close()\n- self.log('Successfully wrote {}'.format(path))\n+ self.log('Successfully wrote {}'.format(path.encode('utf-8')))\ndef write_metadata_file(self, video_id, content):\n\"\"\"Writes the metadata file that caches grabbed content from netflix\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix again unicode bugs |
106,018 | 01.04.2018 22:56:13 | -7,200 | dd43525eedc95261b007651c1de17921335b681d | fix missing fanart image | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -721,13 +721,14 @@ class KodiHelper(object):\n\"\"\"\naction = ['remove_from_library', self.get_local_string(30030), 'remove']\n+ li = xbmcgui.ListItem(\n+ label=self.get_local_string(30064),\n+ iconImage=self.default_fanart)\n+ li.setProperty('fanart_image', self.default_fanart)\nxbmcplugin.addDirectoryItem(\nhandle=self.plugin_handle,\n- url=build_url({'action': 'export-new-episodes',\n- 'inbackground': True}),\n- listitem=xbmcgui.ListItem(\n- label=self.get_local_string(30064),\n- iconImage=self.default_fanart),\n+ url=build_url({'action': 'export-new-episodes','inbackground': True}),\n+ listitem=li,\nisFolder=False)\nlisting = content\nfor video in listing[0]:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix missing fanart image |
106,018 | 16.04.2018 13:59:53 | -7,200 | 18af801fb36b88df6ade95149d91daabaf5e8d7e | Make sure unicode wont break export caused by logging | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -114,12 +114,12 @@ class Library(object):\nVideo fallback title for m3u\n\"\"\"\n- self.log('Writing {}'.format(path.encode('utf-8')))\n+ self.log('Writing {}'.format(path.decode('ascii','ignore')))\nf = xbmcvfs.File(path, 'w')\nf.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\\n')\nf.write(url)\nf.close()\n- self.log('Successfully wrote {}'.format(path.encode('utf-8')))\n+ self.log('Successfully wrote {}'.format(path.decode('ascii','ignore')))\ndef write_metadata_file(self, video_id, content):\n\"\"\"Writes the metadata file that caches grabbed content from netflix\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Make sure unicode wont break export caused by logging |
106,018 | 16.04.2018 14:08:36 | -7,200 | 99f8ba6ce2211630437de3ae6d4e3605769112dc | Version bump (0.12.9) | [
{
"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.12.8\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.12.9\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<email>public at asciidisco dot com</email>\n<forum>https://www.kodinerds.net/index.php/Thread/55612-PreRelease-Plugin-Netflix-Inputstream/</forum>\n<source>https://github.com/asciidisco/plugin.video.netflix</source>\n- <news>v0.12.6 (2017-10-27)\n-- Adapt the Netflix API changes for episode/season lists\n+ <news>v0.12.9 (2018-04-16)\n+- View for exported\n+- Support for inputstreamhelper\n+- Grab metadate for episodes on export\n+- Auto export new episodes for exported shows\n+- Auto update watched status inside kodi library\n</news>\n</extension>\n</addon>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump (0.12.9) |
105,992 | 26.04.2018 14:15:22 | -7,200 | d54ea4480a6a100e348ccc7a4b8917159d5bb42d | fix _guess_episode scope | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -231,8 +231,8 @@ class KodiMonitor(xbmc.Monitor):\nexcept KeyError:\nself.log('Guessing video info (fallback={})'.format(fallback_data),\nxbmc.LOGWARNING)\n- return (self._guess_episode(info, fallback_data) or\n- self._guess_movie(info, fallback_data))\n+ return (_guess_episode(info, fallback_data) or\n+ _guess_movie(info, fallback_data))\n@log\ndef _update_item_details(self, properties):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix _guess_episode scope |
105,992 | 26.04.2018 14:16:11 | -7,200 | eae88e0c839629f7b4cd74c7161ced8cd54c9235 | Version bump 0.13.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.12.9\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.0\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n- Grab metadate for episodes on export\n- Auto export new episodes for exported shows\n- Auto update watched status inside kodi library\n+\n+v0.13.0 (2018-04-26)\n+- Android support WIDEVINE Cryptosession for MSL\n</news>\n</extension>\n</addon>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.0 |
105,992 | 26.04.2018 22:56:10 | -7,200 | 79194110fd46696a49c7ebb9e5006f8cd49ecc0f | Fix wrong constant location | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -131,7 +131,7 @@ class KodiMonitor(xbmc.Monitor):\nIndicates if a playback was initiated by the netflix addon by\nchecking the appropriate window property set by KodiHelper.\n\"\"\"\n- return self._is_playback_status(self.nx_common.PROP_PLAYBACK_INIT)\n+ return self._is_playback_status(PROP_PLAYBACK_INIT)\ndef is_tracking_playback(self):\n\"\"\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix wrong constant location |
105,992 | 26.04.2018 23:30:09 | -7,200 | a341d38c53685efbe60c306b26e9a52263892745 | Fix var naming in get_setting / decode -> encode for log message | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -115,7 +115,7 @@ class Library(object):\nVideo fallback title for m3u\n\"\"\"\n- self.log('Writing {}'.format(path.decode('ascii','ignore')))\n+ self.log('Writing {}'.format(path.encode('ascii','ignore')))\nf = xbmcvfs.File(path, 'w')\nf.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\\n')\nf.write(url)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCommon.py",
"new_path": "resources/lib/NetflixCommon.py",
"diff": "@@ -28,11 +28,11 @@ class NetflixCommon(object):\n\"\"\"Return the current addon instance\"\"\"\nreturn self.addon.getAddonInfo(name)\n- def set_setting(self, name, value):\n- return self.addon.setSetting(name, value)\n+ def set_setting(self, key, value):\n+ return self.addon.setSetting(key, value)\n- def get_setting(self, name):\n- return self.addon.getSetting(name)\n+ def get_setting(self, key):\n+ return self.addon.getSetting(key)\ndef flush_settings(self):\nself.addon = Addon()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix var naming in get_setting / decode -> encode for log message |
105,992 | 28.04.2018 13:00:15 | -7,200 | 899423341b0f1eff0152eeb3be0c6b926c072c9a | fix 336 / fix 337 / join threads on shutdown | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -201,10 +201,10 @@ class KodiHelper(object):\nautologin_id : :obj:`str`\nProfile id from netflix\n\"\"\"\n- self.set_setting('autologin_user', autologin_user)\n- self.set_setting('autologin_id', autologin_id)\n- self.set_setting('autologin_enable', 'True')\n- self.dialogs.show_autologin_enabled_notify()\n+ self.nx_common.set_setting('autologin_user', autologin_user)\n+ self.nx_common.set_setting('autologin_id', autologin_id)\n+ self.nx_common.set_setting('autologin_enable', 'True')\n+ self.nx_common.dialogs.show_autologin_enabled_notify()\nself.invalidate_memcache()\nself.refresh()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -13,6 +13,7 @@ import json\nimport time\nimport base64\nimport random\n+import uuid\nfrom StringIO import StringIO\nfrom datetime import datetime\nimport requests\n@@ -296,9 +297,13 @@ class MSL(object):\n# Check for pssh\npssh = ''\n+ keyid = None\nif 'psshb64' in manifest:\nif len(manifest['psshb64']) >= 1:\npssh = manifest['psshb64'][0]\n+ psshbytes = base64.standard_b64decode(pssh)\n+ if len(psshbytes) == 52:\n+ keyid = psshbytes[36:]\nseconds = manifest['runtime']/1000\ninit_length = seconds / 2 * 12 + 20*1000\n@@ -318,7 +323,16 @@ class MSL(object):\ntag='AdaptationSet',\nmimeType='video/mp4',\ncontentType=\"video\")\n+\n# Content Protection\n+ if keyid:\n+ protection = ET.SubElement(\n+ parent=video_adaption_set,\n+ tag='ContentProtection',\n+ value='cenc',\n+ schemeIdUri='urn:mpeg:dash:mp4protection:2011')\n+ protection.set('cenc:default_KID', str(uuid.UUID(bytes=keyid)))\n+\nprotection = ET.SubElement(\nparent=video_adaption_set,\ntag='ContentProtection',\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCredentials.py",
"new_path": "resources/lib/NetflixCredentials.py",
"diff": "@@ -23,8 +23,8 @@ class NetflixCredentials(object):\n# if everything is fine, we encode the values\nif '' != email or '' != password:\nreturn {\n- 'email': self.encode(enc=email),\n- 'password': self.encode(enc=password)\n+ 'email': self.encode(raw=email),\n+ 'password': self.encode(raw=password)\n}\n# if email is empty, we return an empty map\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -102,28 +102,32 @@ class NetflixService(object):\ndef _start_servers(self):\n# start thread for MLS servie\n- msl_thread = threading.Thread(target=self.msl_server.serve_forever)\n- msl_thread.daemon = True\n- msl_thread.start()\n+ self.msl_thread = threading.Thread(target=self.msl_server.serve_forever)\n+ #self.msl_thread.daemon = True\n+ self.msl_thread.start()\n+ self.nx_common.log(msg='[MSL] Thread started')\n# start thread for Netflix HTTP service\n- ns_thread = threading.Thread(target=self.ns_server.serve_forever)\n- ns_thread.daemon = True\n- ns_thread.start()\n+ self.ns_thread = threading.Thread(target=self.ns_server.serve_forever)\n+ #self.ns_thread.daemon = True\n+ self.ns_thread.start()\n+ self.nx_common.log(msg='[NS] Thread started')\ndef _shutdown(self):\n# MSL service shutdown sequence\nself.msl_server.server_close()\n- self.msl_server.socket.close()\nself.msl_server.shutdown()\n+ self.msl_thread.join()\nself.msl_server = None\n+ self.msl_thread = None\nself.nx_common.log(msg='Stopped MSL Service')\n# Netflix service shutdown sequence\nself.ns_server.server_close()\n- self.ns_server.socket.close()\nself.ns_server.shutdown()\n+ self.ns_thread.join()\nself.ns_server = None\n+ self.ns_thread = None\nself.nx_common.log(msg='Stopped HTTP Service')\ndef _is_idle(self):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | fix 336 / fix 337 / join threads on shutdown |
105,992 | 28.04.2018 15:37:49 | -7,200 | a1fab95400cb1a2af935a6fc9a8da224f9e2a8c1 | make travis hapy | [
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -102,14 +102,14 @@ class NetflixService(object):\ndef _start_servers(self):\n# start thread for MLS servie\n- self.msl_thread = threading.Thread(target=self.msl_server.serve_forever)\n- #self.msl_thread.daemon = True\n+ self.msl_thread = threading.Thread(\n+ target=self.msl_server.serve_forever)\nself.msl_thread.start()\nself.nx_common.log(msg='[MSL] Thread started')\n# start thread for Netflix HTTP service\n- self.ns_thread = threading.Thread(target=self.ns_server.serve_forever)\n- #self.ns_thread.daemon = True\n+ self.ns_thread = threading.Thread(\n+ target=self.ns_server.serve_forever)\nself.ns_thread.start()\nself.nx_common.log(msg='[NS] Thread started')\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | make travis hapy |
105,992 | 28.04.2018 15:38:06 | -7,200 | ebaf58e36e0eea09ef30fe45cc3a988d730052ea | Version bump 0.13.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.13.0\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.1\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.1 |
105,992 | 29.04.2018 11:33:00 | -7,200 | 5f30df1126fbc285afa0b38b263f36699e96b66d | KodiHelper -> Library / Fix hang if ESN changed | [
{
"change_type": "MODIFY",
"old_path": "addon.py",
"new_path": "addon.py",
"diff": "import sys\nfrom resources.lib.NetflixCommon import NetflixCommon\nfrom resources.lib.Navigation import Navigation\n-from resources.lib.Library import Library\n# Setup plugin\nPLUGIN_HANDLE = int(sys.argv[1])\n@@ -24,11 +23,8 @@ NETFLIX_COMMON = NetflixCommon(\nbase_url=BASE_URL\n)\n-LIBRARY = Library(nx_common=NETFLIX_COMMON)\n-\nNAVIGATION = Navigation(\n- nx_common=NETFLIX_COMMON,\n- library=LIBRARY,\n+ nx_common=NETFLIX_COMMON\n)\nif __name__ == '__main__':\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -204,7 +204,7 @@ class KodiHelper(object):\nself.nx_common.set_setting('autologin_user', autologin_user)\nself.nx_common.set_setting('autologin_id', autologin_id)\nself.nx_common.set_setting('autologin_enable', 'True')\n- self.nx_common.dialogs.show_autologin_enabled_notify()\n+ self.dialogs.show_autologin_enabled_notify()\nself.invalidate_memcache()\nself.refresh()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Library.py",
"new_path": "resources/lib/Library.py",
"diff": "@@ -59,6 +59,7 @@ class Library(object):\nenable_custom_folder = nx_common.get_setting('enablelibraryfolder')\nself.nx_common = nx_common\n+ self.kodi_helper = None\nself.base_data_path = nx_common.data_path\nself.enable_custom_library_folder = enable_custom_folder\nself.custom_library_folder = nx_common.get_setting('customlibraryfolder')\n@@ -86,6 +87,9 @@ class Library(object):\n# load the local db\nself.db = self._load_local_db(filename=self.db_filepath)\n+ def set_kodi_helper(self, kodi_helper):\n+ self.kodi_helper = kodi_helper\n+\ndef setup_local_netflix_library(self, source):\n\"\"\"Sets up the basic directories\n@@ -115,12 +119,18 @@ class Library(object):\nVideo fallback title for m3u\n\"\"\"\n- self.log('Writing {}'.format(path.encode('ascii','ignore')))\n+ if isinstance(path, str):\n+ logpath = path.decode('ascii', 'ignore').encode('ascii')\n+ elif isinstance(path, unicode):\n+ logpath = path.encode('ascii', 'ignore')\n+\n+ self.log('Writing {}'.format(logpath))\n+\nf = xbmcvfs.File(path, 'w')\nf.write('#EXTINF:-1,'+title_player.encode('utf-8')+'\\n')\nf.write(url)\nf.close()\n- self.log('Successfully wrote {}'.format(path.decode('ascii','ignore')))\n+ self.log('Successfully wrote {}'.format(logpath))\ndef write_metadata_file(self, video_id, content):\n\"\"\"Writes the metadata file that caches grabbed content from netflix\n@@ -358,7 +368,7 @@ class Library(object):\npath=os.path.join(self.movie_path, folder))\nfilename = os.path.join(dirname, movie_meta + '.strm')\nprogress = xbmcgui.DialogProgress()\n- progress.create(self.nx_common.get_local_string(650), movie_meta)\n+ progress.create(self.kodi_helper.get_local_string(650), movie_meta)\nif xbmcvfs.exists(filename):\nreturn\nif not xbmcvfs.exists(dirname):\n@@ -401,7 +411,7 @@ class Library(object):\nshow_dir = self.nx_common.check_folder_path(\npath=os.path.join(self.tvshow_path, folder))\nprogress = self._create_progress_dialog(in_background)\n- progress.create(self.nx_common.get_local_string(650), show_meta)\n+ progress.create(self.kodi_helper.get_local_string(650), show_meta)\nif not xbmcvfs.exists(show_dir):\nself.log('Created show folder {}'.format(show_dir))\nxbmcvfs.mkdirs(show_dir)\n@@ -431,9 +441,9 @@ class Library(object):\nstep = round(100.0 / len(episodes), 1)\npercent = step\nfor episode in episodes:\n- desc = self.nx_common.get_local_string(20373) + ': '\n+ desc = self.kodi_helper.get_local_string(20373) + ': '\ndesc += str(episode.get('season'))\n- long_desc = self.nx_common.get_local_string(20359) + ': '\n+ long_desc = self.kodi_helper.get_local_string(20359) + ': '\nlong_desc += str(episode.get('episode'))\nprogress.update(\npercent=int(percent),\n@@ -560,7 +570,7 @@ class Library(object):\nrepl=r'',\nstring=self.db[self.movies_label][movie_meta]['alt_title'])\nprogress = xbmcgui.DialogProgress()\n- progress.create(self.nx_common.get_local_string(1210), movie_meta)\n+ progress.create(self.kodi_helper.get_local_string(1210), movie_meta)\nprogress.update(50)\ntime.sleep(0.5)\ndel self.db[self.movies_label][movie_meta]\n@@ -597,7 +607,7 @@ class Library(object):\nrepl=r'',\nstring=rep_str)\nprogress = xbmcgui.DialogProgress()\n- progress.create(self.nx_common.get_local_string(1210), title)\n+ progress.create(self.kodi_helper.get_local_string(1210), title)\ntime.sleep(0.5)\ndel self.db[self.series_label][title]\nself._update_local_db(filename=self.db_filepath, db=self.db)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -583,8 +583,13 @@ class MSL(object):\n\"\"\"\nreturn base64.standard_b64encode(self.crypto.sign(text))\n+ def perform_key_handshake(self):\n+ self.__perform_key_handshake()\n+\ndef __perform_key_handshake(self):\nesn = self.nx_common.get_esn()\n+ self.nx_common.log(msg='perform_key_handshake: esn:' + esn)\n+\nif not esn:\nreturn False\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSLHttpRequestHandler.py",
"new_path": "resources/lib/MSLHttpRequestHandler.py",
"diff": "@@ -32,7 +32,7 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nif len(data) is 2:\nchallenge = data[0]\nsid = base64.standard_b64decode(data[1])\n- b64license = self.server.Msl.get_license(challenge, sid)\n+ b64license = self.server.MslHandler.get_license(challenge, sid)\nif b64license is not '':\nself.send_response(200)\nself.end_headers()\n@@ -50,11 +50,7 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n\"\"\"Loads the XML manifest for the requested resource\"\"\"\nurl = urlparse(self.path)\nparams = parse_qs(url.query)\n- if 'action' in params:\n- if params['action'][0] is 'reset':\n- self.server.Msl.__perform_key_handshake()\n- self.send_response(200)\n- elif 'id' not in params:\n+ if 'id' not in params:\nself.send_response(400, 'No id')\nelse:\n# Get the manifest with the given id\n@@ -63,7 +59,8 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nhevc = (True if 'hevc' in params and\nparams['hevc'][0].lower() == 'true' else 'false')\n- data = self.server.Msl.load_manifest(int(params['id'][0]),\n+ data = self.server.MslHandler.load_manifest(\n+ int(params['id'][0]),\ndolby, hevc)\nself.send_response(200)\n@@ -84,5 +81,8 @@ class MSLTCPServer(TCPServer):\ndef __init__(self, server_address, nx_common):\nnx_common.log(msg='Constructing MSLTCPServer')\nself.nx_common = nx_common\n- self.Msl = MSL(nx_common)\n+ self.MslHandler = MSL(nx_common)\nTCPServer.__init__(self, server_address, MSLHttpRequestHandler)\n+\n+ def reset_msl_data(self):\n+ self.MslHandler.perform_key_handshake()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -23,6 +23,7 @@ import xbmc\nimport resources.lib.NetflixSession as Netflix\nfrom resources.lib.utils import log\nfrom resources.lib.KodiHelper import KodiHelper\n+from resources.lib.Library import Library\nclass Navigation(object):\n@@ -32,7 +33,7 @@ class Navigation(object):\nfor the Kodi view & the Netflix model\n\"\"\"\n- def __init__(self, nx_common, library):\n+ def __init__(self, nx_common):\n\"\"\"\nTakes the instances & configuration options needed to drive the plugin\n@@ -51,10 +52,14 @@ class Navigation(object):\noptional log function\n\"\"\"\nself.nx_common = nx_common\n+ self.library = Library(nx_common=nx_common)\n+\nself.kodi_helper = KodiHelper(\nnx_common=nx_common,\n- library=library)\n- self.library = library\n+ library=self.library)\n+\n+ self.library.set_kodi_helper(kodi_helper=self.kodi_helper)\n+\nself.base_url = self.nx_common.base_url\nself.log = self.nx_common.log\n@@ -663,7 +668,7 @@ class Navigation(object):\n@log\ndef export_new_episodes(self, in_background):\nupdate_started_at = datetime.today().strftime('%Y-%m-%d %H:%M')\n- self.kodi_helper.set_setting('update_running', update_started_at)\n+ self.nx_common.set_setting('update_running', update_started_at)\nfor title, meta in self.library.list_exported_shows().iteritems():\ntry:\nnetflix_id = meta.get('netflix_id',\n@@ -680,12 +685,12 @@ class Navigation(object):\nin_background=in_background)\nxbmc.executebuiltin(\n'UpdateLibrary(video, {})'.format(self.library.tvshow_path))\n- self.kodi_helper.set_setting('update_running', 'false')\n- self.kodi_helper.set_setting('last_update', update_started_at[0:10])\n+ self.nx_common.set_setting('update_running', 'false')\n+ self.nx_common.set_setting('last_update', update_started_at[0:10])\nreturn True\ndef _get_netflix_id(self, showtitle):\n- show_dir = self.kodi_helper.check_folder_path(\n+ show_dir = self.nx_common.check_folder_path(\npath=os.path.join(self.library.tvshow_path, showtitle))\ntry:\nfilepath = next(os.path.join(show_dir, fn)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCommon.py",
"new_path": "resources/lib/NetflixCommon.py",
"diff": "@@ -45,14 +45,13 @@ class NetflixCommon(object):\ndef set_esn(self, esn):\n\"\"\"\n- Returns the esn from settings\n+ Returns True if MSL reset is required\n\"\"\"\nstored_esn = self.get_esn()\nif not stored_esn and esn:\nself.set_setting('esn', esn)\n- self.delete_manifest_data()\n- return esn\n- return stored_esn\n+ return True\n+ return False\ndef get_credentials(self):\nfrom NetflixCredentials import NetflixCredentials\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpRequestHandler.py",
"new_path": "resources/lib/NetflixHttpRequestHandler.py",
"diff": "@@ -79,3 +79,7 @@ class NetflixTCPServer(TCPServer):\nnetflix_session=netflix_session)\nTCPServer.__init__(self, server_address, NetflixHttpRequestHandler)\n+\n+ def esn_changed(self):\n+ return self.res_handler.nx_common.set_esn(\n+ self.res_handler.netflix_session.esn)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"new_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"diff": "@@ -47,7 +47,6 @@ class NetflixHttpSubRessourceHandler(object):\nelse:\nif self.netflix_session.login(account=self.credentials):\nself.profiles = self.netflix_session.profiles\n- self.nx_common.set_esn(self.netflix_session.esn)\ndef is_logged_in(self, params):\n\"\"\"Existing login proxy function\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -91,22 +91,27 @@ class NetflixService(object):\n# configure the MSL Server\nself.msl_server = MSLTCPServer(('127.0.0.1', msl_port),\nself.nx_common)\n- self.msl_server.server_activate()\n- self.msl_server.timeout = 1\n# configure the Netflix Data Server\nself.ns_server = NetflixTCPServer(('127.0.0.1', ns_port),\nself.nx_common)\n- self.ns_server.server_activate()\n- self.ns_server.timeout = 1\n+\n+ if self.ns_server.esn_changed():\n+ self.msl_server.reset_msl_data()\ndef _start_servers(self):\n+ self.msl_server.server_activate()\n+ self.msl_server.timeout = 1\n+\n# start thread for MLS servie\nself.msl_thread = threading.Thread(\ntarget=self.msl_server.serve_forever)\nself.msl_thread.start()\nself.nx_common.log(msg='[MSL] Thread started')\n+ self.ns_server.server_activate()\n+ self.ns_server.timeout = 1\n+\n# start thread for Netflix HTTP service\nself.ns_thread = threading.Thread(\ntarget=self.ns_server.serve_forever)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | KodiHelper -> Library / Fix hang if ESN changed |
105,992 | 29.04.2018 11:33:47 | -7,200 | b59c56ba8deab45ebfc558c4aa851baaa7dda60a | Version bump 0.13.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.13.1\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.2\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.2 |
105,992 | 05.05.2018 16:41:48 | -7,200 | d3debe779f4076408000c3f6004391a1cbbeabc7 | New profile style / update rsa-key on re-login | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -660,7 +660,7 @@ class MSL(object):\n# If token expires in less then 10 hours or is expires renew it\nself.nx_common.log(msg='Expiration time: Key:' + str(valid_until) + ', Now:' + str(present) + ', Diff:' + str(difference.total_seconds()))\ndifference = difference.total_seconds() / 60 / 60\n- if difference < 10 or self.crypto.fromDict(msl_data):\n+ if self.crypto.fromDict(msl_data) or difference < 10:\nself.__perform_key_handshake()\nreturn\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSLHttpRequestHandler.py",
"new_path": "resources/lib/MSLHttpRequestHandler.py",
"diff": "@@ -32,7 +32,7 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nif len(data) is 2:\nchallenge = data[0]\nsid = base64.standard_b64decode(data[1])\n- b64license = self.server.MslHandler.get_license(challenge, sid)\n+ b64license = self.server.msl_handler.get_license(challenge, sid)\nif b64license is not '':\nself.send_response(200)\nself.end_headers()\n@@ -59,7 +59,7 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nhevc = (True if 'hevc' in params and\nparams['hevc'][0].lower() == 'true' else 'false')\n- data = self.server.MslHandler.load_manifest(\n+ data = self.server.msl_handler.load_manifest(\nint(params['id'][0]),\ndolby, hevc)\n@@ -77,12 +77,15 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nclass MSLTCPServer(TCPServer):\n+ \"\"\"Override TCPServer to allow usage of shared members\"\"\"\ndef __init__(self, server_address, nx_common):\n+ \"\"\"Initialization of MSLTCPServer\"\"\"\nnx_common.log(msg='Constructing MSLTCPServer')\nself.nx_common = nx_common\n- self.MslHandler = MSL(nx_common)\n+ self.msl_handler = MSL(nx_common)\nTCPServer.__init__(self, server_address, MSLHttpRequestHandler)\ndef reset_msl_data(self):\n- self.MslHandler.perform_key_handshake()\n+ \"\"\"Initialization of MSLTCPServerResets MSL data (perform handshake)\"\"\"\n+ self.msl_handler.perform_key_handshake()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpRequestHandler.py",
"new_path": "resources/lib/NetflixHttpRequestHandler.py",
"diff": "@@ -64,8 +64,10 @@ class NetflixHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\nclass NetflixTCPServer(TCPServer):\n+ \"\"\"Override TCPServer to allow shared struct sharing\"\"\"\ndef __init__(self, server_address, nx_common):\n+ \"\"\"Initializes NetflixTCPServer\"\"\"\nnx_common.log(msg='Constructing netflixTCPServer')\nnetflix_session = NetflixSession(\n@@ -81,5 +83,6 @@ class NetflixTCPServer(TCPServer):\nTCPServer.__init__(self, server_address, NetflixHttpRequestHandler)\ndef esn_changed(self):\n+ \"\"\"Return if the esn has changed on Session initialization\"\"\"\nreturn self.res_handler.nx_common.set_esn(\nself.res_handler.netflix_session.esn)\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -170,46 +170,35 @@ class NetflixSession(object):\ndef get_profiles(self, content):\n\"\"\"ADD ME\"\"\"\nprofiles = {}\n- # find everything between the profiles and the profiles_list property\n- _pattern = '\"profiles\":(.*?)\"profilesList'\n- _profiles = recompile(_pattern).findall(content)\n- # replace the last comma we found with nothing\n- if len(_profiles):\n- _profiles_string = _profiles[0][::-1].replace(',', '', 1)[::-1]\n- # check if the last character is a closing bracket\n- if _profiles_string[len(_profiles_string)-1] != '}':\n- # if not, fix that\n- _closing_pos = _profiles_string.rfind('}')+1\n- _profiles_string = _profiles_string[:_closing_pos]\n- _profiles_parsed = json.loads(_profiles_string)\n- avatars = self.get_avatars(content=content)\n- for guid in _profiles_parsed:\n- if 'size' not in guid:\n- _profile = _profiles_parsed[guid].get('summary')\n- _name = _profile.get('avatarName')\n- _profile['avatar'] = avatars.get(_name)\n+ # find falkor cache\n+ falkorCache = content[content.find('netflix.falkorCache = '):]\n+ # Extract JSON\n+ falkorCache = recompile(r\"\\{([^)]+)\\}\").findall(falkorCache)\n+ if not falkorCache:\n+ return profiles\n+ falkorDict = json.loads('{' + falkorCache[0] + '}')\n+ _profiles = falkorDict['profiles']\n+\n+ for guid in _profiles:\n+ if not isinstance(_profiles[guid], dict):\n+ continue\n+ _profile = _profiles[guid]['summary']\n+ if 'value' in _profile:\n+ _profile = _profile['value']\n+ _avatar_path = _profiles[guid]['avatar']\n+ if 'value' in _avatar_path:\n+ _avatar_path = _avatar_path['value']\n+ _avatar_path.extend([u'images', u'byWidth', u'320', u'value'])\n+ _profile['avatar'] = self.__recursive_dict(_avatar_path, falkorDict)\nprofiles.update({guid: _profile})\n+\nreturn profiles\n- @classmethod\n- def get_avatars(cls, content):\n- \"\"\"ADD ME\"\"\"\n- avatars = {}\n- # find everything between the avatars and the profiles property\n- _pattern = '\"avatars\":(.*?)(.*)\"profiles\":'\n- _avatars = recompile(_pattern).findall(content)\n- # replace the last comma we found with nothing\n- if len(_avatars):\n- index = 1 if len(_avatars[0][0]) == 0 else 0\n- _avatar_string = _avatars[0][index][::-1].replace(',', '', 1)[::-1]\n- _avatars_parsed = json.loads(_avatar_string).get('nf')\n- for _ava_key in _avatars_parsed:\n- if 'size' not in _ava_key:\n- _images = _avatars_parsed[_ava_key].get('images', {})\n- _image = _images.get('byWidth', {}).get('320', {})\n- _url = _image.get('value')\n- avatars.update({_ava_key: _url})\n- return avatars\n+ @staticmethod\n+ def __recursive_dict(search, dict, index=0):\n+ if (index + 1 == len(search)):\n+ return dict[search[index]]\n+ return NetflixSession.__recursive_dict(search, dict[search[index]], index + 1)\ndef is_logged_in(self, account):\n\"\"\"\n@@ -299,9 +288,10 @@ class NetflixSession(object):\n'flow': 'websiteSignUp',\n'mode': 'login',\n'action': 'loginAction',\n- 'withFields': 'email,password,rememberMe,nextPage',\n+ 'withFields': 'email,password,rememberMe,nextPage,showPassword',\n'authURL': user_data.get('authURL'),\n- 'nextPage': ''\n+ 'nextPage': '',\n+ 'showPassword': ''\n}\n# perform the login\n@@ -1600,12 +1590,12 @@ class NetflixSession(object):\ndef _path_request(self, paths):\n\"\"\"\nExecutes a post request against the shakti\n- endpoint with Falcor style payload\n+ endpoint with falkor style payload\nParameters\n----------\npaths : :obj:`list` of :obj:`list`\n- Payload with path querys for the Netflix Shakti API in Falcor style\n+ Payload with path querys for the Netflix Shakti API in falkor style\nReturns\n-------\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "import threading\nimport socket\n-\nimport sys\n-import xbmc\nfrom datetime import datetime, timedelta\n+\n+import xbmc\nfrom resources.lib.NetflixCommon import NetflixCommon\nfrom resources.lib.KodiMonitor import KodiMonitor\nfrom resources.lib.MSLHttpRequestHandler import MSLTCPServer\n@@ -96,6 +96,12 @@ class NetflixService(object):\nself.ns_server = NetflixTCPServer(('127.0.0.1', ns_port),\nself.nx_common)\n+ self.msl_thread = threading.Thread(\n+ target=self.msl_server.serve_forever)\n+\n+ self.ns_thread = threading.Thread(\n+ target=self.ns_server.serve_forever)\n+\nif self.ns_server.esn_changed():\nself.msl_server.reset_msl_data()\n@@ -104,8 +110,6 @@ class NetflixService(object):\nself.msl_server.timeout = 1\n# start thread for MLS servie\n- self.msl_thread = threading.Thread(\n- target=self.msl_server.serve_forever)\nself.msl_thread.start()\nself.nx_common.log(msg='[MSL] Thread started')\n@@ -113,8 +117,6 @@ class NetflixService(object):\nself.ns_server.timeout = 1\n# start thread for Netflix HTTP service\n- self.ns_thread = threading.Thread(\n- target=self.ns_server.serve_forever)\nself.ns_thread.start()\nself.nx_common.log(msg='[NS] Thread started')\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | New profile style / update rsa-key on re-login |
105,992 | 05.05.2018 16:46:31 | -7,200 | dc06c57731261a8713001075088e4a0c17b29fb0 | Version bump 0.13.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.13.2\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.3\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.3 |
105,992 | 05.05.2018 19:46:38 | -7,200 | 9cb07c928545bf84ed3e152ddbe822c184316323 | Don't refresh Container on play call (leads to double busy dialogs) | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -220,6 +220,7 @@ class Navigation(object):\nvideo_id=params['video_id'],\nstart_offset=params.get('start_offset', -1),\ninfoLabels=params.get('infoLabels', {}))\n+ return True\nelif action == 'user-items' and params['type'] == 'search':\n# if the user requested a search, ask for the term\nterm = self.kodi_helper.dialogs.show_search_term_dialog()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Don't refresh Container on play call (leads to double busy dialogs) |
105,992 | 06.05.2018 21:42:53 | -7,200 | 12d170b85c4fe8d8edd064de4473a60c662dd28c | Fix manifest_url | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -910,8 +910,7 @@ class KodiHelper(object):\nmsl_manifest_url += '&dolby=' + self.nx_common.get_setting('enable_dolby_sound')\nmsl_manifest_url += '&hevc=' + self.nx_common.get_setting('enable_hevc_profiles')\n- play_item = xbmcgui.ListItem(\n- path=msl_service_url + '/manifest?id=' + video_id)\n+ play_item = xbmcgui.ListItem(path=msl_manifest_url)\nplay_item.setContentLookup(False)\nplay_item.setMimeType('application/dash+xml')\nplay_item.setProperty(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix manifest_url |
105,992 | 06.05.2018 21:58:19 | -7,200 | 27fe99d079041d24b280ad954abdd533725ab102 | Version bump 0.13.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.13.3\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.4\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.4 |
105,992 | 11.05.2018 13:21:40 | -7,200 | 9de83e7a2670f5e0cfdb678e46ac91db7c9e9ebe | Remove log spam (KodiMonitor) | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -141,7 +141,7 @@ class KodiMonitor(xbmc.Monitor):\nreturn (self.video_info is not None and\nself._is_playback_status(PROP_PLAYBACK_TRACKING))\n- @log\n+ # @log\ndef update_playback_progress(self):\n\"\"\"\nUpdates the internal progress status of a tracked playback\n@@ -176,7 +176,7 @@ class KodiMonitor(xbmc.Monitor):\nelif method == 'Player.OnStop':\nself._on_playback_stopped()\n- @log\n+ # @log\ndef _on_playback_started(self, item):\nplayer_id = _retry(_get_active_video_player, 5)\n@@ -198,7 +198,7 @@ class KodiMonitor(xbmc.Monitor):\nif self.is_initialized_playback() else\n'Unable to obtain active video player'))\n- @log\n+ # @log\ndef _on_playback_stopped(self):\nif self.is_tracking_playback():\nif self.progress >= 90:\n@@ -216,7 +216,7 @@ class KodiMonitor(xbmc.Monitor):\nself.video_info = None\nself.progress = 0\n- @log\n+ # @log\ndef _get_video_info(self, player_id, fallback_data):\ninfo = _json_rpc('Player.GetItem',\n{\n@@ -234,7 +234,7 @@ class KodiMonitor(xbmc.Monitor):\nreturn (_guess_episode(info, fallback_data) or\n_guess_movie(info, fallback_data))\n- @log\n+ # @log\ndef _update_item_details(self, properties):\nmethod = ('VideoLibrary.Set{}Details'\n.format(self.video_info['dbtype'].capitalize()))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSLHttpRequestHandler.py",
"new_path": "resources/lib/MSLHttpRequestHandler.py",
"diff": "@@ -27,7 +27,6 @@ class MSLHttpRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):\n\"\"\"Loads the licence for the requested resource\"\"\"\nlength = int(self.headers.get('content-length'))\npost = self.rfile.read(length)\n- print post\ndata = post.split('!')\nif len(data) is 2:\nchallenge = data[0]\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Remove log spam (KodiMonitor) |
105,992 | 14.05.2018 16:51:23 | -7,200 | 3714e1444dd2f0265940169bca15540c379ca1fc | Fix issues after invalid login | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -798,15 +798,17 @@ class Navigation(object):\n# check if we have user settings, if not, set em\nif credentials['email'] == '':\nemail = self.kodi_helper.dialogs.show_email_dialog()\n- self.nx_common.set_setting(key='email', value=email)\ncredentials['email'] = email\nif credentials['password'] == '':\npassword = self.kodi_helper.dialogs.show_password_dialog()\n- self.nx_common.set_setting(key='password', value=password)\ncredentials['password'] = password\n+ self.nx_common.set_credentials(credentials['email'], credentials['password'])\n+\nif self.establish_session(account=credentials) is not True:\n+ self.nx_common.set_credentials('', '')\nself.kodi_helper.dialogs.show_login_failed_notify()\n+\n# persist & load main menu selection\nif 'type' in params:\nself.kodi_helper.set_main_menu_selection(type=params['type'])\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCredentials.py",
"new_path": "resources/lib/NetflixCredentials.py",
"diff": "@@ -62,7 +62,7 @@ class NetflixCredentials(object):\n:type data: str\n:returns: string -- Encoded data\n\"\"\"\n- raw = Padding.pad(data_to_pad=raw, block_size=self.bs)\n+ raw = bytes(Padding.pad(data_to_pad=raw, block_size=self.bs))\niv = Random.new().read(AES.block_size)\ncipher = AES.new(self.crypt_key, AES.MODE_CBC, iv)\nreturn base64.b64encode(iv + cipher.encrypt(raw))\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix issues after invalid login |
105,992 | 14.05.2018 18:54:57 | -7,200 | f71b5205e1780655c750e8fdf90442f9edfb342d | Remove more log spam | [
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -191,9 +191,11 @@ class NetflixService(object):\ntimedelta(minutes=self.schedule_check_interval))\nif not self.freq or now <= next_schedule_check:\n+ '''\nself.nx_common.log('Auto-update disabled or schedule check '\n'interval not complete yet ({} / {}).'\n.format(now, next_schedule_check))\n+ '''\nreturn False\nself.last_schedule_check = now\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Remove more log spam |
105,992 | 16.05.2018 10:08:56 | -7,200 | 4f0be7ebc2352adc81dbfcc8291474e9348e3c41 | Version bump 0.13.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.13.4\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.5\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.5 |
105,992 | 20.05.2018 00:46:21 | -7,200 | e7977ce21e083cf151b7b64600e881cc9741d5b2 | Fix search sort order | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -19,6 +19,8 @@ import urllib\nimport urllib2\nfrom urlparse import parse_qsl, urlparse\nfrom datetime import datetime\n+from collections import OrderedDict\n+\nimport xbmc\nimport resources.lib.NetflixSession as Netflix\nfrom resources.lib.utils import log\n@@ -979,7 +981,7 @@ class Navigation(object):\nopener = urllib2.build_opener(urllib2.ProxyHandler({}))\nurllib2.install_opener(opener)\ndata = urllib2.urlopen(full_url).read(opener)\n- parsed_json = json.loads(data)\n+ parsed_json = json.loads(data, object_pairs_hook=OrderedDict)\nif 'error' in parsed_json:\nresult = {'error': parsed_json.get('error')}\nreturn result\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"new_path": "resources/lib/NetflixHttpSubRessourceHandler.py",
"diff": "@@ -382,5 +382,6 @@ class NetflixHttpSubRessourceHandler(object):\nreturn []\n# list the search results\nsearch_results = self.netflix_session.parse_video_list(\n- response_data=raw_search_results)\n+ response_data=raw_search_results,\n+ term=term)\nreturn search_results\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -16,6 +16,7 @@ from re import compile as recompile\nfrom base64 import urlsafe_b64encode\nfrom requests import session, cookies\nfrom utils import noop, get_user_agent\n+from collections import OrderedDict\ntry:\nimport cPickle as pickle\nexcept:\n@@ -575,7 +576,7 @@ class NetflixSession(object):\n}\n}\n- def parse_video_list(self, response_data):\n+ def parse_video_list(self, response_data, term=None):\n\"\"\"Parse a list of videos\nParameters\n@@ -684,11 +685,25 @@ class NetflixSession(object):\n},\n}\n\"\"\"\n- video_list = {}\n+ video_ids = []\nraw_video_list = response_data.get('value', {})\n- netflix_list_id = self.parse_netflix_list_id(video_list=raw_video_list)\n+ # search results have sorting given in references\n+ if term and 'search' in raw_video_list:\n+ try:\n+ reference = raw_video_list.get('search').get('byTerm').get('|'+term).get('titles').get('48')[2]\n+ references = raw_video_list.get('search').get('byReference').get(reference)\n+ for reference_id in range (0, 48):\n+ video_ids.append(references.get(str(reference_id)).get('reference')[1])\n+ except:\n+ return {}\n+ else:\nfor video_id in raw_video_list.get('videos', {}):\nif self._is_size_key(key=video_id) is False:\n+ video_ids.append(video_id);\n+\n+ video_list = OrderedDict()\n+ netflix_list_id = self.parse_netflix_list_id(video_list=raw_video_list)\n+ for video_id in video_ids:\nvideo_list_entry = self.parse_video_list_entry(\nid=video_id,\nlist_id=netflix_list_id,\n@@ -696,6 +711,7 @@ class NetflixSession(object):\npersons=raw_video_list.get('person'),\ngenres=raw_video_list.get('genres'))\nvideo_list.update(video_list_entry)\n+\nreturn video_list\ndef parse_video_list_entry(self, id, list_id, video, persons, genres):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix search sort order |
105,992 | 21.05.2018 23:38:46 | -7,200 | 4e9be1598b4fe203d5d69fd202e4bdf30ed39882 | Remove initialization segment / add audio attributes | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/MSL.py",
"new_path": "resources/lib/MSL.py",
"diff": "@@ -377,23 +377,31 @@ class MSL(object):\ntag='SegmentBase',\nindexRange='0-' + str(init_length),\nindexRangeExact='true')\n- ET.SubElement(\n- parent=segment_base,\n- tag='Initialization',\n- range='0-' + str(init_length))\n# Multiple Adaption Set for audio\n+ language = None\nfor audio_track in manifest['audioTracks']:\nimpaired = 'false'\n+ original = 'false'\n+ default = 'false'\n+\nif audio_track.get('trackType') == 'ASSISTIVE':\nimpaired = 'true'\n+ elif not language or language == audio_track.get('language'):\n+ language = audio_track.get('language')\n+ default = 'true'\n+ if audio_track.get('language').find('[') > 0:\n+ original = 'true'\n+\naudio_adaption_set = ET.SubElement(\nparent=period,\ntag='AdaptationSet',\nlang=audio_track['bcp47'],\ncontentType='audio',\nmimeType='audio/mp4',\n- impaired=impaired)\n+ impaired=impaired,\n+ original=original,\n+ default=default)\nfor downloadable in audio_track['downloadables']:\ncodec = 'aac'\n#self.nx_common.log(msg=downloadable)\n@@ -426,10 +434,6 @@ class MSL(object):\ntag='SegmentBase',\nindexRange='0-' + str(init_length),\nindexRangeExact='true')\n- ET.SubElement(\n- parent=segment_base,\n- tag='Initialization',\n- range='0-' + str(init_length))\n# Multiple Adaption Sets for subtiles\nfor text_track in manifest.get('textTracks'):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Remove initialization segment / add audio attributes |
105,992 | 22.05.2018 18:53:43 | -7,200 | 5dac8d5fef3049d1ed97addd2b79a94eff401618 | Fix issues regarding falkorcache retrieval / profiles | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -141,9 +141,9 @@ class NetflixSession(object):\nself.nx_common.log(msg='Parsing inline data...')\nitems = self.page_items if items is None else items\nuser_data = {'gpsModel': 'harris'}\n- content = content.encode('utf-8').decode('string_escape')\n+ content = content.replace('\\\"', '\\\\\"').encode('utf-8').decode('string_escape')\n# find <script/> tag witch contains the 'reactContext' globals\n- react_context = recompile('reactContext(?s)(.*);').findall(content)\n+ react_context = recompile(r\"netflix\\.reactContext\\s*=\\s*(.*?);\\s*</script>\").findall(content)\n# iterate over all wanted item keys & try to fetch them\nfor item in items:\nmatch = recompile(\n@@ -171,13 +171,11 @@ class NetflixSession(object):\ndef get_profiles(self, content):\n\"\"\"ADD ME\"\"\"\nprofiles = {}\n- # find falkor cache\n- falkorCache = content[content.find('netflix.falkorCache = '):]\n- # Extract JSON\n- falkorCache = recompile(r\"\\{([^)]+)\\}\").findall(falkorCache)\n+ # find falkor cache and extract JSON text\n+ falkorCache = recompile(r\"netflix\\.falkorCache\\s*=\\s*(.*?);\\s*</script>\").findall(content)\nif not falkorCache:\nreturn profiles\n- falkorDict = json.loads('{' + falkorCache[0] + '}')\n+ falkorDict = json.loads(falkorCache[0])\n_profiles = falkorDict['profiles']\nfor guid in _profiles:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix issues regarding falkorcache retrieval / profiles |
105,992 | 23.05.2018 10:29:44 | -7,200 | 6bc775d369d916919b60bd085ab612cb2d6e0f76 | Version bump 0.13.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.13.5\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.6\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.6 |
106,024 | 28.05.2018 11:09:54 | -7,200 | c2a641d8eb46c469c1bc628c04c2f9cc66781d04 | Refactoring extracting json and regex
Refactoring regex and json.loads call's
Add a method for extracting json from content
Change regex for grabbing multiline (if endline in string)
Permits json.loads to parse endline in string too. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -12,7 +12,7 @@ import sys\nimport json\nfrom time import time\nfrom urllib import quote, unquote\n-from re import compile as recompile\n+from re import compile as recompile, DOTALL\nfrom base64 import urlsafe_b64encode\nfrom requests import session, cookies\nfrom utils import noop, get_user_agent\n@@ -93,15 +93,15 @@ class NetflixSession(object):\n\"\"\"str: ESN - something like: NFCDCH-MC-D7D6F54LOPY8J416T72MQXX3RD20ME\"\"\"\npage_items = [\n- 'authURL',\n- 'BUILD_IDENTIFIER',\n- 'ICHNAEA_ROOT',\n- 'API_ROOT',\n- 'API_BASE_URL',\n- 'esn',\n+ 'models/userInfo/data/authURL',\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/esnGeneratorModel/data/esn',\n'gpsModel',\n- 'countryOfSignup',\n- 'membershipStatus'\n+ 'models/userInfo/data/countryOfSignup',\n+ 'models/userInfo/data/membershipStatus'\n]\ndef __init__(self, cookie_path, data_path, verify_ssl, nx_common):\n@@ -127,6 +127,17 @@ class NetflixSession(object):\nself.parsed_user_data = {}\nself._init_session()\n+ def extract_json(self, content, name):\n+ # Extract json from netflix content page\n+ json_array = recompile(r\"netflix\\.%s\\s*=\\s*(.*?);\\s*</script>\" % name, DOTALL).findall(content)\n+ if not json_array:\n+ return {} # Return an empty dict if json not found !\n+ json_str = json_array[0]\n+ json_str = json_str.replace('\\\"', '\\\\\"') # Hook for escape double-quotes\n+ json_str = json_str.replace('\\\\s', '\\\\\\\\s') # Hook for escape \\s in json regex\n+ json_str = json_str.decode('unicode_escape') # finally decoding...\n+ return json.loads(json_str, encoding='utf-8', strict=False)\n+\ndef extract_inline_netflix_page_data(self, content='', items=None):\n\"\"\"Extract the essential data from the page contents\nThe contents of the parsable tags looks something like this:\n@@ -138,19 +149,25 @@ class NetflixSession(object):\n:return: List\nList of all the serialized data pulled out of the pages <script/> tags\n\"\"\"\n+ # Uncomment the two lines below for saving content to disk (if ask you for debug)\n+ # DO NOT PASTE THE CONTENT OF THIS FILE PUBLICALLY ON THE INTERNET, IT MAY CONTAIN SENSITIVE INFORMATION\n+ # USE IT ONLY FOR DEBUGGING\n+ # with open(self.data_path + 'raw_content', \"wb\") as f:\n+ # f.write(content)\nself.nx_common.log(msg='Parsing inline data...')\nitems = self.page_items if items is None else items\nuser_data = {'gpsModel': 'harris'}\n- content = content.replace('\\\"', '\\\\\"').encode('utf-8').decode('string_escape')\n- # find <script/> tag witch contains the 'reactContext' globals\n- react_context = recompile(r\"netflix\\.reactContext\\s*=\\s*(.*?);\\s*</script>\").findall(content)\n+ react_context = self.extract_json(content, 'reactContext')\n# iterate over all wanted item keys & try to fetch them\nfor item in items:\n- match = recompile(\n- '\"' + item + '\":(.*?)\"(.+?)\"').findall(react_context[0])\n- if len(match) > 0:\n- _match = match[0][1]\n- user_data.update({item: _match})\n+ keys = item.split(\"/\")\n+ val = None\n+ for key in keys:\n+ val = val.get(key, None) if val else react_context.get(key, None)\n+ if not val:\n+ break\n+ if val:\n+ user_data.update({key: val})\n# fetch profiles & avatars\nprofiles = self.get_profiles(content=content)\n# get guid of active user\n@@ -171,12 +188,8 @@ class NetflixSession(object):\ndef get_profiles(self, content):\n\"\"\"ADD ME\"\"\"\nprofiles = {}\n- # find falkor cache and extract JSON text\n- falkorCache = recompile(r\"netflix\\.falkorCache\\s*=\\s*(.*?);\\s*</script>\").findall(content)\n- if not falkorCache:\n- return profiles\n- falkorDict = json.loads(falkorCache[0])\n- _profiles = falkorDict['profiles']\n+ falkor_cache = self.extract_json(content, 'falkorCache')\n+ _profiles = falkor_cache.get('profiles', {})\nfor guid in _profiles:\nif not isinstance(_profiles[guid], dict):\n@@ -188,7 +201,7 @@ class NetflixSession(object):\nif 'value' in _avatar_path:\n_avatar_path = _avatar_path['value']\n_avatar_path.extend([u'images', u'byWidth', u'320', u'value'])\n- _profile['avatar'] = self.__recursive_dict(_avatar_path, falkorDict)\n+ _profile['avatar'] = self.__recursive_dict(_avatar_path, falkor_cache)\nprofiles.update({guid: _profile})\nreturn profiles\n@@ -240,7 +253,7 @@ class NetflixSession(object):\nif response:\n# parse out the needed inline information\nuser_data, profiles = self.extract_inline_netflix_page_data(\n- content=response.text)\n+ content=response.content)\nself.profiles = profiles\n# if we have profiles, cookie is still valid\nif self.profiles:\n@@ -279,7 +292,7 @@ class NetflixSession(object):\n\"\"\"\npage = self._session_get(component='profiles')\nuser_data, profiles = self.extract_inline_netflix_page_data(\n- content=page.text)\n+ content=page.content)\nlogin_payload = {\n'email': account.get('email'),\n'password': account.get('password'),\n@@ -297,7 +310,7 @@ class NetflixSession(object):\nlogin_response = self._session_post(\ncomponent='login',\ndata=login_payload)\n- user_data = self._parse_page_contents(content=login_response.text)\n+ user_data = self._parse_page_contents(content=login_response.content)\naccount_hash = self._generate_account_hash(account=account)\n# we know that the login was successfull if we find ???\nif user_data.get('membershipStatus') == 'CURRENT_MEMBER':\n@@ -1593,7 +1606,7 @@ class NetflixSession(object):\nresponse = self._session_get(component='profiles')\nif response:\n# parse out the needed inline information\n- page_data = self._parse_page_contents(content=response.text)\n+ page_data = self._parse_page_contents(content=response.content)\nif page_data is None:\nreturn False\naccount_hash = self._generate_account_hash(account=account)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Refactoring extracting json and regex
Refactoring regex and json.loads call's
-Add a method for extracting json from content
-Change regex for grabbing multiline (if endline in string)
-Permits json.loads to parse endline in string too. |
105,992 | 28.05.2018 20:35:02 | -7,200 | 9242fa237d6036b3b3d784a92cbaeb8b3035c95a | Version bump 0.13.7 | [
{
"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.13.6\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.7\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.7 |
106,024 | 28.05.2018 21:11:04 | -7,200 | 0ab2f0bf863ba83d143bf41cc0d2c3f0c277268f | Resolve issue for rating a movie
Fixed a typographical error? to re-allow to evaluate a movie | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -439,7 +439,7 @@ class NetflixSession(object):\n\"\"\"\n# dirty rating validation\n- ratun = int(rating)\n+ rating = int(rating)\nif rating > 10 or rating < 0:\nreturn False\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Resolve issue for rating a movie
Fixed a typographical error? to re-allow to evaluate a movie |
105,992 | 07.06.2018 10:48:36 | -7,200 | 27b4d2f2e37f9e634825b49d5ea6807058be360c | [Fix] don't pass opener in socket::read(self, size=-1) | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -980,7 +980,7 @@ class Navigation(object):\nif urlparse(url).hostname in ('localhost', '127.0.0.1', '::1'):\nopener = urllib2.build_opener(urllib2.ProxyHandler({}))\nurllib2.install_opener(opener)\n- data = urllib2.urlopen(full_url).read(opener)\n+ data = urllib2.urlopen(full_url).read()\nparsed_json = json.loads(data, object_pairs_hook=OrderedDict)\nif 'error' in parsed_json:\nresult = {'error': parsed_json.get('error')}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | [Fix] don't pass opener in socket::read(self, size=-1) |
105,992 | 07.06.2018 13:36:59 | -7,200 | 033a0e2f6678ce023aed34261aea0a7a588feba6 | Fix resource location in addon.xml | [
{
"change_type": "MODIFY",
"old_path": "addon.xml",
"new_path": "addon.xml",
"diff": "<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<assets>\n- <icon>resources\\icon.png</icon>\n- <fanart>resources\\fanart.jpg</fanart>\n- <screenshot>resources\\screenshot-01.jpg</screenshot>\n- <screenshot>resources\\screenshot-02.jpg</screenshot>\n- <screenshot>resources\\screenshot-03.jpg</screenshot>\n+ <icon>resources/icon.png</icon>\n+ <fanart>resources/fanart.jpg</fanart>\n+ <screenshot>resources/screenshot-01.jpg</screenshot>\n+ <screenshot>resources/screenshot-02.jpg</screenshot>\n+ <screenshot>resources/screenshot-03.jpg</screenshot>\n</assets>\n<language>en de es he hr it nl pl pt sk sv</language>\n<platform>all</platform>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix resource location in addon.xml |
105,992 | 07.06.2018 13:38:50 | -7,200 | f29f030ba4b301284e4ed7fc10a75d3313b64f4c | Version bump 0.13.8 | [
{
"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.13.7\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.8\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\nv0.13.0 (2018-04-26)\n- Android support WIDEVINE Cryptosession for MSL\n+\n+v0.13.7 (2018-05-28)\n+- rework of login info parsing\n+\n+v0.13.8 (2018-06-07)\n+- fix proxy communication\n+- fix folder definition for image resources\n</news>\n</extension>\n</addon>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.8 |
105,989 | 11.06.2018 19:43:55 | -7,200 | 007b2bc5960aa6ef001f7d5dd2fc1f0c8d299110 | Use correct poster, landscape and fanart artworks. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -995,16 +995,19 @@ class KodiHelper(object):\n'landscape': '',\n'thumb': '',\n'fanart': '',\n- 'poster': ''\n+ 'poster': '',\n+ 'clearlogo': ''\n})\nif 'boxarts' in dict(entry).keys() and not isinstance(entry.get('boxarts'), dict):\nbig = entry.get('boxarts', '')\nsmall = big\n+ poster = big\nif 'boxarts' in dict(entry).keys() and isinstance(entry.get('boxarts'), dict):\nbig = entry.get('boxarts', {}).get('big')\nsmall = entry.get('boxarts', {}).get('small')\n+ poster = entry.get('boxarts', {}).get('poster')\nart.update({\n- 'poster': big or small,\n+ 'poster': poster,\n'landscape': big or small,\n'thumb': big or small,\n'fanart': big or small\n@@ -1016,10 +1019,18 @@ class KodiHelper(object):\nurl=str(big))\nif 'interesting_moment' in dict(entry).keys():\n+ if entry.get('type') == 'episode':\n+ art.update({'thumb': entry['interesting_moment'],\n+ 'landscape': entry['interesting_moment']})\nart.update({\n- 'poster': entry['interesting_moment'],\n'fanart': entry['interesting_moment']\n})\n+ if 'artwork' in dict(entry).keys():\n+ art.update({\n+ 'fanart': entry['artwork']\n+ })\n+ if 'clearlogo' in dict(entry).keys():\n+ art.update({'clearlogo': entry['clearlogo']})\nif 'thumb' in dict(entry).keys():\nart.update({'thumb': entry['thumb']})\nif 'fanart' in dict(entry).keys():\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -24,6 +24,14 @@ except:\nFETCH_VIDEO_REQUEST_COUNT = 26\n+ART_BILLBOARD_SIZE = '_1920x1080'\n+ART_MOMENT_SIZE_SMALL = '_665x375'\n+ART_MOMENT_SIZE_LARGE = '_1920x1080'\n+ART_BOX_SIZE_POSTER = '_342x684'\n+ART_BOX_SIZE_SMALL = '_665x375'\n+ART_BOX_SIZE_LARGE = '_1920x1080'\n+ART_LOGO_SIZE = '_400x90'\n+\nclass NetflixSession(object):\n\"\"\"Helps with login/session management of Netflix users & API handling\"\"\"\n@@ -823,13 +831,12 @@ class NetflixSession(object):\n# determine artwork\nboxarts = video.get('boxarts', {})\n- bx_small = boxarts.get('_342x192', {}).get('jpg', {}).get('url')\n- bx_big = boxarts.get('_1280x720', {}).get('jpg', {}).get('url')\n- raw_moment = video.get('interestingMoment', {})\n- moment = raw_moment.get('_665x375', {}).get('jpg', {}).get('url')\n- raw_by_type = video.get('artWorkByType', {})\n- billboard = raw_by_type.get('BILLBOARD', {})\n- artwork = billboard.get('_1280x720', {}).get('jpg', {}).get('url')\n+ bx_small = boxarts.get(ART_BOX_SIZE_SMALL, {}).get('jpg', {}).get('url')\n+ bx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ bx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\n+ moment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ logo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\nid: {\n@@ -864,10 +871,12 @@ class NetflixSession(object):\n'maturity': maturity,\n'boxarts': {\n'small': bx_small,\n- 'big': bx_big\n+ 'big': bx_big,\n+ 'poster': bx_poster\n},\n'interesting_moment': moment,\n'artwork': artwork,\n+ 'clearlogo': logo\n}\n}\n@@ -1175,8 +1184,14 @@ class NetflixSession(object):\n}\n}\n\"\"\"\n- raw_moment = video.get('interestingMoment', {})\n- moment = raw_moment.get('_665x375', {}).get('jpg', {}).get('url')\n+ # determine artwork\n+ boxarts = video.get('boxarts', {})\n+ bx_small = boxarts.get(ART_BOX_SIZE_SMALL, {}).get('jpg', {}).get('url')\n+ bx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ bx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\n+ moment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ logo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\nseason['summary']['id']: {\n'idx': sorting[season['summary']['id']],\n@@ -1184,10 +1199,14 @@ class NetflixSession(object):\n'text': season['summary']['name'],\n'shortName': season['summary']['shortName'],\n'boxarts': {\n- 'small': video['boxarts']['_342x192']['jpg']['url'],\n- 'big': video['boxarts']['_1280x720']['jpg']['url']\n+ 'small': bx_small,\n+ 'big': bx_big,\n+ 'poster': bx_poster\n},\n'interesting_moment': moment,\n+ 'artwork': artwork,\n+ 'clearlogo': logo,\n+ 'type': 'season'\n}\n}\n@@ -1311,8 +1330,14 @@ class NetflixSession(object):\nrating = episode.get('userRating', {}).get('predicted', 0)\nrating = episode.get('userRating', {}).get('average', rating)\n- raw_moment = episode.get('interestingMoment', {})\n- moment = raw_moment.get('_1280x720', {}).get('jpg', {}).get('url')\n+ # determine artwork\n+ boxarts = episode.get('boxarts', {})\n+ bx_small = boxarts.get(ART_BOX_SIZE_SMALL, {}).get('jpg', {}).get('url')\n+ bx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ bx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\n+ moment = episode.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n+ artwork = episode.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ logo = episode.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\nepisode['summary']['id']: {\n@@ -1330,13 +1355,18 @@ class NetflixSession(object):\n'maturity': episode['maturity'],\n'playcount': (0, 1)[episode.get('watched')],\n'rating': rating,\n- 'thumb': episode['interestingMoment']['_665x375']['jpg']['url'],\n- 'fanart': moment,\n- 'poster': episode['boxarts']['_1280x720']['jpg']['url'],\n- 'banner': episode['boxarts']['_342x192']['jpg']['url'],\n'mediatype': episode.get('summary', {}).get('type', 'movie'),\n'my_list': episode['queue']['inQueue'],\n- 'bookmark': episode['bookmarkPosition']\n+ 'bookmark': episode['bookmarkPosition'],\n+ 'boxarts': {\n+ 'small': bx_small,\n+ 'big': bx_big,\n+ 'poster': bx_poster\n+ },\n+ 'interesting_moment': moment,\n+ 'artwork': artwork,\n+ 'clearlogo': logo,\n+ 'type': 'episode'\n}\n}\n@@ -1398,12 +1428,14 @@ class NetflixSession(object):\npaths = [\nitem_path + item_titles + item_pagination + ['reference', ['summary', 'releaseYear', 'title', 'synopsis', 'regularSynopsis', 'evidence', 'queue', 'episodeCount', 'info', 'maturity', 'runtime', 'seasonCount', 'releaseYear', 'userRating', 'numSeasonsLabel', 'bookmarkPosition', 'watched', 'delivery', 'seasonList', 'current']],\n- item_path + item_titles + item_pagination + ['reference', 'bb2OGLogo', '_400x90', 'png'],\n- item_path + item_titles + item_pagination + ['reference', 'boxarts', '_342x192', 'jpg'],\n- item_path + item_titles + item_pagination + ['reference', 'boxarts', '_1280x720', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n+ item_path + item_titles + item_pagination + ['reference', 'boxarts', ART_BOX_SIZE_SMALL, 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\nitem_path + item_titles + item_pagination + ['reference', 'storyarts', '_1632x873', 'jpg'],\n- item_path + item_titles + item_pagination + ['reference', 'interestingMoment', '_665x375', 'jpg'],\n- item_path + item_titles + item_pagination + ['reference', 'artWorkByType', 'BILLBOARD', '_1280x720', 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg'],\nitem_path + item_titles + item_pagination + ['reference', 'cast', {'from': 0, 'to': 15}, ['id', 'name']],\nitem_path + item_titles + item_pagination + ['reference', 'cast', 'summary'],\nitem_path + item_titles + item_pagination + ['reference', 'genres', {'from': 0, 'to': 5}, ['id', 'name']],\n@@ -1449,12 +1481,14 @@ class NetflixSession(object):\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'tags', 'summary'],\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", ['creators', 'directors'], {'from': 0, 'to': 49}, ['id', 'name']],\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", ['creators', 'directors'], 'summary'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'bb2OGLogo', '_400x90', 'png'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', '_342x192', 'jpg'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', '_1280x720', 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', ART_BOX_SIZE_SMALL, 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'storyarts', '_1632x873', 'jpg'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', '_665x375', 'jpg'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'artWorkByType', 'BILLBOARD', '_1280x720', 'jpg']\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\n@@ -1543,10 +1577,14 @@ class NetflixSession(object):\npaths = [\n['videos', id, 'seasonList', {'from': list_from, 'to': list_to}, 'summary'],\n['videos', id, 'seasonList', 'summary'],\n- ['videos', id, 'boxarts', '_342x192', 'jpg'],\n- ['videos', id, 'boxarts', '_1280x720', 'jpg'],\n+ ['videos', id, 'boxarts', ART_BOX_SIZE_SMALL, 'jpg'],\n+ ['videos', id, 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n+ ['videos', id, 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\n['videos', id, 'storyarts', '_1632x873', 'jpg'],\n- ['videos', id, 'interestingMoment', '_665x375', 'jpg']\n+ ['videos', id, 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n+ ['videos', id, 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n+ ['videos', id, 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n+ ['videos', id, 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\nreturn self._process_response(response=response, component='Seasons')\n@@ -1584,10 +1622,13 @@ class NetflixSession(object):\n# ['videos', season_id, ['creators', 'directors'], 'summary'],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'genres', {'from': 0, 'to': 1}, ['id', 'name']],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'genres', 'summary'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'interestingMoment', '_1280x720', 'jpg'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'interestingMoment', '_665x375', 'jpg'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', '_342x192', 'jpg'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', '_1280x720', 'jpg']\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_SMALL, 'jpg'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\nreturn self._process_response(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Use correct poster, landscape and fanart artworks. |
106,024 | 13.06.2018 23:48:49 | -7,200 | f0c525652850250ed356695c568682d79174e3d2 | Add continueWatching to user_list
Add 'continueWatching' to user_list to permit retrieving list_id of it. | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -427,7 +427,7 @@ class Navigation(object):\nuser_data = self._check_response(self.call_netflix_service({\n'method': 'get_user_data'}))\nif user_data:\n- user_list = ['queue', 'topTen', 'netflixOriginals',\n+ user_list = ['queue', 'topTen', 'netflixOriginals', 'continueWatching',\n'trendingNow', 'newRelease', 'popularTitles']\nif str(type) in user_list and video_list_id is None:\nvideo_list_id = self.list_id_for_type(type)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add continueWatching to user_list
Add 'continueWatching' to user_list to permit retrieving list_id of it. |
105,992 | 14.06.2018 11:42:17 | -7,200 | 729550102b7b06c4635da0cfc963b86d601e0ef0 | Fix login / adapt netflix typo correction | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -188,7 +188,7 @@ class NetflixSession(object):\ndef get_profiles(self, content):\n\"\"\"ADD ME\"\"\"\nprofiles = {}\n- falkor_cache = self.extract_json(content, 'falkorCache')\n+ falkor_cache = self.extract_json(content, 'falcorCache')\n_profiles = falkor_cache.get('profiles', {})\nfor guid in _profiles:\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix login / adapt netflix typo correction |
105,989 | 14.06.2018 12:01:17 | -7,200 | 2cb77113ed54a5780d169e390d7825df1035f087 | Add query parameter widget_display to suppress setting custom view modes | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -266,7 +266,8 @@ class KodiHelper(object):\nreturn xbmcplugin.endOfDirectory(handle=self.plugin_handle)\n- def build_main_menu_listing(self, video_list_ids, user_list_order, actions, build_url):\n+ def build_main_menu_listing(self, video_list_ids, user_list_order, actions,\n+ build_url, widget_display=False):\n\"\"\"\nBuilds the video lists (my list, continue watching, etc.) Kodi screen\n@@ -394,10 +395,13 @@ class KodiHelper(object):\npreselected_list_item = idx + 1 if self.get_main_menu_selection() == 'search' else preselected_list_item\nif preselected_list_item is not None:\nxbmc.executebuiltin('ActivateWindowAndFocus(%s, %s)' % (str(xbmcgui.Window(xbmcgui.getCurrentWindowId()).getFocusId()), str(preselected_list_item)))\n+ if not widget_display:\nself.set_custom_view(VIEW_FOLDER)\nreturn True\n- def build_video_listing(self, video_list, actions, type, build_url, has_more=False, start=0, current_video_list_id=\"\"):\n+ def build_video_listing(self, video_list, actions, type, build_url,\n+ has_more=False, start=0, current_video_list_id=\"\",\n+ widget_display=False):\n\"\"\"\nBuilds the video lists (my list, continue watching, etc.)\ncontents Kodi screen\n@@ -498,11 +502,12 @@ class KodiHelper(object):\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(view)\nreturn True\n- def build_video_listing_exported(self, content, build_url):\n+ def build_video_listing_exported(self, content, build_url, widget_display=False):\n\"\"\"Build list of exported movies / shows\nParameters\n@@ -587,10 +592,11 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_FOLDER)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(VIEW_EXPORTED)\nreturn True\n- def build_search_result_folder(self, build_url, term):\n+ def build_search_result_folder(self, build_url, term, widget_display=False):\n\"\"\"Add search result folder\nParameters\n@@ -624,6 +630,7 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_FOLDER)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(VIEW_FOLDER)\nreturn url_rec\n@@ -703,7 +710,8 @@ class KodiHelper(object):\nself.dialogs.show_no_search_results_notify()\nreturn xbmcplugin.endOfDirectory(self.plugin_handle)\n- def build_user_sub_listing(self, video_list_ids, type, action, build_url):\n+ def build_user_sub_listing(self, video_list_ids, type, action, build_url,\n+ widget_display=False):\n\"\"\"\nBuilds the video lists screen for user subfolders\n(genres & recommendations)\n@@ -746,10 +754,11 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_FOLDER)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(VIEW_FOLDER)\nreturn True\n- def build_season_listing(self, seasons_sorted, build_url):\n+ def build_season_listing(self, seasons_sorted, build_url, widget_display=False):\n\"\"\"Builds the season list screen for a show\nParameters\n@@ -805,10 +814,11 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_SEASON)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(VIEW_SEASON)\nreturn True\n- def build_episode_listing(self, episodes_sorted, build_url):\n+ def build_episode_listing(self, episodes_sorted, build_url, widget_display=False):\n\"\"\"Builds the episode list screen for a season of a show\nParameters\n@@ -873,6 +883,7 @@ class KodiHelper(object):\nhandle=self.plugin_handle,\ncontent=CONTENT_EPISODE)\nxbmcplugin.endOfDirectory(self.plugin_handle)\n+ if not widget_display:\nself.set_custom_view(VIEW_EPISODE)\nreturn True\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -20,6 +20,7 @@ import urllib2\nfrom urlparse import parse_qsl, urlparse\nfrom datetime import datetime\nfrom collections import OrderedDict\n+from distutils.util import strtobool\nimport xbmc\nimport resources.lib.NetflixSession as Netflix\n@@ -79,6 +80,7 @@ class Navigation(object):\naction = params.get('action', None)\np_type = params.get('type', None)\np_type_not_search_export = p_type != 'search' and p_type != 'exported'\n+ widget_display = bool(strtobool(params.get('widget_display', 'false')))\n# open foreign settings dialog\nif 'mode' in params.keys() and params['mode'] == 'openSettings':\n@@ -119,7 +121,7 @@ class Navigation(object):\nself.call_netflix_service({\n'method': 'switch_profile',\n'profile_id': profile_id})\n- return self.show_video_lists()\n+ return self.show_video_lists(widget_display)\nreturn self.show_profiles()\nelif action == 'save_autologin':\n# save profile id and name to settings for autologin\n@@ -130,7 +132,7 @@ class Navigation(object):\nelif action == 'video_lists':\n# list lists that contain other lists\n# (starting point with recommendations, search, etc.)\n- return self.show_video_lists()\n+ return self.show_video_lists(widget_display=widget_display)\nelif action == 'video_list':\n# show a list of shows/movies\ntype = None if 'type' not in params.keys() else params['type']\n@@ -138,19 +140,22 @@ class Navigation(object):\nvideo_list = self.show_video_list(\nvideo_list_id=params.get('video_list_id'),\ntype=type,\n- start=start)\n+ start=start,\n+ widget_display=widget_display)\nreturn video_list\nelif action == 'season_list':\n# list of seasons for a show\nseasons = self.show_seasons(\nshow_id=params.get('show_id'),\n- tvshowtitle=params.get('tvshowtitle'))\n+ tvshowtitle=params.get('tvshowtitle'),\n+ widget_display=widget_display)\nreturn seasons\nelif action == 'episode_list':\n# list of episodes for a season\nepisode_list = self.show_episode_list(\nseason_id=params.get('season_id'),\n- tvshowtitle=params.get('tvshowtitle'))\n+ tvshowtitle=params.get('tvshowtitle'),\n+ widget_display=widget_display)\nreturn episode_list\nelif action == 'rating':\nreturn self.rate_on_netflix(video_id=params['id'])\n@@ -202,7 +207,8 @@ class Navigation(object):\nreturn True\nelif action == 'user-items' and p_type_not_search_export:\n# display the lists (recommendations, genres, etc.)\n- return self.show_user_list(type=params['type'])\n+ return self.show_user_list(type=params['type'],\n+ widget_display=widget_display)\nelif action == 'play_video':\n# play a video, check for adult pin if needed\nadult_pin = None\n@@ -229,7 +235,8 @@ class Navigation(object):\nif term:\nresult_folder = self.kodi_helper.build_search_result_folder(\nbuild_url=self.build_url,\n- term=term)\n+ term=term,\n+ widget_display=widget_display)\nreturn self.kodi_helper.set_location(url=result_folder)\nelif action == 'search_result':\nreturn self.show_search_results(params.get('term'))\n@@ -239,7 +246,8 @@ class Navigation(object):\n# list exported movies/shows\nexported = self.kodi_helper.build_video_listing_exported(\ncontent=self.library.list_exported_media(),\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ widget_display=widget_display)\nreturn exported\nelse:\nraise ValueError('Invalid paramstring: {0}!'.format(paramstring))\n@@ -306,7 +314,7 @@ class Navigation(object):\nself.kodi_helper.dialogs.show_no_search_results_notify()\nreturn False\n- def show_user_list(self, type):\n+ def show_user_list(self, type, widget_display=False):\n\"\"\"\nList the users lists for shows/movies for\nrecommendations/genres based on the given type\n@@ -329,11 +337,12 @@ class Navigation(object):\nvideo_list_ids=video_list_ids[type],\ntype=type,\naction='video_list',\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ widget_display=widget_display)\nreturn sub_list\nreturn False\n- def show_episode_list(self, season_id, tvshowtitle):\n+ def show_episode_list(self, season_id, tvshowtitle, widget_display=False):\n\"\"\"Lists all episodes for a given season\nParameters\n@@ -363,11 +372,12 @@ class Navigation(object):\n# list the episodes\nepisodes_list = self.kodi_helper.build_episode_listing(\nepisodes_sorted=episodes_sorted,\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ widget_display=widget_display)\nreturn episodes_list\nreturn False\n- def show_seasons(self, show_id, tvshowtitle):\n+ def show_seasons(self, show_id, tvshowtitle, widget_display=False):\n\"\"\"Lists all seasons for a given show\nParameters\n@@ -404,11 +414,13 @@ class Navigation(object):\nseason['tvshowtitle'] = tvshowtitle\nseason_list = self.kodi_helper.build_season_listing(\nseasons_sorted=seasons_sorted,\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ widget_display=widget_display)\nreturn season_list\nreturn False\n- def show_video_list(self, video_list_id, type, start=0):\n+ def show_video_list(self, video_list_id, type, start=0,\n+ widget_display=False):\n\"\"\"List shows/movies based on the given video list id\nParameters\n@@ -460,11 +472,12 @@ class Navigation(object):\nbuild_url=self.build_url,\nhas_more=has_more,\nstart=start,\n- current_video_list_id=video_list_id)\n+ current_video_list_id=video_list_id,\n+ widget_display=widget_display)\nreturn listing\nreturn False\n- def show_video_lists(self):\n+ def show_video_lists(self, widget_display=False):\n\"\"\"List the users video lists (recommendations, my list, etc.)\"\"\"\nuser_data = self._check_response(self.call_netflix_service({\n'method': 'get_user_data'}))\n@@ -492,7 +505,8 @@ class Navigation(object):\nvideo_list_ids=video_list_ids,\nuser_list_order=user_list_order,\nactions=actions,\n- build_url=self.build_url)\n+ build_url=self.build_url,\n+ widget_display=widget_display)\nreturn listing\nreturn False\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add query parameter widget_display to suppress setting custom view modes |
105,992 | 14.06.2018 12:18:22 | -7,200 | 1e2be7349f5ed5909a1a10f832bfa89a7bba2665 | Version bump 0.13.9 | [
{
"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.13.8\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.9\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n@@ -47,6 +47,9 @@ v0.13.7 (2018-05-28)\nv0.13.8 (2018-06-07)\n- fix proxy communication\n- fix folder definition for image resources\n+\n+v0.13.9 (2018-06-14)\n+- fix login issues after typo fix in netflix login page\n</news>\n</extension>\n</addon>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Version bump 0.13.9 |
105,992 | 16.06.2018 11:46:07 | -7,200 | 7325d08d9b826b053e2292f6ae80e617096f1b6c | version bump 0.13.10 | [
{
"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.13.9\" provider-name=\"libdev + jojo + asciidisco\">\n+<addon id=\"plugin.video.netflix\" name=\"Netflix\" version=\"0.13.10\" provider-name=\"libdev + jojo + asciidisco\">\n<requires>\n<import addon=\"xbmc.python\" version=\"2.25.0\"/>\n<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | version bump 0.13.10 |
105,992 | 02.07.2018 18:04:46 | -7,200 | 6fbe820e9391b9f5567e9f3c5eaacaaed7ff76a4 | raise systemexit to allow proper shutdown | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -2000,6 +2000,9 @@ class NetflixSession(object):\nparams=params,\nheaders=headers,\nverify=self.verify_ssl)\n+ except SystemExit:\n+ self.nx_common.log(msg='[POST] system error arrived -> exiting')\n+ raise\nexcept:\nexc = sys.exc_info()\nself.nx_common.log(msg='[POST] Error {} {}'.format(exc[0], exc[1]))\n@@ -2039,6 +2042,9 @@ class NetflixSession(object):\nurl=url,\nverify=self.verify_ssl,\nparams=params)\n+ except SystemExit:\n+ self.nx_common.log(msg='[GET] system error arrived -> exiting')\n+ raise\nexcept:\nexc = sys.exc_info()\nself.nx_common.log(msg='[GET] Error {} {}'.format(exc[0], exc[1]))\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | raise systemexit to allow proper shutdown |
105,989 | 26.07.2018 01:11:38 | -7,200 | 516ad8af7328e7e49f9c744188209a6df08f9329 | Add skip intro and skip recap feature | [
{
"change_type": "MODIFY",
"old_path": "resources/language/resource.language.en_gb/strings.po",
"new_path": "resources/language/resource.language.en_gb/strings.po",
"diff": "@@ -317,13 +317,25 @@ msgid \"View for exported\"\nmsgstr \"\"\nmsgctxt \"#30075\"\n-msgid \"Ask to skip credits\"\n+msgid \"Ask to skip intro and recap\"\nmsgstr \"\"\nmsgctxt \"#30076\"\n-msgid \"Skip back\"\n+msgid \"Skip intro\"\nmsgstr \"\"\nmsgctxt \"#30077\"\n-msgid \"Skip intro\"\n+msgid \"Skip recap\"\n+msgstr \"\"\n+\n+msgctxt \"#30078\"\n+msgid \"Playback\"\n+msgstr \"\"\n+\n+msgctxt \"#30079\"\n+msgid \"Skip automatically\"\n+msgstr \"\"\n+\n+msgctxt \"#30080\"\n+msgid \"Don't pause when skipping\"\nmsgstr \"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -45,7 +45,7 @@ TAGGED_WINDOW_ID = 10000\nPROP_NETFLIX_PLAY = 'netflix_playback'\nPROP_PLAYBACK_INIT = 'initialized'\nPROP_PLAYBACK_TRACKING = 'tracking'\n-PROP_METADATA = 'netflix_metadata'\n+PROP_TIMELINE_MARKERS = 'netflix_timeline_markers'\ndef _update_if_present(source_dict, source_att, target_dict, target_att):\nif source_dict.get(source_att):\n@@ -877,7 +877,7 @@ class KodiHelper(object):\nself.set_custom_view(VIEW_EPISODE)\nreturn True\n- def play_item(self, video_id, start_offset=-1, infoLabels={}, metadata={}):\n+ def play_item(self, video_id, start_offset=-1, infoLabels={}, timeline_markers={}):\n\"\"\"Plays a video\nParameters\n@@ -969,10 +969,10 @@ class KodiHelper(object):\nsucceeded=True,\nlistitem=play_item)\n- # set window property to store metadata (skip intro, etc...)\n+ # set window property to store intro markers\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_METADATA,\n- json.dumps(metadata)\n+ PROP_TIMELINE_MARKERS,\n+ pickle.dumps(timeline_markers)\n)\n# set window property to enable recognition of playbacks\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "# Module: KodiMonitor\n# Created on: 08.02.2018\n# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=line-too-long\n\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\nimport json\n+try:\n+ import cPickle as pickle\n+except:\n+ import pickle\n+\nimport xbmc\nimport xbmcgui\n-from xbmcaddon import Addon\n-from resources.lib.utils import noop, log\n+from resources.lib.utils import noop\n+from resources.lib.kodi.skip import Skip\nfrom resources.lib.KodiHelper import TAGGED_WINDOW_ID, \\\nPROP_NETFLIX_PLAY, PROP_PLAYBACK_INIT, PROP_PLAYBACK_TRACKING, \\\n- PROP_METADATA\n+ PROP_TIMELINE_MARKERS\n+\ndef _get_safe_with_fallback(item, fallback, **kwargs):\nitemkey = kwargs.get('itemkey', 'title')\n@@ -56,6 +63,11 @@ def _get_active_video_player():\nNone)\n+def _is_playback_status(status):\n+ return xbmcgui.Window(TAGGED_WINDOW_ID).getProperty(\n+ PROP_NETFLIX_PLAY) == status\n+\n+\ndef _first_match_or_none(mediatype, item, candidates, item_fb, match_fn):\nreturn next(({'dbtype': mediatype,\n'dbid': candidate['{}id'.format(mediatype)],\n@@ -126,6 +138,21 @@ def _seek(player_id, milliseconds):\n})\n+def is_initialized_playback():\n+ \"\"\"\n+ Indicates if a playback was initiated by the netflix addon by\n+ checking the appropriate window property set by KodiHelper.\n+ \"\"\"\n+ return _is_playback_status(PROP_PLAYBACK_INIT)\n+\n+\n+def is_netflix_playback():\n+ \"\"\"\n+ Indicates if an ongoing playback is from netflix addon\n+ \"\"\"\n+ return _is_playback_status(PROP_PLAYBACK_TRACKING)\n+\n+\nclass KodiMonitor(xbmc.Monitor):\n\"\"\"\nTracks status and progress of video playbacks initiated by the addon and\n@@ -138,32 +165,18 @@ class KodiMonitor(xbmc.Monitor):\nself.nx_common = nx_common\nself.video_info = None\nself.progress = 0\n+ self.elapsed = 0\nself.log = log_fn\n- self.credit_markers = None\n-\n- def is_initialized_playback(self):\n- \"\"\"\n- Indicates if a playback was initiated by the netflix addon by\n- checking the appropriate window property set by KodiHelper.\n- \"\"\"\n- return self._is_playback_status(PROP_PLAYBACK_INIT)\n-\n- def is_tracking_playback(self):\n- \"\"\"\n- Indicates if an ongoing playback is actively tracked by an\n- instance of this class.\n- \"\"\"\n- return (self.video_info is not None and\n- self._is_playback_status(PROP_PLAYBACK_TRACKING))\n+ self.timeline_markers = {}\n# @log\n- def update_playback_progress(self):\n+ def on_playback_tick(self):\n\"\"\"\nUpdates the internal progress status of a tracked playback\nand saves bookmarks to Kodi library.\n\"\"\"\n- if not self.is_tracking_playback():\n- return None\n+ if not is_netflix_playback():\n+ return\nplayer_id = _get_active_video_player()\ntry:\n@@ -172,12 +185,24 @@ class KodiMonitor(xbmc.Monitor):\n'properties': ['percentage', 'time']\n})\nexcept IOError:\n- return None\n- elapsed = (progress['time']['hours'] * 3600 +\n+ return\n+ self.elapsed = (progress['time']['hours'] * 3600 +\nprogress['time']['minutes'] * 60 +\nprogress['time']['seconds'])\nself.progress = progress['percentage']\n- return self._update_item_details({'resume': {'position': elapsed}})\n+\n+ if self.nx_common.get_addon().getSetting('skip_credits') == 'true':\n+ for section in ['recap', 'credit']:\n+ section_markers = self.timeline_markers['credit_markers'].get(\n+ section)\n+ if (section_markers and\n+ self.elapsed >= section_markers['start'] and\n+ self.elapsed < section_markers['end']):\n+ self._skip(section)\n+ del self.timeline_markers['credit_markers'][section]\n+\n+ if self.video_info:\n+ self._update_item_details({'resume': {'position': self.elapsed}})\ndef onNotification(self, sender, method, data):\n\"\"\"\n@@ -195,15 +220,11 @@ class KodiMonitor(xbmc.Monitor):\ndef _on_playback_started(self, item):\nplayer_id = _retry(_get_active_video_player, 5)\n- if player_id is not None and self.is_initialized_playback():\n+ if player_id is not None and is_initialized_playback():\nself.video_info = self._get_video_info(player_id, item)\nself.progress = 0\n- try:\n- metadata = xbmcgui.Window(TAGGED_WINDOW_ID).getProperty(PROP_METADATA)\n- metadata = json.loads(metadata)\n- except:\n- metadata = {}\n- self.credit_markers = metadata.get('video', {}).get('creditMarkers', None)\n+ self.elapsed = 0\n+ self._grab_timeline_markers()\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\nPROP_NETFLIX_PLAY,\nPROP_PLAYBACK_TRACKING)\n@@ -214,16 +235,19 @@ class KodiMonitor(xbmc.Monitor):\n# we overwrite it with an arbitrary value\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\nPROP_NETFLIX_PLAY, 'notnetflix')\n- self.credit_markers = None\nself.log('Not tracking playback: {}'\n.format('Playback not initiated by netflix plugin'\n- if self.is_initialized_playback() else\n+ if is_initialized_playback() else\n'Unable to obtain active video player'))\n# @log\ndef _on_playback_stopped(self):\n- if self.is_tracking_playback():\n- if self.progress >= 90:\n+ if is_netflix_playback() and self.video_info:\n+ if (('watched_to_end_offset' in self.timeline_markers and\n+ (self.elapsed >=\n+ self.timeline_markers['watched_to_end_offset'])) or\n+ ('watched_to_end_offset' not in self.timeline_markers and\n+ self.progress >= 90)):\nnew_playcount = self.video_info.get('playcount', 0) + 1\nself._update_item_details({'playcount': new_playcount,\n'resume': {'position': 0}})\n@@ -231,13 +255,53 @@ class KodiMonitor(xbmc.Monitor):\nelse:\naction = ('not marking {} as watched, progress too little'\n.format(self.video_info))\n- self.credit_markers = None\nself.log('Tracked playback stopped: {}'.format(action))\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\nPROP_NETFLIX_PLAY, 'stopped')\n+ xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n+ PROP_TIMELINE_MARKERS, '')\nself.video_info = None\nself.progress = 0\n+ self.elapsed = 0\n+ self.timeline_markers = {}\n+\n+ def _skip(self, section):\n+ addon = self.nx_common.get_addon()\n+ label_code = 30076 if section == 'credit' else 30077\n+ label = addon.getLocalizedString(label_code)\n+ if addon.getSetting('auto_skip_credits') == 'true':\n+ player = xbmc.Player()\n+ dlg = xbmcgui.Dialog()\n+ dlg.notification('Netflix', '{}...'.format(label),\n+ xbmcgui.NOTIFICATION_INFO, 5000)\n+ if addon.getSetting('skip_enabled_no_pause') == 'true':\n+ player.seekTime(\n+ self.timeline_markers['credit_markers'][section]['end'])\n+ else:\n+ player.pause()\n+ xbmc.sleep(1) # give kodi the chance to execute\n+ player.seekTime(\n+ self.timeline_markers['credit_markers'][section]['end'])\n+ xbmc.sleep(1) # give kodi the chance to execute\n+ player.pause() # unpause playback at seek position\n+ else:\n+ dlg = Skip(\"plugin-video-netflix-Skip.xml\",\n+ self.nx_common.get_addon().getAddonInfo('path'),\n+ \"default\", \"1080i\", section=section,\n+ skip_to=self.timeline_markers['credit_markers']\n+ [section]['end'],\n+ label=label)\n+ # close skip intro dialog after time\n+ dialog_duration = (\n+ self.timeline_markers['credit_markers'][section]['end'] -\n+ self.timeline_markers['credit_markers'][section]['start'])\n+ seconds = dialog_duration % 60\n+ minutes = (dialog_duration - seconds) / 60\n+ xbmc.executebuiltin(\n+ 'AlarmClock(closedialog,Dialog.Close(all,true),{:02d}:{:02d},silent)'\n+ .format(minutes, seconds))\n+ dlg.doModal()\n# @log\ndef _get_video_info(self, player_id, fallback_data):\n@@ -266,38 +330,33 @@ class KodiMonitor(xbmc.Monitor):\nparams.update(properties)\nreturn _json_rpc(method, params)\n- def _is_playback_status(self, status):\n- return xbmcgui.Window(TAGGED_WINDOW_ID).getProperty(\n- PROP_NETFLIX_PLAY) == status\n-\n- def check_skip_intro(self):\n- player_id = _get_active_video_player()\n- if player_id > 0 and self.credit_markers:\n+ def _grab_timeline_markers(self):\n+ self.timeline_markers = {'credit_markers': {}}\ntry:\n- progress = _json_rpc('Player.GetProperties', {\n- 'playerid': player_id,\n- 'properties': ['percentage', 'time']\n- })\n- except IOError:\n- return None\n- elapsed = (progress['time']['hours'] * 3600 +\n- progress['time']['minutes'] * 60 +\n- progress['time']['seconds']) * 1000\n- recap = self.credit_markers.get('recap', None)\n- if recap:\n- if elapsed >= recap.get('start', 0) and elapsed < recap.get('end'):\n- if xbmcgui.Dialog().yesno('Netflix', Addon().getLocalizedString(30076),\n- autoclose=recap.get('end') - elapsed):\n- _seek(player_id, recap.get('end'))\n- else:\n- del self.credit_markers['recap']\n- credit = self.credit_markers.get('credit', None)\n- if credit:\n- if elapsed >= credit.get('start', 0) and elapsed < credit.get('end'):\n- if xbmcgui.Dialog().yesno('Netflix', Addon().getLocalizedString(30077),\n- autoclose=credit.get('end') - elapsed):\n- _seek(player_id, credit.get('end'))\n- else:\n- del self.credit_markers['credit']\n- else:\n- return False\n+ timeline_markers = pickle.loads(xbmcgui.Window(\n+ TAGGED_WINDOW_ID).getProperty(PROP_TIMELINE_MARKERS))\n+ except:\n+ self.nx_common.log('No timeline markers found')\n+ return\n+\n+ if timeline_markers['end_credits_offset'] is not None:\n+ self.timeline_markers['end_credits_offset'] = (\n+ timeline_markers['end_credits_offset'])\n+\n+ if timeline_markers['watched_to_end_offset'] is not None:\n+ self.timeline_markers['watched_to_end_offset'] = (\n+ timeline_markers['watched_to_end_offset'])\n+\n+ if timeline_markers['credit_markers']['credit']['start'] is not None:\n+ self.timeline_markers['credit_markers']['credit'] = {\n+ 'start': int(timeline_markers['credit_markers']['credit']['start']/ 1000),\n+ 'end': int(timeline_markers['credit_markers']['credit']['end'] / 1000)\n+ }\n+\n+ if timeline_markers['credit_markers']['recap']['start'] is not None:\n+ self.timeline_markers['credit_markers']['recap'] = {\n+ 'start': int(timeline_markers['credit_markers']['recap']['start'] / 1000),\n+ 'end': int(timeline_markers['credit_markers']['recap']['end'] / 1000)\n+ }\n+\n+ self.nx_common.log('Found timeline markers: {}'.format(self.timeline_markers))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -246,6 +246,25 @@ class Navigation(object):\nxbmc.executebuiltin('Container.Refresh')\nreturn True\n+ def _get_credit_markers_for_episode(self, metadata, episode_id):\n+ if not (metadata and\n+ 'video' in metadata and\n+ metadata['video'].get('type') == 'show'):\n+ return {}\n+\n+ for season in metadata['video']['seasons']:\n+ for episode in season['episodes']:\n+ self.nx_common.log('Looking at S{}E{}: episode[id]={} <=> {}'.format(season['seq'], episode['seq'], episode['id'], episode_id))\n+ if str(episode['id']) == episode_id:\n+ return {\n+ 'end_credits_offset': episode.get('creditsOffset'),\n+ 'watched_to_end_offset': episode.get('watchedToEndOffset'),\n+ 'credit_markers': episode.get('creditMarkers')\n+ }\n+\n+ self.nx_common.log('Could not find metadata for episode')\n+ return {}\n+\n@log\ndef play_video(self, video_id, start_offset, infoLabels):\n\"\"\"Starts video playback\n@@ -268,19 +287,18 @@ class Navigation(object):\nexcept:\ninfoLabels = {}\n- try:\nmetadata = self._check_response(self.call_netflix_service({\n'method': 'fetch_metadata',\n'video_id': video_id\n}))\n- except:\n- metadata = {}\n+\n+ timeline_markers = self._get_credit_markers_for_episode(metadata, video_id)\nplay = self.kodi_helper.play_item(\nvideo_id=video_id,\nstart_offset=start_offset,\ninfoLabels=infoLabels,\n- metadata=metadata)\n+ timeline_markers=timeline_markers)\nreturn play\n@log\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/kodi/skip.py",
"diff": "+# pylint: disable=invalid-name,missing-docstring,attribute-defined-outside-init\n+from platform import machine\n+\n+import xbmc\n+import xbmcgui\n+\n+\n+ACTION_PLAYER_STOP = 13\n+OS_MACHINE = machine()\n+\n+\n+class Skip(xbmcgui.WindowXMLDialog):\n+ \"\"\"\n+ Dialog for skipping video parts (intro, recap, ...)\n+ \"\"\"\n+ def __init__(self, *args, **kwargs):\n+ self.skip_to = kwargs['skip_to']\n+ self.section = kwargs['section']\n+ self.label = kwargs['label']\n+ if OS_MACHINE[0:5] == 'armv7':\n+ xbmcgui.WindowXMLDialog.__init__(self)\n+ else:\n+ xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+\n+ def onInit(self):\n+ self.action_exitkeys_id = [10, 13]\n+ self.getControl(6012).setLabel(self.label)\n+\n+ def onClick(self, controlID):\n+ if controlID == 6012:\n+ xbmc.Player().seekTime(self.skip_to)\n+ self.close()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"viewmodeseason\" type=\"number\" label=\"30042\" enable=\"eq(-5,true)\" default=\"504\"/>\n<setting id=\"viewmodeepisode\" type=\"number\" label=\"30043\" enable=\"eq(-6,true)\" default=\"55\"/>\n<setting id=\"viewmodeexported\" type=\"number\" label=\"30074\" enable=\"eq(-7,true)\" default=\"504\"/>\n- <setting id=\"showskipcredits\" type=\"bool\" label=\"30075\" default=\"true\"/>\n+ </category>\n+ <category label=\"30078\">\n+ <setting id=\"skip_credits\" type=\"bool\" label=\"30075\" default=\"true\"/>\n+ <setting id=\"auto_skip_credits\" type=\"bool\" label=\"30079\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n+ <setting id=\"skip_enabled_no_pause\" type=\"bool\" label=\"30080\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n</category>\n<category label=\"30023\">\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/skins/default/1080i/plugin-video-netflix-Skip.xml",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<window>\n+ <defaultcontrol always=\"true\">6012</defaultcontrol>\n+ <zorder>0</zorder>\n+ <controls>\n+ <control type=\"group\">\n+ <right>30</right>\n+ <bottom>60</bottom>\n+ <height>80</height>\n+ <width>180</width>\n+ <control type=\"group\">\n+ <control type=\"button\" id=\"6012\">\n+ <description>Skip intro</description>\n+ <width>180</width>\n+ <height>80</height>\n+ <font>font12</font>\n+ <label>to be overwritten</label>\n+ <textcolor>FFededed</textcolor>\n+ <focusedcolor>FFededed</focusedcolor>\n+ <selectedcolor>FFededed</selectedcolor>\n+ <shadowcolor>66000000</shadowcolor>\n+ <textoffsetx>20</textoffsetx>\n+ <aligny>center</aligny>\n+ <align>center</align>\n+ <texturefocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturefocus>\n+ <texturenofocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturenofocus>\n+ </control>\n+ </control>\n+ </control>\n+ </controls>\n+</window>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": "resources/skins/default/media/smallbutton.png",
"new_path": "resources/skins/default/media/smallbutton.png",
"diff": "Binary files /dev/null and b/resources/skins/default/media/smallbutton.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -169,15 +169,8 @@ class NetflixService(object):\n\"\"\"\nself._start_servers()\nmonitor = KodiMonitor(self.nx_common, self.nx_common.log)\n- counter = 0\nwhile not monitor.abortRequested():\n- counter += 1 # increment the counter\n- # every 1 seconds\n- if self.nx_common.get_addon().getSetting('showskipcredits') == 'true':\n- monitor.check_skip_intro()\n- if counter % 5 == 0: # every 5 seconds only\n- counter = 0 # reset counter\n- monitor.update_playback_progress()\n+ monitor.on_playback_tick()\ntry:\nif self.library_update_scheduled() and self._is_idle():\nself.update_library()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add skip intro and skip recap feature |
105,989 | 31.07.2018 11:59:16 | -7,200 | 23871be29842f0b45fcb13ceb8542d0ba74194ab | Move library item identification logic into own module | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n-import json\ntry:\nimport cPickle as pickle\n-except:\n+except ImportError:\nimport pickle\n+from json import loads\n+\nimport xbmc\nimport xbmcgui\n-from resources.lib.utils import noop\n+from resources.lib.library_matching import guess_movie, guess_episode\n+from resources.lib.utils import json_rpc, noop\nfrom resources.lib.kodi.skip import Skip\nfrom resources.lib.KodiHelper import TAGGED_WINDOW_ID, \\\n@@ -24,16 +26,6 @@ from resources.lib.KodiHelper import TAGGED_WINDOW_ID, \\\nPROP_TIMELINE_MARKERS\n-def _get_safe_with_fallback(item, fallback, **kwargs):\n- itemkey = kwargs.get('itemkey', 'title')\n- fallbackkey = kwargs.get('fallbackkey', 'title')\n- default = kwargs.get('default', '')\n- try:\n- return item.get(itemkey) or fallback.get(fallbackkey)\n- except AttributeError:\n- return default\n-\n-\ndef _retry(func, max_tries):\nfor _ in range(1, max_tries):\nxbmc.sleep(3000)\n@@ -43,22 +35,9 @@ def _retry(func, max_tries):\nreturn None\n-def _json_rpc(method, params=None):\n- request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n- 'params': params or {}}\n- request = json.dumps(request_data)\n- response = json.loads(unicode(xbmc.executeJSONRPC(request), 'utf-8',\n- errors='ignore'))\n- if 'error' in response:\n- raise IOError('JSONRPC-Error {}: {}'\n- .format(response['error']['code'],\n- response['error']['message']))\n- return response['result']\n-\n-\ndef _get_active_video_player():\nreturn next((player['playerid']\n- for player in _json_rpc('Player.GetActivePlayers')\n+ for player in json_rpc('Player.GetActivePlayers')\nif player['type'] == 'video'),\nNone)\n@@ -68,66 +47,8 @@ def _is_playback_status(status):\nPROP_NETFLIX_PLAY) == status\n-def _first_match_or_none(mediatype, item, candidates, item_fb, match_fn):\n- return next(({'dbtype': mediatype,\n- 'dbid': candidate['{}id'.format(mediatype)],\n- 'playcount': candidate['playcount']}\n- for candidate in candidates\n- if match_fn(item, candidate, item_fb)),\n- None)\n-\n-\n-def _match_movie(item, movie, fallback_data):\n- title = _get_safe_with_fallback(item, fallback_data)\n- movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n- return movie_meta == title or movie['label'] in title\n-\n-\n-def _match_episode_explicitly(item, candidate):\n- try:\n- matches_show = (item.get('tvshowid') == candidate['tvshowid'] or\n- item.get('showtitle') == candidate['showtitle'])\n- matches_season = item.get('season') == candidate['season']\n- matches_episode = item.get('episode') == candidate['episode']\n- return matches_show and matches_season and matches_episode\n- except AttributeError:\n- return False\n-\n-\n-def _match_episode_by_title(title, candidate):\n- episode_meta = 'S%02dE%02d' % (candidate['season'],\n- candidate['episode'])\n- return candidate['showtitle'] in title and episode_meta in title\n-\n-\n-def _match_episode(item, candidate, item_fb):\n- title = _get_safe_with_fallback(item, item_fb, itemkey='label')\n- return (_match_episode_explicitly(item, candidate) or\n- _match_episode_by_title(title, candidate))\n-\n-\n-def _guess_episode(item, item_fb):\n- resp = _json_rpc('VideoLibrary.GetEpisodes',\n- {'properties': ['playcount', 'tvshowid',\n- 'showtitle', 'season',\n- 'episode']})\n- return _first_match_or_none('episode', item, resp.get('episodes', []),\n- item_fb, _match_episode)\n-\n-\n-def _guess_movie(item, item_fb):\n- params = {'properties': ['playcount', 'year', 'title']}\n- try:\n- params['filter'] = {'year': item['year']}\n- except (TypeError, KeyError):\n- pass\n- resp = _json_rpc('VideoLibrary.GetMovies', params)\n- return _first_match_or_none('movie', item, resp.get('movies', []),\n- item_fb, _match_movie)\n-\n-\ndef _seek(player_id, milliseconds):\n- return _json_rpc('Player.Seek', {\n+ return json_rpc('Player.Seek', {\n'playerid': player_id,\n'value': {\n'hours': (milliseconds / (1000 * 60 * 60)) % 24,\n@@ -180,7 +101,7 @@ class KodiMonitor(xbmc.Monitor):\nplayer_id = _get_active_video_player()\ntry:\n- progress = _json_rpc('Player.GetProperties', {\n+ progress = json_rpc('Player.GetProperties', {\n'playerid': player_id,\n'properties': ['percentage', 'time']\n})\n@@ -210,7 +131,7 @@ class KodiMonitor(xbmc.Monitor):\nstarted and playback stopped events.\n\"\"\"\n# pylint: disable=unused-argument, invalid-name\n- data = json.loads(unicode(data, 'utf-8', errors='ignore'))\n+ data = loads(unicode(data, 'utf-8', errors='ignore'))\nif method == 'Player.OnPlay':\nself._on_playback_started(data.get('item', None))\nelif method == 'Player.OnStop':\n@@ -305,7 +226,7 @@ class KodiMonitor(xbmc.Monitor):\n# @log\ndef _get_video_info(self, player_id, fallback_data):\n- info = _json_rpc('Player.GetItem',\n+ info = json_rpc('Player.GetItem',\n{\n'playerid': player_id,\n'properties': ['playcount', 'title', 'year',\n@@ -318,8 +239,8 @@ class KodiMonitor(xbmc.Monitor):\nexcept KeyError:\nself.log('Guessing video info (fallback={})'.format(fallback_data),\nxbmc.LOGWARNING)\n- return (_guess_episode(info, fallback_data) or\n- _guess_movie(info, fallback_data))\n+ return (guess_episode(info, fallback_data) or\n+ guess_movie(info, fallback_data))\n# @log\ndef _update_item_details(self, properties):\n@@ -328,7 +249,7 @@ class KodiMonitor(xbmc.Monitor):\nparams = {'{}id'.format(self.video_info['dbtype']):\nself.video_info['dbid']}\nparams.update(properties)\n- return _json_rpc(method, params)\n+ return json_rpc(method, params)\ndef _grab_timeline_markers(self):\nself.timeline_markers = {'credit_markers': {}}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/library_matching.py",
"diff": "+\"\"\" Utility functions to identify items in the Kodi library\"\"\"\n+from resources.lib.utils import json_rpc\n+\n+\n+def guess_episode(item, item_fb):\n+ \"\"\"\n+ Tries to identify the episode in the Kodi library represented by the item.\n+ \"\"\"\n+ resp = json_rpc('VideoLibrary.GetEpisodes',\n+ {'properties': ['playcount', 'tvshowid',\n+ 'showtitle', 'season',\n+ 'episode']})\n+ return _first_match_or_none('episode', item, resp.get('episodes', []),\n+ item_fb, _match_episode)\n+\n+\n+def guess_movie(item, item_fb):\n+ \"\"\"\n+ Tries to identify the movie in the Kodi library represented by the item.\n+ \"\"\"\n+ params = {'properties': ['playcount', 'year', 'title']}\n+ try:\n+ params['filter'] = {'year': item['year']}\n+ except (TypeError, KeyError):\n+ pass\n+ resp = json_rpc('VideoLibrary.GetMovies', params)\n+ return _first_match_or_none('movie', item, resp.get('movies', []),\n+ item_fb, _match_movie)\n+\n+\n+def _get_safe_with_fallback(item, fallback, **kwargs):\n+ itemkey = kwargs.get('itemkey', 'title')\n+ fallbackkey = kwargs.get('fallbackkey', 'title')\n+ default = kwargs.get('default', '')\n+ try:\n+ return item.get(itemkey) or fallback.get(fallbackkey)\n+ except AttributeError:\n+ return default\n+\n+\n+def _first_match_or_none(mediatype, item, candidates, item_fb, match_fn):\n+ return next(({'dbtype': mediatype,\n+ 'dbid': candidate['{}id'.format(mediatype)],\n+ 'playcount': candidate['playcount']}\n+ for candidate in candidates\n+ if match_fn(item, candidate, item_fb)),\n+ None)\n+\n+\n+def _match_movie(item, movie, fallback_data):\n+ title = _get_safe_with_fallback(item, fallback_data)\n+ movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n+ return movie_meta == title or movie['label'] in title\n+\n+\n+def _match_episode_explicitly(item, candidate):\n+ try:\n+ matches_show = (item.get('tvshowid') == candidate['tvshowid'] or\n+ item.get('showtitle') == candidate['showtitle'])\n+ matches_season = item.get('season') == candidate['season']\n+ matches_episode = item.get('episode') == candidate['episode']\n+ return matches_show and matches_season and matches_episode\n+ except AttributeError:\n+ return False\n+\n+\n+def _match_episode_by_title(title, candidate):\n+ episode_meta = 'S%02dE%02d' % (candidate['season'],\n+ candidate['episode'])\n+ return candidate['showtitle'] in title and episode_meta in title\n+\n+\n+def _match_episode(item, candidate, item_fb):\n+ title = _get_safe_with_fallback(item, item_fb, itemkey='label')\n+ return (_match_episode_explicitly(item, candidate) or\n+ _match_episode_by_title(title, candidate))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "import time\nimport hashlib\nimport platform\n+import json\nfrom functools import wraps\nfrom types import FunctionType\nimport xbmc\n@@ -120,3 +121,25 @@ def get_class_methods(class_item=None):\n\"\"\"\n_type = FunctionType\nreturn [x for x, y in class_item.__dict__.items() if isinstance(y, _type)]\n+\n+\n+def json_rpc(method, params=None):\n+ \"\"\"\n+ Executes a JSON-RPC in Kodi\n+\n+ :param method: The JSON-RPC method to call\n+ :type method: string\n+ :param params: The parameters of the method call (optional)\n+ :type params: dict\n+ :returns: dict -- Method call result\n+ \"\"\"\n+ request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n+ 'params': params or {}}\n+ request = json.dumps(request_data)\n+ response = json.loads(unicode(xbmc.executeJSONRPC(request), 'utf-8',\n+ errors='ignore'))\n+ if 'error' in response:\n+ raise IOError('JSONRPC-Error {}: {}'\n+ .format(response['error']['code'],\n+ response['error']['message']))\n+ return response['result']\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Move library item identification logic into own module |
105,989 | 31.07.2018 13:18:00 | -7,200 | 44d0f26146d76e92b73d6a40eeb484304b1a59fa | De-clutter KodiMonitor, move stuff to utils | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "# Module: KodiMonitor\n# Created on: 08.02.2018\n# License: MIT https://goo.gl/5bMj3H\n-# pylint: disable=line-too-long\n+# pylint: disable=import-error\n\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n@@ -18,28 +18,12 @@ import xbmc\nimport xbmcgui\nfrom resources.lib.library_matching import guess_movie, guess_episode\n-from resources.lib.utils import json_rpc, noop\n+from resources.lib.utils import json_rpc, retry, get_active_video_player, noop\nfrom resources.lib.kodi.skip import Skip\n-from resources.lib.KodiHelper import TAGGED_WINDOW_ID, \\\n- PROP_NETFLIX_PLAY, PROP_PLAYBACK_INIT, PROP_PLAYBACK_TRACKING, \\\n- PROP_TIMELINE_MARKERS\n-\n-\n-def _retry(func, max_tries):\n- for _ in range(1, max_tries):\n- xbmc.sleep(3000)\n- retval = func()\n- if retval is not None:\n- return retval\n- return None\n-\n-\n-def _get_active_video_player():\n- return next((player['playerid']\n- for player in json_rpc('Player.GetActivePlayers')\n- if player['type'] == 'video'),\n- None)\n+from resources.lib.KodiHelper import (\n+ TAGGED_WINDOW_ID, PROP_NETFLIX_PLAY, PROP_PLAYBACK_INIT,\n+ PROP_PLAYBACK_TRACKING, PROP_TIMELINE_MARKERS)\ndef _is_playback_status(status):\n@@ -47,18 +31,6 @@ def _is_playback_status(status):\nPROP_NETFLIX_PLAY) == status\n-def _seek(player_id, milliseconds):\n- return json_rpc('Player.Seek', {\n- 'playerid': player_id,\n- 'value': {\n- 'hours': (milliseconds / (1000 * 60 * 60)) % 24,\n- 'minutes': (milliseconds / (1000 * 60)) % 60,\n- 'seconds': (milliseconds / 1000) % 60,\n- 'milliseconds': (milliseconds) % 1000\n- }\n- })\n-\n-\ndef is_initialized_playback():\n\"\"\"\nIndicates if a playback was initiated by the netflix addon by\n@@ -81,6 +53,9 @@ class KodiMonitor(xbmc.Monitor):\nlibrary.\n\"\"\"\n+ AUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n+ '{:02d}:{:02d},silent)'\n+\ndef __init__(self, nx_common, log_fn=noop):\nsuper(KodiMonitor, self).__init__()\nself.nx_common = nx_common\n@@ -99,7 +74,7 @@ class KodiMonitor(xbmc.Monitor):\nif not is_netflix_playback():\nreturn\n- player_id = _get_active_video_player()\n+ player_id = get_active_video_player()\ntry:\nprogress = json_rpc('Player.GetProperties', {\n'playerid': player_id,\n@@ -139,7 +114,7 @@ class KodiMonitor(xbmc.Monitor):\n# @log\ndef _on_playback_started(self, item):\n- player_id = _retry(_get_active_video_player, 5)\n+ player_id = retry(get_active_video_player, 5)\nif player_id is not None and is_initialized_playback():\nself.video_info = self._get_video_info(player_id, item)\n@@ -219,8 +194,7 @@ class KodiMonitor(xbmc.Monitor):\nself.timeline_markers['credit_markers'][section]['start'])\nseconds = dialog_duration % 60\nminutes = (dialog_duration - seconds) / 60\n- xbmc.executebuiltin(\n- 'AlarmClock(closedialog,Dialog.Close(all,true),{:02d}:{:02d},silent)'\n+ xbmc.executebuiltin(KodiMonitor.AUTOCLOSE_COMMAND\n.format(minutes, seconds))\ndlg.doModal()\n@@ -256,6 +230,7 @@ class KodiMonitor(xbmc.Monitor):\ntry:\ntimeline_markers = pickle.loads(xbmcgui.Window(\nTAGGED_WINDOW_ID).getProperty(PROP_TIMELINE_MARKERS))\n+ # pylint: disable=bare-except\nexcept:\nself.nx_common.log('No timeline markers found')\nreturn\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "@@ -143,3 +143,31 @@ def json_rpc(method, params=None):\n.format(response['error']['code'],\nresponse['error']['message']))\nreturn response['result']\n+\n+\n+def retry(func, max_tries, sleep_time=3000):\n+ \"\"\"\n+ Retry an operation max_tries times and wait sleep_time milliseconds\n+ inbetween. Silently ignores exceptions.\n+ \"\"\"\n+ for _ in range(1, max_tries):\n+ try:\n+ result = func()\n+ if result is not None:\n+ return result\n+ # pylint: disable=bare-except\n+ except:\n+ pass\n+ xbmc.sleep(sleep_time)\n+ return None\n+\n+\n+def get_active_video_player():\n+ \"\"\"\n+ Return the id of the currently active Kodi video player or None\n+ if there's no active player.\n+ \"\"\"\n+ return next((player['playerid']\n+ for player in json_rpc('Player.GetActivePlayers')\n+ if player['type'] == 'video'),\n+ None)\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | De-clutter KodiMonitor, move stuff to utils |
105,989 | 31.07.2018 14:00:55 | -7,200 | ce37225a34bd6e82422339bb155faf198d7ade5d | Decompose skipping logic | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "@@ -55,50 +55,19 @@ class KodiMonitor(xbmc.Monitor):\nAUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n'{:02d}:{:02d},silent)'\n+ SKIPPABLE_SECTIONS = ['recap', 'credit']\ndef __init__(self, nx_common, log_fn=noop):\nsuper(KodiMonitor, self).__init__()\nself.nx_common = nx_common\n+ self.active_player_id = None\nself.video_info = None\nself.progress = 0\nself.elapsed = 0\nself.log = log_fn\nself.timeline_markers = {}\n-\n- # @log\n- def on_playback_tick(self):\n- \"\"\"\n- Updates the internal progress status of a tracked playback\n- and saves bookmarks to Kodi library.\n- \"\"\"\n- if not is_netflix_playback():\n- return\n-\n- player_id = get_active_video_player()\n- try:\n- progress = json_rpc('Player.GetProperties', {\n- 'playerid': player_id,\n- 'properties': ['percentage', 'time']\n- })\n- except IOError:\n- return\n- self.elapsed = (progress['time']['hours'] * 3600 +\n- progress['time']['minutes'] * 60 +\n- progress['time']['seconds'])\n- self.progress = progress['percentage']\n-\n- if self.nx_common.get_addon().getSetting('skip_credits') == 'true':\n- for section in ['recap', 'credit']:\n- section_markers = self.timeline_markers['credit_markers'].get(\n- section)\n- if (section_markers and\n- self.elapsed >= section_markers['start'] and\n- self.elapsed < section_markers['end']):\n- self._skip(section)\n- del self.timeline_markers['credit_markers'][section]\n-\n- if self.video_info:\n- self._update_item_details({'resume': {'position': self.elapsed}})\n+ self.skipping_enabled = (\n+ self.nx_common.get_addon().getSetting('skip_credits') == 'true')\ndef onNotification(self, sender, method, data):\n\"\"\"\n@@ -114,10 +83,10 @@ class KodiMonitor(xbmc.Monitor):\n# @log\ndef _on_playback_started(self, item):\n- player_id = retry(get_active_video_player, 5)\n+ self.active_player_id = retry(get_active_video_player, 5)\n- if player_id is not None and is_initialized_playback():\n- self.video_info = self._get_video_info(player_id, item)\n+ if self.active_player_id is not None and is_initialized_playback():\n+ self.video_info = self._get_video_info(item)\nself.progress = 0\nself.elapsed = 0\nself._grab_timeline_markers()\n@@ -162,16 +131,62 @@ class KodiMonitor(xbmc.Monitor):\nself.elapsed = 0\nself.timeline_markers = {}\n- def _skip(self, section):\n+ def on_playback_tick(self):\n+ \"\"\"\n+ Update the internal progress tracking of a playback and check if\n+ sections need to be skipped\n+ \"\"\"\n+ if is_netflix_playback():\n+ self._update_progress()\n+ self._check_skips()\n+\n+ def _update_progress(self):\n+ try:\n+ player_props = json_rpc('Player.GetProperties', {\n+ 'playerid': self.active_player_id,\n+ 'properties': ['percentage', 'time']\n+ })\n+ except IOError:\n+ return\n+\n+ self.progress = player_props['percentage']\n+ self.elapsed = (player_props['time']['hours'] * 3600 +\n+ player_props['time']['minutes'] * 60 +\n+ player_props['time']['seconds'])\n+\n+ if self.video_info:\n+ self._save_bookmark()\n+\n+ def _check_skips(self):\n+ if self.skipping_enabled:\n+ for section in KodiMonitor.SKIPPABLE_SECTIONS:\n+ self._check_skip(section)\n+\n+ def _check_skip(self, section):\n+ section_markers = self.timeline_markers['credit_markers'].get(\n+ section)\n+ if (section_markers is not None and\n+ self.elapsed >= section_markers['start'] and\n+ self.elapsed < section_markers['end']):\n+ self._skip_section(section)\n+ del self.timeline_markers['credit_markers'][section]\n+\n+ def _skip_section(self, section):\naddon = self.nx_common.get_addon()\n- label_code = 30076 if section == 'credit' else 30077\n- label = addon.getLocalizedString(label_code)\n+ label = addon.getLocalizedString(\n+ 30076 if section == 'credit' else 30077)\nif addon.getSetting('auto_skip_credits') == 'true':\n+ pause_on_skip = addon.getSetting('skip_enabled_no_pause') == 'true'\n+ self._auto_skip(section, label, pause_on_skip)\n+ else:\n+ self._ask_to_skip(section, label)\n+\n+ def _auto_skip(self, section, label, pause_on_skip):\nplayer = xbmc.Player()\ndlg = xbmcgui.Dialog()\ndlg.notification('Netflix', '{}...'.format(label),\nxbmcgui.NOTIFICATION_INFO, 5000)\n- if addon.getSetting('skip_enabled_no_pause') == 'true':\n+ if not pause_on_skip:\nplayer.seekTime(\nself.timeline_markers['credit_markers'][section]['end'])\nelse:\n@@ -181,7 +196,8 @@ class KodiMonitor(xbmc.Monitor):\nself.timeline_markers['credit_markers'][section]['end'])\nxbmc.sleep(1) # give kodi the chance to execute\nplayer.pause() # unpause playback at seek position\n- else:\n+\n+ def _ask_to_skip(self, section, label):\ndlg = Skip(\"plugin-video-netflix-Skip.xml\",\nself.nx_common.get_addon().getAddonInfo('path'),\n\"default\", \"1080i\", section=section,\n@@ -199,10 +215,10 @@ class KodiMonitor(xbmc.Monitor):\ndlg.doModal()\n# @log\n- def _get_video_info(self, player_id, fallback_data):\n+ def _get_video_info(self, fallback_data):\ninfo = json_rpc('Player.GetItem',\n{\n- 'playerid': player_id,\n+ 'playerid': self.active_player_id,\n'properties': ['playcount', 'title', 'year',\n'tvshowid', 'showtitle',\n'season', 'episode']\n@@ -216,13 +232,15 @@ class KodiMonitor(xbmc.Monitor):\nreturn (guess_episode(info, fallback_data) or\nguess_movie(info, fallback_data))\n- # @log\n- def _update_item_details(self, properties):\n+ def _save_bookmark(self):\nmethod = ('VideoLibrary.Set{}Details'\n.format(self.video_info['dbtype'].capitalize()))\n- params = {'{}id'.format(self.video_info['dbtype']):\n- self.video_info['dbid']}\n- params.update(properties)\n+ params = {\n+ '{}id'.format(self.video_info['dbtype']): self.video_info['dbid'],\n+ 'resume': {\n+ 'position': self.elapsed\n+ }\n+ }\nreturn json_rpc(method, params)\ndef _grab_timeline_markers(self):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Decompose skipping logic |
105,989 | 31.07.2018 18:27:33 | -7,200 | 9569c4506c2c4c7df1b3a093288d62942c2c24d1 | Move skipping logic into own class, simplify marker extraction | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n-try:\n- import cPickle as pickle\n-except ImportError:\n- import pickle\n-\nfrom json import loads\nimport xbmc\nimport xbmcgui\n+from resources.lib.utils import json_rpc, retry, get_active_video_player\nfrom resources.lib.library_matching import guess_movie, guess_episode\n-from resources.lib.utils import json_rpc, retry, get_active_video_player, noop\n-from resources.lib.kodi.skip import Skip\n-\n+from resources.lib.section_skipping import (\n+ SectionSkipper, OFFSET_WATCHED_TO_END)\nfrom resources.lib.KodiHelper import (\nTAGGED_WINDOW_ID, PROP_NETFLIX_PLAY, PROP_PLAYBACK_INIT,\nPROP_PLAYBACK_TRACKING, PROP_TIMELINE_MARKERS)\n@@ -53,21 +48,15 @@ class KodiMonitor(xbmc.Monitor):\nlibrary.\n\"\"\"\n- AUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n- '{:02d}:{:02d},silent)'\n- SKIPPABLE_SECTIONS = ['recap', 'credit']\n-\n- def __init__(self, nx_common, log_fn=noop):\n+ def __init__(self, nx_common):\nsuper(KodiMonitor, self).__init__()\nself.nx_common = nx_common\n+ self.log = nx_common.log\n+ self.section_skipper = SectionSkipper(nx_common)\nself.active_player_id = None\nself.video_info = None\nself.progress = 0\nself.elapsed = 0\n- self.log = log_fn\n- self.timeline_markers = {}\n- self.skipping_enabled = (\n- self.nx_common.get_addon().getSetting('skip_credits') == 'true')\ndef onNotification(self, sender, method, data):\n\"\"\"\n@@ -86,10 +75,10 @@ class KodiMonitor(xbmc.Monitor):\nself.active_player_id = retry(get_active_video_player, 5)\nif self.active_player_id is not None and is_initialized_playback():\n+ self.section_skipper.on_playback_started()\nself.video_info = self._get_video_info(item)\nself.progress = 0\nself.elapsed = 0\n- self._grab_timeline_markers()\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\nPROP_NETFLIX_PLAY,\nPROP_PLAYBACK_TRACKING)\n@@ -108,10 +97,10 @@ class KodiMonitor(xbmc.Monitor):\n# @log\ndef _on_playback_stopped(self):\nif is_netflix_playback() and self.video_info:\n- if (('watched_to_end_offset' in self.timeline_markers and\n+ if ((OFFSET_WATCHED_TO_END in self.timeline_markers and\n(self.elapsed >=\n- self.timeline_markers['watched_to_end_offset'])) or\n- ('watched_to_end_offset' not in self.timeline_markers and\n+ self.timeline_markers[OFFSET_WATCHED_TO_END])) or\n+ (OFFSET_WATCHED_TO_END not in self.timeline_markers and\nself.progress >= 90)):\nnew_playcount = self.video_info.get('playcount', 0) + 1\nself._update_item_details({'playcount': new_playcount,\n@@ -127,9 +116,6 @@ class KodiMonitor(xbmc.Monitor):\nxbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\nPROP_TIMELINE_MARKERS, '')\nself.video_info = None\n- self.progress = 0\n- self.elapsed = 0\n- self.timeline_markers = {}\ndef on_playback_tick(self):\n\"\"\"\n@@ -138,7 +124,7 @@ class KodiMonitor(xbmc.Monitor):\n\"\"\"\nif is_netflix_playback():\nself._update_progress()\n- self._check_skips()\n+ self.section_skipper.on_tick(self.elapsed)\ndef _update_progress(self):\ntry:\n@@ -157,63 +143,6 @@ class KodiMonitor(xbmc.Monitor):\nif self.video_info:\nself._save_bookmark()\n- def _check_skips(self):\n- if self.skipping_enabled:\n- for section in KodiMonitor.SKIPPABLE_SECTIONS:\n- self._check_skip(section)\n-\n- def _check_skip(self, section):\n- section_markers = self.timeline_markers['credit_markers'].get(\n- section)\n- if (section_markers is not None and\n- self.elapsed >= section_markers['start'] and\n- self.elapsed < section_markers['end']):\n- self._skip_section(section)\n- del self.timeline_markers['credit_markers'][section]\n-\n- def _skip_section(self, section):\n- addon = self.nx_common.get_addon()\n- label = addon.getLocalizedString(\n- 30076 if section == 'credit' else 30077)\n- if addon.getSetting('auto_skip_credits') == 'true':\n- pause_on_skip = addon.getSetting('skip_enabled_no_pause') == 'true'\n- self._auto_skip(section, label, pause_on_skip)\n- else:\n- self._ask_to_skip(section, label)\n-\n- def _auto_skip(self, section, label, pause_on_skip):\n- player = xbmc.Player()\n- dlg = xbmcgui.Dialog()\n- dlg.notification('Netflix', '{}...'.format(label),\n- xbmcgui.NOTIFICATION_INFO, 5000)\n- if not pause_on_skip:\n- player.seekTime(\n- self.timeline_markers['credit_markers'][section]['end'])\n- else:\n- player.pause()\n- xbmc.sleep(1) # give kodi the chance to execute\n- player.seekTime(\n- self.timeline_markers['credit_markers'][section]['end'])\n- xbmc.sleep(1) # give kodi the chance to execute\n- player.pause() # unpause playback at seek position\n-\n- def _ask_to_skip(self, section, label):\n- dlg = Skip(\"plugin-video-netflix-Skip.xml\",\n- self.nx_common.get_addon().getAddonInfo('path'),\n- \"default\", \"1080i\", section=section,\n- skip_to=self.timeline_markers['credit_markers']\n- [section]['end'],\n- label=label)\n- # close skip intro dialog after time\n- dialog_duration = (\n- self.timeline_markers['credit_markers'][section]['end'] -\n- self.timeline_markers['credit_markers'][section]['start'])\n- seconds = dialog_duration % 60\n- minutes = (dialog_duration - seconds) / 60\n- xbmc.executebuiltin(KodiMonitor.AUTOCLOSE_COMMAND\n- .format(minutes, seconds))\n- dlg.doModal()\n-\n# @log\ndef _get_video_info(self, fallback_data):\ninfo = json_rpc('Player.GetItem',\n@@ -242,35 +171,3 @@ class KodiMonitor(xbmc.Monitor):\n}\n}\nreturn json_rpc(method, params)\n-\n- def _grab_timeline_markers(self):\n- self.timeline_markers = {'credit_markers': {}}\n- try:\n- timeline_markers = pickle.loads(xbmcgui.Window(\n- TAGGED_WINDOW_ID).getProperty(PROP_TIMELINE_MARKERS))\n- # pylint: disable=bare-except\n- except:\n- self.nx_common.log('No timeline markers found')\n- return\n-\n- if timeline_markers['end_credits_offset'] is not None:\n- self.timeline_markers['end_credits_offset'] = (\n- timeline_markers['end_credits_offset'])\n-\n- if timeline_markers['watched_to_end_offset'] is not None:\n- self.timeline_markers['watched_to_end_offset'] = (\n- timeline_markers['watched_to_end_offset'])\n-\n- if timeline_markers['credit_markers']['credit']['start'] is not None:\n- self.timeline_markers['credit_markers']['credit'] = {\n- 'start': int(timeline_markers['credit_markers']['credit']['start']/ 1000),\n- 'end': int(timeline_markers['credit_markers']['credit']['end'] / 1000)\n- }\n-\n- if timeline_markers['credit_markers']['recap']['start'] is not None:\n- self.timeline_markers['credit_markers']['recap'] = {\n- 'start': int(timeline_markers['credit_markers']['recap']['start'] / 1000),\n- 'end': int(timeline_markers['credit_markers']['recap']['end'] / 1000)\n- }\n-\n- self.nx_common.log('Found timeline markers: {}'.format(self.timeline_markers))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -23,9 +23,11 @@ from collections import OrderedDict\nimport xbmc\nimport resources.lib.NetflixSession as Netflix\n-from resources.lib.utils import log\n+from resources.lib.utils import log, find_episode\nfrom resources.lib.KodiHelper import KodiHelper\nfrom resources.lib.Library import Library\n+from resources.lib.section_skipping import (\n+ SKIPPABLE_SECTIONS, OFFSET_CREDITS, OFFSET_WATCHED_TO_END)\nclass Navigation(object):\n@@ -246,25 +248,6 @@ class Navigation(object):\nxbmc.executebuiltin('Container.Refresh')\nreturn True\n- def _get_credit_markers_for_episode(self, metadata, episode_id):\n- if not (metadata and\n- 'video' in metadata and\n- metadata['video'].get('type') == 'show'):\n- return {}\n-\n- for season in metadata['video']['seasons']:\n- for episode in season['episodes']:\n- self.nx_common.log('Looking at S{}E{}: episode[id]={} <=> {}'.format(season['seq'], episode['seq'], episode['id'], episode_id))\n- if str(episode['id']) == episode_id:\n- return {\n- 'end_credits_offset': episode.get('creditsOffset'),\n- 'watched_to_end_offset': episode.get('watchedToEndOffset'),\n- 'credit_markers': episode.get('creditMarkers')\n- }\n-\n- self.nx_common.log('Could not find metadata for episode')\n- return {}\n-\n@log\ndef play_video(self, video_id, start_offset, infoLabels):\n\"\"\"Starts video playback\n@@ -287,19 +270,49 @@ class Navigation(object):\nexcept:\ninfoLabels = {}\n- metadata = self._check_response(self.call_netflix_service({\n- 'method': 'fetch_metadata',\n- 'video_id': video_id\n- }))\n-\n- timeline_markers = self._get_credit_markers_for_episode(metadata, video_id)\n-\n- play = self.kodi_helper.play_item(\n+ return self.kodi_helper.play_item(\nvideo_id=video_id,\nstart_offset=start_offset,\ninfoLabels=infoLabels,\n- timeline_markers=timeline_markers)\n- return play\n+ timeline_markers=self._get_timeline_markers(video_id))\n+\n+ @log\n+ def _get_timeline_markers(self, video_id):\n+ try:\n+ metadata = self._get_single_metadata(video_id)\n+ except KeyError:\n+ return {}\n+\n+ markers = {\n+ marker: metadata[marker]\n+ for marker in [OFFSET_CREDITS, OFFSET_WATCHED_TO_END]\n+ if metadata[marker] is not None\n+ }\n+\n+ markers['creditMarkers'] = {\n+ section: {\n+ 'start': metadata['creditMarkers'][section]['start'] / 1000,\n+ 'end': metadata['creditMarkers'][section]['end'] / 1000\n+ }\n+ for section in SKIPPABLE_SECTIONS\n+ if None not in metadata['creditMarkers'][section].values()\n+ }\n+\n+ return markers\n+\n+ @log\n+ def _get_single_metadata(self, video_id):\n+ metadata = (\n+ self._check_response(\n+ self.call_netflix_service({\n+ 'method': 'fetch_metadata',\n+ 'video_id': video_id\n+ })\n+ ) or {}\n+ )['video']\n+ return (find_episode(video_id, metadata['seasons'])\n+ if metadata['type'] == 'show'\n+ else metadata)\n@log\ndef show_search_results(self, term):\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/section_skipping.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Module: section_skipping\n+# Created on: 31.07.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"Skipping of video sections (recap, intro)\"\"\"\n+try:\n+ import cPickle as pickle\n+except ImportError:\n+ import pickle\n+\n+import xbmc\n+import xbmcgui\n+\n+from resources.lib.KodiHelper import TAGGED_WINDOW_ID, PROP_TIMELINE_MARKERS\n+from resources.lib.kodi.skip import Skip\n+\n+\n+AUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n+ '{:02d}:{:02d},silent)'\n+SKIPPABLE_SECTIONS = ['recap', 'credit']\n+OFFSET_CREDITS = 'creditsOffset'\n+OFFSET_WATCHED_TO_END = 'watchedToEndOffset'\n+\n+\n+class SectionSkipper(object):\n+ \"\"\"\n+ Encapsulates skipping logic. on_tick() method must periodically\n+ be called to execute actions.\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ self.addon = nx_common.get_addon()\n+ self.log = nx_common.log\n+ self.enabled = False\n+ self.auto_skip = False\n+ self.pause_on_skip = False\n+ self._markers = {}\n+\n+ def on_playback_started(self):\n+ \"\"\"\n+ Initialize settings and timeline markers for a new playback\n+ \"\"\"\n+ self._load_settings()\n+ self._load_markers()\n+\n+ def _load_settings(self):\n+ self.enabled = self.addon.getSetting('skip_credits') == 'true'\n+ self.auto_skip = self.addon.getSetting('auto_skip_credits') == 'true'\n+ self.pause_on_skip = self.addon.getSetting('pause_on_skip') == 'true'\n+\n+ def _load_markers(self):\n+ try:\n+ self._markers = pickle.loads(xbmcgui.Window(\n+ TAGGED_WINDOW_ID).getProperty(PROP_TIMELINE_MARKERS))\n+ # pylint: disable=bare-except\n+ except:\n+ self.log('No timeline markers found')\n+ self._markers = {'creditMarkers': {}}\n+\n+ self.log('Found timeline markers: {}'.format(self._markers))\n+\n+ def on_tick(self, elapsed):\n+ \"\"\"\n+ Check if playback has reached a skippable section and skip if this is\n+ the case\n+ \"\"\"\n+ if self.enabled:\n+ for section in SKIPPABLE_SECTIONS:\n+ self._check_section(elapsed, section)\n+\n+ def _check_section(self, elapsed, section):\n+ section_markers = self._markers['creditMarkers'].get(section)\n+ if (section_markers is not None and\n+ elapsed >= section_markers['start'] and\n+ elapsed < section_markers['end']):\n+ self._skip_section(section)\n+ del self._markers['creditMarkers'][section]\n+\n+ def _skip_section(self, section):\n+ label = self.addon.getLocalizedString(\n+ 30076 if section == 'credit' else 30077)\n+ if self.auto_skip:\n+ self._auto_skip(section, label)\n+ else:\n+ self._ask_to_skip(section, label)\n+\n+ def _auto_skip(self, section, label):\n+ player = xbmc.Player()\n+ xbmcgui.Dialog().notification(\n+ 'Netflix', '{}...'.format(label), xbmcgui.NOTIFICATION_INFO, 5000)\n+ if self.pause_on_skip:\n+ player.pause()\n+ xbmc.sleep(1000) # give kodi the chance to execute\n+ player.seekTime(self._markers['creditMarkers'][section]['end'])\n+ xbmc.sleep(1000) # give kodi the chance to execute\n+ player.pause() # unpause playback at seek position\n+ else:\n+ player.seekTime(self._markers['creditMarkers'][section]['end'])\n+\n+ def _ask_to_skip(self, section, label):\n+ dlg = Skip(\"plugin-video-netflix-Skip.xml\",\n+ self.addon.getAddonInfo('path'),\n+ \"default\", \"1080i\",\n+ section=section,\n+ skip_to=self._markers['creditMarkers'][section]['end'],\n+ label=label)\n+ # close skip intro dialog after time\n+ dialog_duration = (self._markers['creditMarkers'][section]['end'] -\n+ self._markers['creditMarkers'][section]['start'])\n+ seconds = dialog_duration % 60\n+ minutes = (dialog_duration - seconds) / 60\n+ xbmc.executebuiltin(AUTOCLOSE_COMMAND.format(minutes, seconds))\n+ dlg.doModal()\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "@@ -171,3 +171,15 @@ def get_active_video_player():\nfor player in json_rpc('Player.GetActivePlayers')\nif player['type'] == 'video'),\nNone)\n+\n+def find_episode(episode_id, seasons):\n+ \"\"\"\n+ Return metadata for a specific episode from within a nested\n+ metadata dict.\n+ Returns an empty dict if the episode could not be found.\n+ \"\"\"\n+ for season in seasons:\n+ for episode in season['episodes']:\n+ if str(episode['id']) == episode_id:\n+ return episode\n+ return {}\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<category label=\"30078\">\n<setting id=\"skip_credits\" type=\"bool\" label=\"30075\" default=\"true\"/>\n<setting id=\"auto_skip_credits\" type=\"bool\" label=\"30079\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n- <setting id=\"skip_enabled_no_pause\" type=\"bool\" label=\"30080\" default=\"true\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n+ <setting id=\"pause_on_skip\" type=\"bool\" label=\"30080\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n</category>\n<category label=\"30023\">\n<setting id=\"enable_dolby_sound\" type=\"bool\" label=\"30033\" default=\"true\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "\"\"\"Kodi plugin for Netflix (https://netflix.com)\"\"\"\n+# pylint: disable=import-error\nimport threading\nimport socket\n@@ -168,15 +169,19 @@ class NetflixService(object):\nMain loop. Runs until xbmc.Monitor requests abort\n\"\"\"\nself._start_servers()\n- monitor = KodiMonitor(self.nx_common, self.nx_common.log)\n+ monitor = KodiMonitor(self.nx_common)\n+ player = xbmc.Player()\nwhile not monitor.abortRequested():\n+ if player.isPlayingVideo():\nmonitor.on_playback_tick()\n+\ntry:\nif self.library_update_scheduled() and self._is_idle():\nself.update_library()\nexcept RuntimeError as exc:\nself.nx_common.log(\n'RuntimeError: {}'.format(exc), xbmc.LOGERROR)\n+\nif monitor.waitForAbort(1):\nbreak\nself._shutdown()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Move skipping logic into own class, simplify marker extraction |
105,989 | 31.07.2018 22:04:20 | -7,200 | 1bc93af669b610d05e2bb852cc12f147ea5c9def | Massive declutter, use addonsignals | [
{
"change_type": "MODIFY",
"old_path": "addon.xml",
"new_path": "addon.xml",
"diff": "<import addon=\"script.module.requests\" version=\"2.12.4\"/>\n<import addon=\"script.module.pycryptodome\" version=\"3.4.3\"/>\n<import addon=\"script.module.inputstreamhelper\" version=\"0.3.3\"/>\n+ <import addon=\"script.module.addon.signals\" version=\"0.0.3\"/>\n</requires>\n<extension point=\"xbmc.python.pluginsource\" library=\"addon.py\">\n<provides>video</provides>\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -10,11 +10,13 @@ import hashlib\nfrom os import remove\nfrom uuid import uuid4\nfrom urllib import urlencode\n+import AddonSignals\nimport xbmc\nimport xbmcgui\nimport xbmcplugin\nimport inputstreamhelper\nfrom resources.lib.kodi.Dialogs import Dialogs\n+from resources.lib.NetflixCommon import Signals\nfrom utils import get_user_agent\nfrom UniversalAnalytics import Tracker\ntry:\n@@ -41,11 +43,6 @@ CONTENT_SHOW = 'tvshows'\nCONTENT_SEASON = 'seasons'\nCONTENT_EPISODE = 'episodes'\n-TAGGED_WINDOW_ID = 10000\n-PROP_NETFLIX_PLAY = 'netflix_playback'\n-PROP_PLAYBACK_INIT = 'initialized'\n-PROP_PLAYBACK_TRACKING = 'tracking'\n-PROP_TIMELINE_MARKERS = 'netflix_timeline_markers'\ndef _update_if_present(source_dict, source_att, target_dict, target_att):\nif source_dict.get(source_att):\n@@ -944,6 +941,8 @@ class KodiHelper(object):\nplay_item.setArt(art)\nplay_item.setInfo('video', infoLabels)\n+ signal_data = {'timeline_markers': timeline_markers}\n+\n# check for content in kodi db\nif str(infoLabels) != 'None':\nif infoLabels['mediatype'] == 'episode':\n@@ -952,7 +951,7 @@ class KodiHelper(object):\nshowid=id,\nshowseason=infoLabels['season'],\nshowepisode=infoLabels['episode'])\n- if infoLabels['mediatype'] != 'episode':\n+ else:\nid = self.movietitle_to_id(title=infoLabels['title'])\ndetails = self.get_movie_content_by_id(movieid=id)\n@@ -963,26 +962,18 @@ class KodiHelper(object):\n'StartOffset', str(resume_point))\nplay_item.setInfo('video', details[0])\nplay_item.setArt(details[1])\n+ signal_data.update({\n+ 'dbid': details[0]['dbid'],\n+ 'dbtype': details[0]['mediatype'],\n+ 'playcount': details[0]['playcount']})\n+\n+ AddonSignals.sendSignal(Signals.PLAYBACK_INITIATED, signal_data)\n- resolved = xbmcplugin.setResolvedUrl(\n+ return xbmcplugin.setResolvedUrl(\nhandle=self.plugin_handle,\nsucceeded=True,\nlistitem=play_item)\n- # set window property to store intro markers\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_TIMELINE_MARKERS,\n- pickle.dumps(timeline_markers)\n- )\n-\n- # set window property to enable recognition of playbacks\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_NETFLIX_PLAY,\n- PROP_PLAYBACK_INIT\n- )\n-\n- return resolved\n-\ndef _generate_art_info(self, entry):\n\"\"\"Adds the art info from an entry to a Kodi list item\n@@ -1304,7 +1295,7 @@ class KodiHelper(object):\nshowseason = int(showseason)\nshowepisode = int(showepisode)\nprops = [\"title\", \"showtitle\", \"season\", \"episode\", \"plot\", \"fanart\",\n- \"art\", \"resume\"]\n+ \"art\", \"resume\", \"playcount\"]\nquery = {\n\"jsonrpc\": \"2.0\",\n\"method\": \"VideoLibrary.GetEpisodes\",\n@@ -1331,7 +1322,8 @@ class KodiHelper(object):\n'title': episode['title']}\nif episode['resume']['position'] > 0:\ninfos['resume'] = episode['resume']['position']\n- infos.update({'plot': episode['plot'],\n+ infos.update({'playcount': episode.get('playcount', 0),\n+ 'plot': episode['plot'],\n'genre': showid[1]}\nif episode.get('plot') else {})\nart = {}\n@@ -1368,7 +1360,8 @@ class KodiHelper(object):\n\"fanart\",\n\"thumbnail\",\n\"art\",\n- \"resume\"]\n+ \"resume\",\n+ \"playcount\"]\n},\n\"id\": \"libMovies\"\n}\n@@ -1380,7 +1373,8 @@ class KodiHelper(object):\nif result is not None and 'moviedetails' in result:\nresult = result.get('moviedetails', {})\ninfos = {'mediatype': 'movie', 'dbid': movieid,\n- 'title': result['title']}\n+ 'title': result['title'],\n+ 'playcount': episode.get('playcount', 0)}\nif 'resume' in result:\ninfos.update('resume', result['resume'])\nif 'genre' in result and len(result['genre']) > 0:\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": "resources/lib/KodiMonitor.py",
"diff": "\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n-from json import loads\n+import AddonSignals\n+from xbmc import Monitor, LOGERROR\n-import xbmc\n-import xbmcgui\n-\n-from resources.lib.utils import json_rpc, retry, get_active_video_player\n-from resources.lib.library_matching import guess_movie, guess_episode\n+from resources.lib.NetflixCommon import Signals\nfrom resources.lib.section_skipping import (\nSectionSkipper, OFFSET_WATCHED_TO_END)\n-from resources.lib.KodiHelper import (\n- TAGGED_WINDOW_ID, PROP_NETFLIX_PLAY, PROP_PLAYBACK_INIT,\n- PROP_PLAYBACK_TRACKING, PROP_TIMELINE_MARKERS)\n-\n-\n-def _is_playback_status(status):\n- return xbmcgui.Window(TAGGED_WINDOW_ID).getProperty(\n- PROP_NETFLIX_PLAY) == status\n-\n-\n-def is_initialized_playback():\n- \"\"\"\n- Indicates if a playback was initiated by the netflix addon by\n- checking the appropriate window property set by KodiHelper.\n- \"\"\"\n- return _is_playback_status(PROP_PLAYBACK_INIT)\n-\n-\n-def is_netflix_playback():\n- \"\"\"\n- Indicates if an ongoing playback is from netflix addon\n- \"\"\"\n- return _is_playback_status(PROP_PLAYBACK_TRACKING)\n+from resources.lib.utils import (\n+ json_rpc, get_active_video_player, update_library_item_details)\n-class KodiMonitor(xbmc.Monitor):\n+class KodiMonitor(Monitor):\n\"\"\"\nTracks status and progress of video playbacks initiated by the addon and\nsaves bookmarks and watched state for the associated items into the Kodi\nlibrary.\n\"\"\"\n-\ndef __init__(self, nx_common):\nsuper(KodiMonitor, self).__init__()\n- self.nx_common = nx_common\nself.log = nx_common.log\nself.section_skipper = SectionSkipper(nx_common)\n+ self.tracking = False\n+ self.dbinfo = None\n+ self.progress = 0\n+ self.elapsed = 0\nself.active_player_id = None\n- self.video_info = None\n+\n+ AddonSignals.registerSlot(\n+ nx_common.addon.getAddonInfo('id'), Signals.PLAYBACK_INITIATED,\n+ self.setup_playback_tracking)\n+\n+ def setup_playback_tracking(self, data):\n+ \"\"\"\n+ Callback for addon signal when this addon initiates a playback\n+ \"\"\"\n+ self.tracking = True\n+ self.dbinfo = data.get('dbinfo')\nself.progress = 0\nself.elapsed = 0\n+ self.section_skipper.initialize(data.get('timeline_markers'))\ndef onNotification(self, sender, method, data):\n+ # pylint: disable=unused-argument, invalid-name\n\"\"\"\nCallback for Kodi notifications that handles and dispatches playback\nstarted and playback stopped events.\n\"\"\"\n- # pylint: disable=unused-argument, invalid-name\n- data = loads(unicode(data, 'utf-8', errors='ignore'))\n- if method == 'Player.OnPlay':\n- self._on_playback_started(data.get('item', None))\n+ if self.tracking:\n+ if method == 'Player.OnAVStart':\n+ self._on_playback_started()\nelif method == 'Player.OnStop':\nself._on_playback_stopped()\n- # @log\n- def _on_playback_started(self, item):\n- self.active_player_id = retry(get_active_video_player, 5)\n-\n- if self.active_player_id is not None and is_initialized_playback():\n- self.section_skipper.on_playback_started()\n- self.video_info = self._get_video_info(item)\n- self.progress = 0\n- self.elapsed = 0\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_NETFLIX_PLAY,\n- PROP_PLAYBACK_TRACKING)\n- self.log('Tracking playback of {}'.format(self.video_info))\n- else:\n- # Clean up remnants from improperly stopped previous playbacks.\n- # Clearing the window property does not work as expected, thus\n- # we overwrite it with an arbitrary value\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_NETFLIX_PLAY, 'notnetflix')\n- self.log('Not tracking playback: {}'\n- .format('Playback not initiated by netflix plugin'\n- if is_initialized_playback() else\n- 'Unable to obtain active video player'))\n-\n- # @log\n- def _on_playback_stopped(self):\n- if is_netflix_playback() and self.video_info:\n- if ((OFFSET_WATCHED_TO_END in self.timeline_markers and\n- (self.elapsed >=\n- self.timeline_markers[OFFSET_WATCHED_TO_END])) or\n- (OFFSET_WATCHED_TO_END not in self.timeline_markers and\n- self.progress >= 90)):\n- new_playcount = self.video_info.get('playcount', 0) + 1\n- self._update_item_details({'playcount': new_playcount,\n- 'resume': {'position': 0}})\n- action = 'marking {} as watched.'.format(self.video_info)\n- else:\n- action = ('not marking {} as watched, progress too little'\n- .format(self.video_info))\n- self.log('Tracked playback stopped: {}'.format(action))\n-\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_NETFLIX_PLAY, 'stopped')\n- xbmcgui.Window(TAGGED_WINDOW_ID).setProperty(\n- PROP_TIMELINE_MARKERS, '')\n- self.video_info = None\n-\ndef on_playback_tick(self):\n\"\"\"\nUpdate the internal progress tracking of a playback and check if\nsections need to be skipped\n\"\"\"\n- if is_netflix_playback():\n+ if self.tracking:\nself._update_progress()\nself.section_skipper.on_tick(self.elapsed)\n@@ -140,34 +82,41 @@ class KodiMonitor(xbmc.Monitor):\nplayer_props['time']['minutes'] * 60 +\nplayer_props['time']['seconds'])\n- if self.video_info:\n+ if self.dbinfo:\nself._save_bookmark()\n- # @log\n- def _get_video_info(self, fallback_data):\n- info = json_rpc('Player.GetItem',\n- {\n- 'playerid': self.active_player_id,\n- 'properties': ['playcount', 'title', 'year',\n- 'tvshowid', 'showtitle',\n- 'season', 'episode']\n- }).get('item', {})\n- try:\n- return {'dbtype': info['type'], 'dbid': info['id'],\n- 'playcount': info.get('playcount', 0)}\n- except KeyError:\n- self.log('Guessing video info (fallback={})'.format(fallback_data),\n- xbmc.LOGWARNING)\n- return (guess_episode(info, fallback_data) or\n- guess_movie(info, fallback_data))\n-\ndef _save_bookmark(self):\n- method = ('VideoLibrary.Set{}Details'\n- .format(self.video_info['dbtype'].capitalize()))\n- params = {\n- '{}id'.format(self.video_info['dbtype']): self.video_info['dbid'],\n- 'resume': {\n- 'position': self.elapsed\n- }\n- }\n- return json_rpc(method, params)\n+ update_library_item_details(\n+ self.dbinfo['dbtype'], self.dbinfo['dbid'],\n+ {'resume': {'position': self.elapsed}})\n+\n+ def _on_playback_started(self):\n+ self.active_player_id = get_active_video_player()\n+\n+ if self.active_player_id is None:\n+ self.log('Cannot obtain active player, not tracking playback',\n+ level=LOGERROR)\n+ self._on_playback_stopped()\n+\n+ def _on_playback_stopped(self):\n+ if self.tracking and self.dbinfo and self._watched_to_end():\n+ self._mark_as_watched()\n+\n+ self.tracking = False\n+ self.dbinfo = None\n+ self.progress = 0\n+ self.elapsed = 0\n+ self.active_player_id = None\n+\n+ def _watched_to_end(self):\n+ return (\n+ (OFFSET_WATCHED_TO_END in self.timeline_markers and\n+ self.elapsed >= self.timeline_markers[OFFSET_WATCHED_TO_END]) or\n+ (OFFSET_WATCHED_TO_END not in self.timeline_markers and\n+ self.progress >= 90))\n+\n+ def _mark_as_watched(self):\n+ update_library_item_details(\n+ self.dbinfo['dbtype'], self.dbinfo['dbid'],\n+ {'playcount': self.dbinfo.get('playcount', 0) + 1,\n+ 'resume': {'position': 0}})\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -289,14 +289,14 @@ class Navigation(object):\nif metadata[marker] is not None\n}\n- markers['creditMarkers'] = {\n+ markers.update({\nsection: {\n- 'start': metadata['creditMarkers'][section]['start'] / 1000,\n- 'end': metadata['creditMarkers'][section]['end'] / 1000\n+ 'start': int(metadata['creditMarkers'][section]['start'] / 1000),\n+ 'end': int(metadata['creditMarkers'][section]['end'] / 1000)\n}\n- for section in SKIPPABLE_SECTIONS\n+ for section in SKIPPABLE_SECTIONS.keys()\nif None not in metadata['creditMarkers'][section].values()\n- }\n+ })\nreturn markers\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCommon.py",
"new_path": "resources/lib/NetflixCommon.py",
"diff": "@@ -3,6 +3,11 @@ from xbmcaddon import Addon\nimport xbmcvfs\nimport json\n+\n+class Signals(object):\n+ PLAYBACK_INITIATED = 'playback_initiated'\n+\n+\nclass NetflixCommon(object):\n\"\"\"\nStuff shared between / used from service and addon\"\"\"\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/skip.py",
"new_path": "resources/lib/kodi/skip.py",
"diff": "-# pylint: disable=invalid-name,missing-docstring,attribute-defined-outside-init\n+# pylint: disable=invalid-name,missing-docstring,attribute-defined-outside-init,import-error\nfrom platform import machine\nimport xbmc\n@@ -15,7 +15,6 @@ class Skip(xbmcgui.WindowXMLDialog):\n\"\"\"\ndef __init__(self, *args, **kwargs):\nself.skip_to = kwargs['skip_to']\n- self.section = kwargs['section']\nself.label = kwargs['label']\nif OS_MACHINE[0:5] == 'armv7':\nxbmcgui.WindowXMLDialog.__init__(self)\n"
},
{
"change_type": "DELETE",
"old_path": "resources/lib/library_matching.py",
"new_path": null,
"diff": "-\"\"\" Utility functions to identify items in the Kodi library\"\"\"\n-from resources.lib.utils import json_rpc\n-\n-\n-def guess_episode(item, item_fb):\n- \"\"\"\n- Tries to identify the episode in the Kodi library represented by the item.\n- \"\"\"\n- resp = json_rpc('VideoLibrary.GetEpisodes',\n- {'properties': ['playcount', 'tvshowid',\n- 'showtitle', 'season',\n- 'episode']})\n- return _first_match_or_none('episode', item, resp.get('episodes', []),\n- item_fb, _match_episode)\n-\n-\n-def guess_movie(item, item_fb):\n- \"\"\"\n- Tries to identify the movie in the Kodi library represented by the item.\n- \"\"\"\n- params = {'properties': ['playcount', 'year', 'title']}\n- try:\n- params['filter'] = {'year': item['year']}\n- except (TypeError, KeyError):\n- pass\n- resp = json_rpc('VideoLibrary.GetMovies', params)\n- return _first_match_or_none('movie', item, resp.get('movies', []),\n- item_fb, _match_movie)\n-\n-\n-def _get_safe_with_fallback(item, fallback, **kwargs):\n- itemkey = kwargs.get('itemkey', 'title')\n- fallbackkey = kwargs.get('fallbackkey', 'title')\n- default = kwargs.get('default', '')\n- try:\n- return item.get(itemkey) or fallback.get(fallbackkey)\n- except AttributeError:\n- return default\n-\n-\n-def _first_match_or_none(mediatype, item, candidates, item_fb, match_fn):\n- return next(({'dbtype': mediatype,\n- 'dbid': candidate['{}id'.format(mediatype)],\n- 'playcount': candidate['playcount']}\n- for candidate in candidates\n- if match_fn(item, candidate, item_fb)),\n- None)\n-\n-\n-def _match_movie(item, movie, fallback_data):\n- title = _get_safe_with_fallback(item, fallback_data)\n- movie_meta = '%s (%d)' % (movie['label'], movie['year'])\n- return movie_meta == title or movie['label'] in title\n-\n-\n-def _match_episode_explicitly(item, candidate):\n- try:\n- matches_show = (item.get('tvshowid') == candidate['tvshowid'] or\n- item.get('showtitle') == candidate['showtitle'])\n- matches_season = item.get('season') == candidate['season']\n- matches_episode = item.get('episode') == candidate['episode']\n- return matches_show and matches_season and matches_episode\n- except AttributeError:\n- return False\n-\n-\n-def _match_episode_by_title(title, candidate):\n- episode_meta = 'S%02dE%02d' % (candidate['season'],\n- candidate['episode'])\n- return candidate['showtitle'] in title and episode_meta in title\n-\n-\n-def _match_episode(item, candidate, item_fb):\n- title = _get_safe_with_fallback(item, item_fb, itemkey='label')\n- return (_match_episode_explicitly(item, candidate) or\n- _match_episode_by_title(title, candidate))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/section_skipping.py",
"new_path": "resources/lib/section_skipping.py",
"diff": "# pylint: disable=import-error\n\"\"\"Skipping of video sections (recap, intro)\"\"\"\n-try:\n- import cPickle as pickle\n-except ImportError:\n- import pickle\n-\nimport xbmc\nimport xbmcgui\n-from resources.lib.KodiHelper import TAGGED_WINDOW_ID, PROP_TIMELINE_MARKERS\nfrom resources.lib.kodi.skip import Skip\nAUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n'{:02d}:{:02d},silent)'\n-SKIPPABLE_SECTIONS = ['recap', 'credit']\n+SKIPPABLE_SECTIONS = {'credit': 30076, 'recap': 30077}\nOFFSET_CREDITS = 'creditsOffset'\nOFFSET_WATCHED_TO_END = 'watchedToEndOffset'\n@@ -38,29 +32,15 @@ class SectionSkipper(object):\nself.pause_on_skip = False\nself._markers = {}\n- def on_playback_started(self):\n+ def initialize(self, markers):\n\"\"\"\n- Initialize settings and timeline markers for a new playback\n+ Init markers and load settings\n\"\"\"\n- self._load_settings()\n- self._load_markers()\n-\n- def _load_settings(self):\n+ self._markers = markers or {}\nself.enabled = self.addon.getSetting('skip_credits') == 'true'\nself.auto_skip = self.addon.getSetting('auto_skip_credits') == 'true'\nself.pause_on_skip = self.addon.getSetting('pause_on_skip') == 'true'\n- def _load_markers(self):\n- try:\n- self._markers = pickle.loads(xbmcgui.Window(\n- TAGGED_WINDOW_ID).getProperty(PROP_TIMELINE_MARKERS))\n- # pylint: disable=bare-except\n- except:\n- self.log('No timeline markers found')\n- self._markers = {'creditMarkers': {}}\n-\n- self.log('Found timeline markers: {}'.format(self._markers))\n-\ndef on_tick(self, elapsed):\n\"\"\"\nCheck if playback has reached a skippable section and skip if this is\n@@ -68,19 +48,18 @@ class SectionSkipper(object):\n\"\"\"\nif self.enabled:\nfor section in SKIPPABLE_SECTIONS:\n- self._check_section(elapsed, section)\n+ self._check_section(section, elapsed)\n- def _check_section(self, elapsed, section):\n- section_markers = self._markers['creditMarkers'].get(section)\n- if (section_markers is not None and\n+ def _check_section(self, section, elapsed):\n+ section_markers = self._markers.get(section)\n+ if (section_markers and\nelapsed >= section_markers['start'] and\nelapsed < section_markers['end']):\nself._skip_section(section)\n- del self._markers['creditMarkers'][section]\n+ del self._markers[section]\ndef _skip_section(self, section):\n- label = self.addon.getLocalizedString(\n- 30076 if section == 'credit' else 30077)\n+ label = self.addon.getLocalizedString(SKIPPABLE_SECTIONS[section])\nif self.auto_skip:\nself._auto_skip(section, label)\nelse:\n@@ -93,22 +72,21 @@ class SectionSkipper(object):\nif self.pause_on_skip:\nplayer.pause()\nxbmc.sleep(1000) # give kodi the chance to execute\n- player.seekTime(self._markers['creditMarkers'][section]['end'])\n+ player.seekTime(self._markers[section]['end'])\nxbmc.sleep(1000) # give kodi the chance to execute\nplayer.pause() # unpause playback at seek position\nelse:\n- player.seekTime(self._markers['creditMarkers'][section]['end'])\n+ player.seekTime(self._markers[section]['end'])\ndef _ask_to_skip(self, section, label):\ndlg = Skip(\"plugin-video-netflix-Skip.xml\",\nself.addon.getAddonInfo('path'),\n\"default\", \"1080i\",\n- section=section,\n- skip_to=self._markers['creditMarkers'][section]['end'],\n+ skip_to=self._markers[section]['end'],\nlabel=label)\n# close skip intro dialog after time\n- dialog_duration = (self._markers['creditMarkers'][section]['end'] -\n- self._markers['creditMarkers'][section]['start'])\n+ dialog_duration = (self._markers[section]['end'] -\n+ self._markers[section]['start'])\nseconds = dialog_duration % 60\nminutes = (dialog_duration - seconds) / 60\nxbmc.executebuiltin(AUTOCLOSE_COMMAND.format(minutes, seconds))\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "@@ -145,6 +145,13 @@ def json_rpc(method, params=None):\nreturn response['result']\n+def update_library_item_details(dbtype, dbid, details):\n+ method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n+ params = {'{}id'.format(dbtype): dbid}\n+ params.update(details)\n+ return json_rpc(method, params)\n+\n+\ndef retry(func, max_tries, sleep_time=3000):\n\"\"\"\nRetry an operation max_tries times and wait sleep_time milliseconds\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Massive declutter, use addonsignals |
105,989 | 31.07.2018 22:51:12 | -7,200 | 85b7fff272ee27e96b8b3b49adb35e5c4c3aa0c5 | Codeclimate again | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -30,6 +30,26 @@ from resources.lib.section_skipping import (\nSKIPPABLE_SECTIONS, OFFSET_CREDITS, OFFSET_WATCHED_TO_END)\n+def _get_offset_markers(metadata):\n+ return {\n+ marker: metadata[marker]\n+ for marker in [OFFSET_CREDITS, OFFSET_WATCHED_TO_END]\n+ if metadata[marker] is not None\n+ }\n+\n+\n+def _get_section_markers(metadata):\n+ return {\n+ section: {\n+ 'start': int(metadata['creditMarkers'][section]['start'] /\n+ 1000),\n+ 'end': int(metadata['creditMarkers'][section]['end'] / 1000)\n+ }\n+ for section in SKIPPABLE_SECTIONS\n+ if None not in metadata['creditMarkers'][section].values()\n+ }\n+\n+\nclass Navigation(object):\n\"\"\"\nRoutes to the correct subfolder,\n@@ -283,21 +303,8 @@ class Navigation(object):\nexcept KeyError:\nreturn {}\n- markers = {\n- marker: metadata[marker]\n- for marker in [OFFSET_CREDITS, OFFSET_WATCHED_TO_END]\n- if metadata[marker] is not None\n- }\n-\n- markers.update({\n- section: {\n- 'start': int(metadata['creditMarkers'][section]['start'] /\n- 1000),\n- 'end': int(metadata['creditMarkers'][section]['end'] / 1000)\n- }\n- for section in SKIPPABLE_SECTIONS.keys()\n- if None not in metadata['creditMarkers'][section].values()\n- })\n+ markers = _get_offset_markers(metadata)\n+ markers.update(_get_section_markers(metadata))\nreturn markers\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/skip.py",
"new_path": "resources/lib/kodi/skip.py",
"diff": "-# pylint: disable=invalid-name,missing-docstring,attribute-defined-outside-init,\n-# pylint: disable=import-error\n+# pylint: disable=invalid-name,missing-docstring\n+# pylint: disable=attribute-defined-outside-init,import-error\nfrom platform import machine\nimport xbmc\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "@@ -189,9 +189,8 @@ def find_episode(episode_id, seasons):\nmetadata dict.\nReturns an empty dict if the episode could not be found.\n\"\"\"\n- episodes = (e for season_episodes in (s['episodes'] for s in seasons)\n- for e in season_episodes)\n- return next((episode\n- for episode in episodes\n- if str(episode['id']) == episode_id),\n- {})\n+ for season in seasons:\n+ for episode in season['episodes']:\n+ if str(episode['id']) == episode_id:\n+ return episode\n+ return {}\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Codeclimate again |
105,989 | 01.08.2018 18:04:48 | -7,200 | ca6dcaa6867d63fcc80c34f08cde4c6400f82ed6 | Fix for missing fanart images on non-netflix originals | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -24,7 +24,7 @@ except:\nFETCH_VIDEO_REQUEST_COUNT = 26\n-ART_BILLBOARD_SIZE = '_1920x1080'\n+ART_FANART_SIZE = '1080'\nART_MOMENT_SIZE_SMALL = '_665x375'\nART_MOMENT_SIZE_LARGE = '_1920x1080'\nART_BOX_SIZE_POSTER = '_342x684'\n@@ -835,7 +835,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = video.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\nlogo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\n@@ -1190,7 +1190,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = video.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\nlogo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\nseason['summary']['id']: {\n@@ -1336,7 +1336,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = episode.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = episode.get('artWorkByType', {}).get('BILLBOARD', {}).get(ART_BILLBOARD_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = episode.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\nlogo = episode.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\n@@ -1435,7 +1435,7 @@ class NetflixSession(object):\nitem_path + item_titles + item_pagination + ['reference', 'storyarts', '_1632x873', 'jpg'],\nitem_path + item_titles + item_pagination + ['reference', 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\nitem_path + item_titles + item_pagination + ['reference', 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n- item_path + item_titles + item_pagination + ['reference', 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg'],\n+ item_path + item_titles + item_pagination + ['reference', 'BGImages', ART_FANART_SIZE, 'jpg'],\nitem_path + item_titles + item_pagination + ['reference', 'cast', {'from': 0, 'to': 15}, ['id', 'name']],\nitem_path + item_titles + item_pagination + ['reference', 'cast', 'summary'],\nitem_path + item_titles + item_pagination + ['reference', 'genres', {'from': 0, 'to': 5}, ['id', 'name']],\n@@ -1488,7 +1488,7 @@ class NetflixSession(object):\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'storyarts', '_1632x873', 'jpg'],\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n- ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n+ ['lists', [list_id], {'from': list_from, 'to': list_to}, \"reference\", 'BGImages', ART_FANART_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\n@@ -1584,7 +1584,7 @@ class NetflixSession(object):\n['videos', id, 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n['videos', id, 'interestingMoment', ART_MOMENT_SIZE_SMALL, 'jpg'],\n['videos', id, 'interestingMoment', ART_MOMENT_SIZE_LARGE, 'jpg'],\n- ['videos', id, 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n+ ['videos', id, 'BGImages', ART_FANART_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\nreturn self._process_response(response=response, component='Seasons')\n@@ -1628,7 +1628,7 @@ class NetflixSession(object):\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'artWorkByType', 'BILLBOARD', ART_BILLBOARD_SIZE, 'jpg']\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'BGImages', ART_FANART_SIZE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\nreturn self._process_response(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix for missing fanart images on non-netflix originals |
105,989 | 01.08.2018 20:59:25 | -7,200 | e8093f6b72fd26111978675bc56a736f3e03ada5 | Fix fanart extraction, lower quality for fanart to distinguish it from interestingMoment | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -24,13 +24,15 @@ except:\nFETCH_VIDEO_REQUEST_COUNT = 26\n-ART_FANART_SIZE = '1080'\n+# Fanart: lower quality than 1080, but provides more variance\n+# (1080 is usually the same as interestingMoment)\n+ART_FANART_SIZE = '720'\nART_MOMENT_SIZE_SMALL = '_665x375'\nART_MOMENT_SIZE_LARGE = '_1920x1080'\nART_BOX_SIZE_POSTER = '_342x684'\nART_BOX_SIZE_SMALL = '_665x375'\nART_BOX_SIZE_LARGE = '_1920x1080'\n-ART_LOGO_SIZE = '_400x90'\n+ART_LOGO_SIZE = '_550x124'\nclass NetflixSession(object):\n@@ -835,7 +837,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', [{}])[0].get('url')\nlogo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\n@@ -1190,7 +1192,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = video.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = video.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', [{}])[0].get('url')\nlogo = video.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\nseason['summary']['id']: {\n@@ -1336,7 +1338,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = episode.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = episode.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', {}).get('url')\n+ artwork = episode.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', [{}])[0].get('url')\nlogo = episode.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix fanart extraction, lower quality for fanart to distinguish it from interestingMoment |
105,989 | 01.08.2018 21:07:05 | -7,200 | 1d12dd4c73deffd956326efcc4212a9923bb6f1d | Only reduce fanart quality for episodes | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -24,9 +24,10 @@ except:\nFETCH_VIDEO_REQUEST_COUNT = 26\n-# Fanart: lower quality than 1080, but provides more variance\n-# (1080 is usually the same as interestingMoment)\n-ART_FANART_SIZE = '720'\n+ART_FANART_SIZE = '1080'\n+# Lower quality for episodes than 1080, because it provides more variance\n+# (1080 is usually the same as interestingMoment for episodes)\n+ART_FANART_SIZE_EPISODE = '720'\nART_MOMENT_SIZE_SMALL = '_665x375'\nART_MOMENT_SIZE_LARGE = '_1920x1080'\nART_BOX_SIZE_POSTER = '_342x684'\n@@ -1338,7 +1339,7 @@ class NetflixSession(object):\nbx_big = boxarts.get(ART_BOX_SIZE_LARGE, {}).get('jpg', {}).get('url')\nbx_poster = boxarts.get(ART_BOX_SIZE_POSTER, {}).get('jpg', {}).get('url')\nmoment = episode.get('interestingMoment', {}).get(ART_MOMENT_SIZE_LARGE, {}).get('jpg', {}).get('url')\n- artwork = episode.get('BGImages', {}).get(ART_FANART_SIZE, {}).get('jpg', [{}])[0].get('url')\n+ artwork = episode.get('BGImages', {}).get(ART_FANART_SIZE_EPISODE, {}).get('jpg', [{}])[0].get('url')\nlogo = episode.get('bb2OGLogo', {}).get(ART_LOGO_SIZE, {}).get('png', {}).get('url')\nreturn {\n@@ -1630,7 +1631,7 @@ class NetflixSession(object):\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_LARGE, 'jpg'],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'boxarts', ART_BOX_SIZE_POSTER, 'jpg'],\n['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'bb2OGLogo', ART_LOGO_SIZE, 'png'],\n- ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'BGImages', ART_FANART_SIZE, 'jpg']\n+ ['seasons', season_id, 'episodes', {'from': list_from, 'to': list_to}, 'BGImages', ART_FANART_SIZE_EPISODE, 'jpg']\n]\nresponse = self._path_request(paths=paths)\nreturn self._process_response(\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Only reduce fanart quality for episodes |
105,989 | 07.08.2018 12:53:05 | -7,200 | 1aeb2ee08fa111cef1da04da89d56f80b650a4f4 | Add save and restore of audio/subtitle settings across all episodes of a show. Heavily refactor code for action to be taken during playback (KodiMonitor) | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -963,9 +963,12 @@ class KodiHelper(object):\nplay_item.setInfo('video', details[0])\nplay_item.setArt(details[1])\nsignal_data.update({\n+ 'dbinfo': {\n'dbid': details[0]['dbid'],\n'dbtype': details[0]['mediatype'],\n- 'playcount': details[0]['playcount']})\n+ 'playcount': details[0]['playcount']}})\n+ if infoLabels['mediatype'] == 'episode':\n+ signal_data['dbinfo'].update({'tvshowid': id[0]})\nAddonSignals.sendSignal(Signals.PLAYBACK_INITIATED, signal_data)\n"
},
{
"change_type": "DELETE",
"old_path": "resources/lib/KodiMonitor.py",
"new_path": null,
"diff": "-# -*- coding: utf-8 -*-\n-# Author: caphm\n-# Module: KodiMonitor\n-# Created on: 08.02.2018\n-# License: MIT https://goo.gl/5bMj3H\n-# pylint: disable=import-error\n-\n-\"\"\"Playback tracking & update of associated item properties in Kodi library\"\"\"\n-\n-from json import loads\n-\n-import AddonSignals\n-from xbmc import Monitor\n-\n-from resources.lib.NetflixCommon import Signals\n-from resources.lib.section_skipping import (\n- SectionSkipper, OFFSET_WATCHED_TO_END)\n-from resources.lib.utils import json_rpc, update_library_item_details\n-\n-\n-class KodiMonitor(Monitor):\n- \"\"\"\n- Tracks status and progress of video playbacks initiated by the addon and\n- saves bookmarks and watched state for the associated items into the Kodi\n- library.\n- \"\"\"\n- def __init__(self, nx_common):\n- super(KodiMonitor, self).__init__()\n- self.log = nx_common.log\n- self.section_skipper = SectionSkipper(nx_common)\n- self.tracking = False\n- self.dbinfo = None\n- self.progress = 0\n- self.elapsed = 0\n- self.active_player_id = None\n-\n- AddonSignals.registerSlot(\n- nx_common.addon.getAddonInfo('id'), Signals.PLAYBACK_INITIATED,\n- self.setup_playback_tracking)\n-\n- def setup_playback_tracking(self, data):\n- \"\"\"\n- Callback for addon signal when this addon initiates a playback\n- \"\"\"\n- self.tracking = True\n- self.dbinfo = data.get('dbinfo')\n- self.progress = 0\n- self.elapsed = 0\n- self.section_skipper.initialize(data.get('timeline_markers'))\n-\n- def onNotification(self, sender, method, data):\n- # pylint: disable=unused-argument, invalid-name\n- \"\"\"\n- Callback for Kodi notifications that handles and dispatches playback\n- started and playback stopped events.\n- \"\"\"\n- if self.tracking:\n- if method == 'Player.OnAVStart':\n- data = loads(unicode(data, 'utf-8', errors='ignore'))\n- self.active_player_id = data['player']['playerid']\n- elif method == 'Player.OnStop':\n- self._on_playback_stopped()\n-\n- def on_playback_tick(self):\n- \"\"\"\n- Update the internal progress tracking of a playback and check if\n- sections need to be skipped\n- \"\"\"\n- if self.tracking:\n- self._update_progress()\n- self.section_skipper.on_tick(self.elapsed)\n-\n- def _update_progress(self):\n- try:\n- player_props = json_rpc('Player.GetProperties', {\n- 'playerid': self.active_player_id,\n- 'properties': ['percentage', 'time']\n- })\n- except IOError:\n- return\n-\n- self.progress = player_props['percentage']\n- self.elapsed = (player_props['time']['hours'] * 3600 +\n- player_props['time']['minutes'] * 60 +\n- player_props['time']['seconds'])\n-\n- if self.dbinfo:\n- self._save_bookmark()\n-\n- def _save_bookmark(self):\n- update_library_item_details(\n- self.dbinfo['dbtype'], self.dbinfo['dbid'],\n- {'resume': {'position': self.elapsed}})\n-\n- def _on_playback_stopped(self):\n- if self.tracking and self.dbinfo and self._watched_to_end():\n- self._mark_as_watched()\n-\n- self.tracking = False\n- self.dbinfo = None\n- self.progress = 0\n- self.elapsed = 0\n- self.active_player_id = None\n-\n- def _watched_to_end(self):\n- return (\n- (OFFSET_WATCHED_TO_END in self.timeline_markers and\n- self.elapsed >= self.timeline_markers[OFFSET_WATCHED_TO_END]) or\n- (OFFSET_WATCHED_TO_END not in self.timeline_markers and\n- self.progress >= 90))\n-\n- def _mark_as_watched(self):\n- update_library_item_details(\n- self.dbinfo['dbtype'], self.dbinfo['dbid'],\n- {'playcount': self.dbinfo.get('playcount', 0) + 1,\n- 'resume': {'position': 0}})\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/Navigation.py",
"new_path": "resources/lib/Navigation.py",
"diff": "@@ -46,7 +46,8 @@ def _get_section_markers(metadata):\n'end': int(metadata['creditMarkers'][section]['end'] / 1000)\n}\nfor section in SKIPPABLE_SECTIONS\n- if None not in metadata['creditMarkers'][section].values()\n+ if (None not in metadata['creditMarkers'][section].values() and\n+ any(i > 0 for i in metadata['creditMarkers'][section].values()))\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixCommon.py",
"new_path": "resources/lib/NetflixCommon.py",
"diff": "@@ -3,6 +3,8 @@ from xbmcaddon import Addon\nimport xbmcvfs\nimport json\n+from resources.lib.storage import PersistentStorage\n+\nclass Signals(object):\nPLAYBACK_INITIATED = 'playback_initiated'\n@@ -42,6 +44,9 @@ class NetflixCommon(object):\ndef flush_settings(self):\nself.addon = Addon()\n+ def get_storage(self, storage_id):\n+ return PersistentStorage(storage_id, self)\n+\ndef get_esn(self):\n\"\"\"\nReturns the esn from settings\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/kodi/__init__.py",
"new_path": "resources/lib/kodi/__init__.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Package: kodi\n+# Created on: 06.08.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"Kodi GUI stuff\"\"\"\n+\n+import xbmc\n+\n+CMD_AUTOCLOSE_DIALOG = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n+ '{:02d}:{:02d},silent)'\n+\n+\n+def show_modal_dialog(dlg_class, xml, path, **kwargs):\n+ \"\"\"\n+ Show a modal Dialog in the UI.\n+ Pass kwargs minutes and/or seconds tohave the dialog automatically\n+ close after the specified time.\n+ \"\"\"\n+ dlg = dlg_class(xml, path, \"default\", \"1080i\", **kwargs)\n+ minutes = kwargs.get('minutes', 0)\n+ seconds = kwargs.get('seconds', 0)\n+ if minutes > 0 or seconds > 0:\n+ xbmc.executebuiltin(CMD_AUTOCLOSE_DIALOG.format(minutes, seconds))\n+ dlg.doModal()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/kodi/save_stream_settings.py",
"diff": "+# pylint: disable=invalid-name,missing-docstring\n+# pylint: disable=attribute-defined-outside-init,import-error\n+from platform import machine\n+\n+import xbmcgui\n+\n+\n+ACTION_PLAYER_STOP = 13\n+OS_MACHINE = machine()\n+\n+\n+class SaveStreamSettings(xbmcgui.WindowXMLDialog):\n+ \"\"\"\n+ Dialog for skipping video parts (intro, recap, ...)\n+ \"\"\"\n+ def __init__(self, *args, **kwargs):\n+ self.stream_settings = kwargs['stream_settings']\n+ self.tvshowid = kwargs['tvshowid']\n+ self.storage = kwargs['storage']\n+ if OS_MACHINE[0:5] == 'armv7':\n+ xbmcgui.WindowXMLDialog.__init__(self)\n+ else:\n+ xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+\n+ def onInit(self):\n+ self.action_exitkeys_id = [10, 13]\n+\n+ def onClick(self, controlID):\n+ if controlID == 6012:\n+ self.storage[self.tvshowid] = self.stream_settings\n+ self.close()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/playback_controlling/__init__.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Package: playback_controlling\n+# Created on: 08.02.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"Playback tracking and coordination of several actions during playback\"\"\"\n+\n+import json\n+\n+import xbmc\n+import AddonSignals\n+\n+from resources.lib.NetflixCommon import Signals\n+from resources.lib.utils import LoggingComponent\n+\n+\n+def json_rpc(method, params=None):\n+ \"\"\"\n+ Executes a JSON-RPC in Kodi\n+\n+ :param method: The JSON-RPC method to call\n+ :type method: string\n+ :param params: The parameters of the method call (optional)\n+ :type params: dict\n+ :returns: dict -- Method call result\n+ \"\"\"\n+ request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n+ 'params': params or {}}\n+ request = json.dumps(request_data)\n+ response = json.loads(unicode(xbmc.executeJSONRPC(request), 'utf-8',\n+ errors='ignore'))\n+ if 'error' in response:\n+ raise IOError('JSONRPC-Error {}: {}'\n+ .format(response['error']['code'],\n+ response['error']['message']))\n+ return response['result']\n+\n+\n+class PlaybackController(xbmc.Monitor, LoggingComponent):\n+ \"\"\"\n+ Tracks status and progress of video playbacks initiated by the addon and\n+ saves bookmarks and watched state for the associated items into the Kodi\n+ library.\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ xbmc.Monitor.__init__(self)\n+ LoggingComponent.__init__(self, nx_common)\n+ self.tracking = False\n+ self.active_player_id = None\n+ self.action_managers = []\n+\n+ AddonSignals.registerSlot(\n+ nx_common.addon.getAddonInfo('id'), Signals.PLAYBACK_INITIATED,\n+ self.initialize_playback)\n+\n+ def initialize_playback(self, data):\n+ \"\"\"\n+ Callback for addon signal when this addon has initiated a playback\n+ \"\"\"\n+ self.tracking = True\n+ self._notify_all(PlaybackActionManager.initialize, data)\n+\n+ def onNotification(self, sender, method, data):\n+ # pylint: disable=unused-argument, invalid-name\n+ \"\"\"\n+ Callback for Kodi notifications that handles and dispatches playback\n+ started and playback stopped events.\n+ \"\"\"\n+ if self.tracking:\n+ if method == 'Player.OnAVStart':\n+ self._on_playback_started(\n+ json.loads(unicode(data, 'utf-8', errors='ignore')))\n+ elif method == 'Player.OnStop':\n+ self._on_playback_stopped()\n+\n+ def on_playback_tick(self):\n+ \"\"\"\n+ Notify action managers of playback tick\n+ \"\"\"\n+ if self.tracking:\n+ player_state = self._get_player_state()\n+ if player_state:\n+ self._notify_all(PlaybackActionManager.on_tick,\n+ player_state)\n+\n+ def _on_playback_started(self, data):\n+ self.active_player_id = data['player']['playerid']\n+ self._notify_all(PlaybackActionManager.on_playback_started,\n+ self._get_player_state())\n+\n+ def _on_playback_stopped(self):\n+ self.tracking = False\n+ self.active_player_id = None\n+ self._notify_all(PlaybackActionManager.on_playback_stopped)\n+\n+ def _notify_all(self, notification, data=None):\n+ self.log('Notifying all managers of {} (data={})'\n+ .format(notification.__name__, data))\n+ for manager in self.action_managers:\n+ notify_method = getattr(manager, notification.__name__)\n+ if data is not None:\n+ notify_method(data)\n+ else:\n+ notify_method()\n+\n+ def _get_player_state(self):\n+ try:\n+ player_state = json_rpc('Player.GetProperties', {\n+ 'playerid': self.active_player_id,\n+ 'properties': [\n+ 'audiostreams',\n+ 'currentaudiostream',\n+ 'subtitles',\n+ 'currentsubtitle',\n+ 'subtitleenabled',\n+ 'percentage',\n+ 'time']\n+ })\n+ except IOError:\n+ return {}\n+\n+ # convert time dict to elapsed seconds\n+ player_state['elapsed_seconds'] = (\n+ player_state['time']['hours'] * 3600 +\n+ player_state['time']['minutes'] * 60 +\n+ player_state['time']['seconds'])\n+\n+ return player_state\n+\n+\n+class PlaybackActionManager(LoggingComponent):\n+ \"\"\"\n+ Base class for managers that handle executing of specific actions\n+ during playback\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ LoggingComponent.__init__(self, nx_common)\n+ self.addon = nx_common.get_addon()\n+ self._enabled = None\n+\n+ @property\n+ def enabled(self):\n+ \"\"\"\n+ Indicates whether this instance is enabled or not.\n+ Loads the value from Kodi settings if it has not been set.\n+ \"\"\"\n+ if self._enabled is None:\n+ self.log('Loading enabled setting from store')\n+ self._enabled = self.addon.getSetting(\n+ '{}_enabled'.format(self.__class__.__name__))\n+\n+ return self._enabled\n+\n+ @enabled.setter\n+ def enabled(self, enabled):\n+ self._enabled = enabled\n+\n+ def initialize(self, data):\n+ \"\"\"\n+ Initialize the manager with data when the addon initiates a playback.\n+ \"\"\"\n+ # pylint: disable=bare-except\n+ try:\n+ self._call_if_enabled(self._initialize, data=data)\n+ except:\n+ self.enabled = False\n+ self.log('Initialiized ({})'.format(self))\n+\n+ def on_playback_started(self, player_state):\n+ \"\"\"\n+ Notify that the playback has actually started and supply initial\n+ player state\n+ \"\"\"\n+ self._call_if_enabled(self._on_playback_started,\n+ player_state=player_state)\n+\n+ def on_tick(self, player_state):\n+ \"\"\"\n+ Notify that a playback tick has passed and supply current player state\n+ \"\"\"\n+ self._call_if_enabled(self._on_tick, player_state=player_state)\n+\n+ def on_playback_stopped(self):\n+ \"\"\"\n+ Notify that a playback has stopped\n+ \"\"\"\n+ self._call_if_enabled(self._on_playback_stopped)\n+ self.enabled = None\n+\n+ def _call_if_enabled(self, target_func, **kwargs):\n+ if self.enabled:\n+ target_func(**kwargs)\n+\n+ def _initialize(self, data):\n+ \"\"\"\n+ Initialize the manager for a new playback.\n+ If preconditions are not met, this should raise an exception so the\n+ manager will be disabled throught the current playback.\n+ \"\"\"\n+ raise NotImplementedError\n+\n+ def _on_playback_started(self, player_state):\n+ pass\n+\n+ def _on_tick(self, player_state):\n+ raise NotImplementedError\n+\n+ def _on_playback_stopped(self):\n+ pass\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/playback_controlling/bookmarks.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Package: bookmarking\n+# Created on: 02.08.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"Save bookmarks for library items and mark them as watched\"\"\"\n+\n+from resources.lib.playback_controlling import PlaybackActionManager, json_rpc\n+\n+OFFSET_WATCHED_TO_END = 'watchedToEndOffset'\n+\n+\n+def update_library_item_details(dbtype, dbid, details):\n+ \"\"\"\n+ Update properties of an item in the Kodi library\n+ \"\"\"\n+ method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n+ params = {'{}id'.format(dbtype): dbid}\n+ params.update(details)\n+ return json_rpc(method, params)\n+\n+\n+class BookmarkManager(PlaybackActionManager):\n+ \"\"\"\n+ Saves bookmarks on each playback tick if the played item exists in the\n+ Kodi library and marks it as watched after playback.\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ super(BookmarkManager, self).__init__(nx_common)\n+ self.dbinfo = None\n+ self.markers = None\n+ self.progress = 0\n+ self.elapsed = 0\n+\n+ def __str__(self):\n+ return ('enabled={}, dbinfo={}, markers={}'\n+ .format(self.enabled, self.dbinfo, self.markers))\n+\n+ def _initialize(self, data):\n+ self.dbinfo = data['dbinfo']\n+ self.markers = data.get('timeline_markers', {})\n+ self.progress = 0\n+ self.elapsed = 0\n+\n+ def _on_playback_stopped(self):\n+ if self._watched_to_end():\n+ self._mark_as_watched()\n+\n+ def _on_tick(self, player_state):\n+ self.progress = player_state['percentage']\n+ self.elapsed = player_state['elapsed_seconds']\n+ if self.elapsed % 5 == 0:\n+ self._save_bookmark()\n+\n+ def _save_bookmark(self):\n+ self.log('Saving bookmark for {} at {}s'.format(self.dbinfo,\n+ self.elapsed))\n+ update_library_item_details(\n+ self.dbinfo['dbtype'], self.dbinfo['dbid'],\n+ {'resume': {'position': self.elapsed}})\n+\n+ def _watched_to_end(self):\n+ return (\n+ (OFFSET_WATCHED_TO_END in self.markers and\n+ self.elapsed >= self.markers[OFFSET_WATCHED_TO_END]) or\n+ (OFFSET_WATCHED_TO_END not in self.markers and\n+ self.progress >= 90))\n+\n+ def _mark_as_watched(self):\n+ self.log('Marking {} as watched'.format(self.dbinfo))\n+ update_library_item_details(\n+ self.dbinfo['dbtype'], self.dbinfo['dbid'],\n+ {'playcount': self.dbinfo.get('playcount', 0) + 1,\n+ 'resume': {'position': 0}})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/playback_controlling/section_skipping.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Module: section_skipping\n+# Created on: 31.07.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"Skipping of video sections (recap, intro)\"\"\"\n+import xbmc\n+import xbmcgui\n+\n+from resources.lib.playback_controlling import PlaybackActionManager\n+from resources.lib.kodi import show_modal_dialog\n+from resources.lib.kodi.skip import Skip\n+\n+\n+SKIPPABLE_SECTIONS = {'credit': 30076, 'recap': 30077}\n+OFFSET_CREDITS = 'creditsOffset'\n+\n+\n+class SectionSkipper(PlaybackActionManager):\n+ \"\"\"\n+ Checks if a skippable section has been reached and takes appropriate action\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ super(SectionSkipper, self).__init__(nx_common)\n+ self.markers = {}\n+ self.auto_skip = False\n+ self.pause_on_skip = False\n+\n+ def __str__(self):\n+ return ('enabled={}, markers={}, auto_skip={}, pause_on_skip={}'\n+ .format(self.enabled, self.markers, self.auto_skip,\n+ self.pause_on_skip))\n+\n+ def _initialize(self, data):\n+ self.markers = data['timeline_markers']\n+ self.auto_skip = self.addon.getSetting('auto_skip_credits') == 'true'\n+ self.pause_on_skip = self.addon.getSetting('pause_on_skip') == 'true'\n+\n+ def _on_tick(self, player_state):\n+ for section in SKIPPABLE_SECTIONS:\n+ self._check_section(section, player_state['elapsed_seconds'])\n+\n+ def _check_section(self, section, elapsed):\n+ if (self.markers.get(section) and\n+ elapsed >= self.markers[section]['start'] and\n+ elapsed <= self.markers[section]['end']):\n+ self._skip_section(section)\n+ del self.markers[section]\n+\n+ def _skip_section(self, section):\n+ self.log('Entered section {}'.format(section))\n+ label = self.addon.getLocalizedString(SKIPPABLE_SECTIONS[section])\n+ if self.auto_skip:\n+ self._auto_skip(section, label)\n+ else:\n+ self._ask_to_skip(section, label)\n+\n+ def _auto_skip(self, section, label):\n+ self.log('Auto-skipping {}'.format(section))\n+ player = xbmc.Player()\n+ xbmcgui.Dialog().notification(\n+ 'Netflix', '{}...'.format(label), xbmcgui.NOTIFICATION_INFO, 5000)\n+ if self.pause_on_skip:\n+ player.pause()\n+ xbmc.sleep(1000) # give kodi the chance to execute\n+ player.seekTime(self.markers[section]['end'])\n+ xbmc.sleep(1000) # give kodi the chance to execute\n+ player.pause() # unpause playback at seek position\n+ else:\n+ player.seekTime(self.markers[section]['end'])\n+\n+ def _ask_to_skip(self, section, label):\n+ self.log('Asking to skip {}'.format(section))\n+ dialog_duration = (self.markers[section]['end'] -\n+ self.markers[section]['start'])\n+ seconds = dialog_duration % 60\n+ minutes = (dialog_duration - seconds) / 60\n+ show_modal_dialog(Skip,\n+ \"plugin-video-netflix-Skip.xml\",\n+ self.addon.getAddonInfo('path'),\n+ minutes=minutes,\n+ seconds=seconds,\n+ skip_to=self.markers[section]['end'],\n+ label=label)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/playback_controlling/stream_continuity.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Module: stream_continuity\n+# Created on: 02.08.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"\n+Remember and restore audio stream / subtitle settings between individual\n+episodes of a tv show\n+\"\"\"\n+import xbmc\n+\n+from resources.lib.playback_controlling import PlaybackActionManager\n+from resources.lib.kodi import show_modal_dialog\n+from resources.lib.kodi.save_stream_settings import SaveStreamSettings\n+\n+STREAMS = {\n+ 'audio': {\n+ 'attribute_current': 'currentaudiostream',\n+ 'setter': xbmc.Player.setAudioStream\n+ },\n+ 'subtitle': {\n+ 'attribute_current': 'currentsubtitle',\n+ 'setter': xbmc.Player.setSubtitleStream\n+ }\n+}\n+\n+\n+class StreamContinuityManager(PlaybackActionManager):\n+ \"\"\"\n+ Detects changes in audio / subtitle streams during playback, saves them\n+ for the currently playing show and restores them on subsequent episodes.\n+ \"\"\"\n+ def __init__(self, nx_common):\n+ super(StreamContinuityManager, self).__init__(nx_common)\n+ self.storage = nx_common.get_storage(__name__)\n+ self.current_show = None\n+ self.current_streams = {}\n+ self.player = xbmc.Player()\n+ self.did_restore = False\n+\n+ def __str__(self):\n+ return ('enabled={}, current_show={}'\n+ .format(self.enabled, self.current_show))\n+\n+ def _initialize(self, data):\n+ self.did_restore = False\n+ self.current_show = data['dbinfo']['tvshowid']\n+\n+ def _on_playback_started(self, player_state):\n+ for stype, stream in STREAMS.iteritems():\n+ current_player_stream = player_state[stream['attribute_current']]\n+ if current_player_stream:\n+ self.current_streams.update({\n+ stype: current_player_stream['index']\n+ })\n+ self._restore_stream(stype, stream['setter'])\n+ self.did_restore = True\n+\n+ def _on_tick(self, player_state):\n+ if not self.did_restore:\n+ self.log('Did not restore streams yet, ignoring tick')\n+ return\n+\n+ for stype in self.current_streams:\n+ stream = STREAMS[stype]\n+ current_player_stream = player_state[stream['attribute_current']]\n+ if (self.current_streams[stype] !=\n+ current_player_stream['index']):\n+ self.log('{} stream has changed from {} to {}'\n+ .format(stype,\n+ self.current_streams[stype],\n+ current_player_stream))\n+ self._ask_to_save(\n+ stype, current_player_stream['index'])\n+ self.current_streams[stype] = current_player_stream['index']\n+\n+ def _restore_stream(self, stype, stream_setter):\n+ self.log('Trying to restore {}...'.format(stype))\n+ stored_streams = self.storage.get(self.current_show, {})\n+ if (stype in stored_streams and\n+ (stored_streams[stype] != self.current_streams[stype] or\n+ stype not in self.current_streams)):\n+ self.current_streams[stype] = stored_streams[stype]\n+ getattr(self.player, stream_setter.__name__)(\n+ self.current_streams[stype])\n+ self.log('Restored {}'.format(stype))\n+\n+ def _ask_to_save(self, stype, index):\n+ self.log('Asking to save {} stream #{}'.format(stype, index))\n+ stream_settings = self.storage.get(self.current_show, {})\n+ stream_settings[stype] = index\n+ show_modal_dialog(SaveStreamSettings,\n+ \"plugin-video-netflix-SaveStreamSettings.xml\",\n+ self.addon.getAddonInfo('path'),\n+ minutes=0,\n+ seconds=5,\n+ stream_settings=stream_settings,\n+ tvshowid=self.current_show,\n+ storage=self.storage)\n"
},
{
"change_type": "DELETE",
"old_path": "resources/lib/section_skipping.py",
"new_path": null,
"diff": "-# -*- coding: utf-8 -*-\n-# Author: caphm\n-# Module: section_skipping\n-# Created on: 31.07.2018\n-# License: MIT https://goo.gl/5bMj3H\n-# pylint: disable=import-error\n-\n-\"\"\"Skipping of video sections (recap, intro)\"\"\"\n-import xbmc\n-import xbmcgui\n-\n-from resources.lib.kodi.skip import Skip\n-\n-\n-AUTOCLOSE_COMMAND = 'AlarmClock(closedialog,Dialog.Close(all,true),' \\\n- '{:02d}:{:02d},silent)'\n-SKIPPABLE_SECTIONS = {'credit': 30076, 'recap': 30077}\n-OFFSET_CREDITS = 'creditsOffset'\n-OFFSET_WATCHED_TO_END = 'watchedToEndOffset'\n-\n-\n-class SectionSkipper(object):\n- \"\"\"\n- Encapsulates skipping logic. on_tick() method must periodically\n- be called to execute actions.\n- \"\"\"\n- def __init__(self, nx_common):\n- self.addon = nx_common.get_addon()\n- self.log = nx_common.log\n- self.enabled = False\n- self.auto_skip = False\n- self.pause_on_skip = False\n- self._markers = {}\n-\n- def initialize(self, markers):\n- \"\"\"\n- Init markers and load settings\n- \"\"\"\n- self._markers = markers or {}\n- self.enabled = self.addon.getSetting('skip_credits') == 'true'\n- self.auto_skip = self.addon.getSetting('auto_skip_credits') == 'true'\n- self.pause_on_skip = self.addon.getSetting('pause_on_skip') == 'true'\n-\n- def on_tick(self, elapsed):\n- \"\"\"\n- Check if playback has reached a skippable section and skip if this is\n- the case\n- \"\"\"\n- if self.enabled:\n- for section in SKIPPABLE_SECTIONS:\n- self._check_section(section, elapsed)\n-\n- def _check_section(self, section, elapsed):\n- section_markers = self._markers.get(section)\n- if (section_markers and\n- elapsed >= section_markers['start'] and\n- elapsed < section_markers['end']):\n- self._skip_section(section)\n- del self._markers[section]\n-\n- def _skip_section(self, section):\n- label = self.addon.getLocalizedString(SKIPPABLE_SECTIONS[section])\n- if self.auto_skip:\n- self._auto_skip(section, label)\n- else:\n- self._ask_to_skip(section, label)\n-\n- def _auto_skip(self, section, label):\n- player = xbmc.Player()\n- xbmcgui.Dialog().notification(\n- 'Netflix', '{}...'.format(label), xbmcgui.NOTIFICATION_INFO, 5000)\n- if self.pause_on_skip:\n- player.pause()\n- xbmc.sleep(1000) # give kodi the chance to execute\n- player.seekTime(self._markers[section]['end'])\n- xbmc.sleep(1000) # give kodi the chance to execute\n- player.pause() # unpause playback at seek position\n- else:\n- player.seekTime(self._markers[section]['end'])\n-\n- def _ask_to_skip(self, section, label):\n- dlg = Skip(\"plugin-video-netflix-Skip.xml\",\n- self.addon.getAddonInfo('path'),\n- \"default\", \"1080i\",\n- skip_to=self._markers[section]['end'],\n- label=label)\n- # close skip intro dialog after time\n- dialog_duration = (self._markers[section]['end'] -\n- self._markers[section]['start'])\n- seconds = dialog_duration % 60\n- minutes = (dialog_duration - seconds) / 60\n- xbmc.executebuiltin(AUTOCLOSE_COMMAND.format(minutes, seconds))\n- dlg.doModal()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/lib/storage.py",
"diff": "+# -*- coding: utf-8 -*-\n+# Author: caphm\n+# Module: storage\n+# Created on: 06.08.2018\n+# License: MIT https://goo.gl/5bMj3H\n+# pylint: disable=import-error\n+\n+\"\"\"\n+Easily accessible persistent storage\n+\"\"\"\n+\n+import os\n+try:\n+ import cPickle as pickle\n+except ImportError:\n+ import pickle\n+\n+import xbmcvfs\n+\n+from resources.lib.utils import LoggingComponent\n+\n+\n+class PersistentStorage(LoggingComponent):\n+ \"\"\"\n+ Key-Value storage with a backing file on disk.\n+ Reads entire dict structure into memory on first access and updates\n+ the backing file with each changed entry.\n+\n+ IMPORTANT: Changes to mutable objects inserted into the key-value-store\n+ are not automatically written to disk. You need to call commit() to\n+ persist these changes.\n+ \"\"\"\n+ def __init__(self, storage_id, nx_common):\n+ LoggingComponent.__init__(self, nx_common)\n+ self.storage_id = storage_id\n+ self.backing_file = os.path.join(nx_common.data_path,\n+ self.storage_id + '.ndb')\n+ self._contents = {}\n+ self._dirty = True\n+ self.log('Instantiated {}'.format(self.storage_id))\n+\n+ def __getitem__(self, key):\n+ self.log('Getting {}'.format(key))\n+ return self.contents[key]\n+\n+ def __setitem__(self, key, value):\n+ self.log('Setting {} to {}'.format(key, value))\n+ self._contents[key] = value\n+ self.commit()\n+ self._dirty = True\n+\n+ @property\n+ def contents(self):\n+ \"\"\"\n+ The contents of the storage file\n+ \"\"\"\n+ if self._dirty:\n+ self._load_from_disk()\n+ return self._contents\n+\n+ def get(self, key, default=None):\n+ \"\"\"\n+ Return the value associated with key. If key does not exist,\n+ return default (defaults to None)\n+ \"\"\"\n+ return self.contents.get(key, default)\n+\n+ def commit(self):\n+ \"\"\"\n+ Write current contents to disk\n+ \"\"\"\n+ f = xbmcvfs.File(self.backing_file, 'wb')\n+ pickle.dump(self._contents, f)\n+ f.close()\n+ self.log('Committed changes to backing file')\n+\n+ def clear(self):\n+ \"\"\"\n+ Clear contents and backing file\n+ \"\"\"\n+ self._contents = {}\n+ self.commit()\n+\n+ def _load_from_disk(self):\n+ self.log('Trying to load contents from disk')\n+ if xbmcvfs.exists(self.backing_file):\n+ f = xbmcvfs.File(self.backing_file, 'rb')\n+ self._contents = pickle.loads(f.read())\n+ self._dirty = False\n+ f.close()\n+ self.log('Loaded contents from backing file ({})'.format(self._contents))\n+ else:\n+ self.log('Backing file does not exist')\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/lib/utils.py",
"new_path": "resources/lib/utils.py",
"diff": "import time\nimport hashlib\nimport platform\n-import json\nfrom functools import wraps\nfrom types import FunctionType\nimport xbmc\n+class LoggingComponent(object):\n+ \"\"\"\n+ Prepends log statements with the calling class' name\n+ \"\"\"\n+ # pylint: disable=too-few-public-methods\n+ def __init__(self, nx_common):\n+ self._log = nx_common.log\n+\n+ def log(self, msg, level=xbmc.LOGDEBUG):\n+ \"\"\"\n+ Log a message\n+ \"\"\"\n+ self._log('{}: {}'.format(self.__class__.__name__, msg), level)\n+\n+\ndef noop(**kwargs):\n\"\"\"Takes everything, does nothing, classic no operation function\"\"\"\nreturn kwargs\n@@ -123,55 +137,6 @@ def get_class_methods(class_item=None):\nreturn [x for x, y in class_item.__dict__.items() if isinstance(y, _type)]\n-def json_rpc(method, params=None):\n- \"\"\"\n- Executes a JSON-RPC in Kodi\n-\n- :param method: The JSON-RPC method to call\n- :type method: string\n- :param params: The parameters of the method call (optional)\n- :type params: dict\n- :returns: dict -- Method call result\n- \"\"\"\n- request_data = {'jsonrpc': '2.0', 'method': method, 'id': 1,\n- 'params': params or {}}\n- request = json.dumps(request_data)\n- response = json.loads(unicode(xbmc.executeJSONRPC(request), 'utf-8',\n- errors='ignore'))\n- if 'error' in response:\n- raise IOError('JSONRPC-Error {}: {}'\n- .format(response['error']['code'],\n- response['error']['message']))\n- return response['result']\n-\n-\n-def update_library_item_details(dbtype, dbid, details):\n- \"\"\"\n- Update properties of an item in the Kodi library\n- \"\"\"\n- method = 'VideoLibrary.Set{}Details'.format(dbtype.capitalize())\n- params = {'{}id'.format(dbtype): dbid}\n- params.update(details)\n- return json_rpc(method, params)\n-\n-\n-def retry(func, max_tries, sleep_time=3000):\n- \"\"\"\n- Retry an operation max_tries times and wait sleep_time milliseconds\n- inbetween. Silently ignores exceptions.\n- \"\"\"\n- for _ in range(1, max_tries):\n- try:\n- result = func()\n- if result is not None:\n- return result\n- # pylint: disable=bare-except\n- except:\n- pass\n- xbmc.sleep(sleep_time)\n- return None\n-\n-\ndef find_episode(episode_id, seasons):\n\"\"\"\nReturn metadata for a specific episode from within a nested\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/settings.xml",
"new_path": "resources/settings.xml",
"diff": "<setting id=\"viewmodeexported\" type=\"number\" label=\"30074\" enable=\"eq(-7,true)\" default=\"504\"/>\n</category>\n<category label=\"30078\">\n- <setting id=\"skip_credits\" type=\"bool\" label=\"30075\" default=\"true\"/>\n+ <setting id=\"BookmarkManager_enabled\" type=\"bool\" label=\"Save bookmarks\" default=\"true\"/>\n+ <setting id=\"StreamContinuityManager_enabled\" type=\"bool\" label=\"Remember audio/subtitle streams\" default=\"true\"/>\n+ <setting id=\"SectionSkipper_enabled\" type=\"bool\" label=\"30075\" default=\"true\"/>\n<setting id=\"auto_skip_credits\" type=\"bool\" label=\"30079\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n<setting id=\"pause_on_skip\" type=\"bool\" label=\"30080\" default=\"false\" visible=\"eq(-1,true)\" subsetting=\"true\"/>\n</category>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/skins/default/1080i/plugin-video-netflix-SaveStreamSettings.xml",
"diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<window>\n+ <defaultcontrol always=\"true\">6012</defaultcontrol>\n+ <zorder>0</zorder>\n+ <controls>\n+ <control type=\"group\">\n+ <right>30</right>\n+ <bottom>60</bottom>\n+ <height>80</height>\n+ <width>180</width>\n+ <control type=\"group\">\n+ <control type=\"button\" id=\"6012\">\n+ <description>Save stream settings</description>\n+ <width>180</width>\n+ <height>80</height>\n+ <font>font12</font>\n+ <label>Save these settings?</label>\n+ <textcolor>FFededed</textcolor>\n+ <focusedcolor>FFededed</focusedcolor>\n+ <selectedcolor>FFededed</selectedcolor>\n+ <shadowcolor>66000000</shadowcolor>\n+ <textoffsetx>20</textoffsetx>\n+ <aligny>center</aligny>\n+ <align>center</align>\n+ <texturefocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturefocus>\n+ <texturenofocus border=\"10\" colordiffuse=\"ff222326\">smallbutton.png</texturenofocus>\n+ </control>\n+ </control>\n+ </control>\n+ </controls>\n+</window>\n"
},
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -15,9 +15,13 @@ from datetime import datetime, timedelta\nimport xbmc\nfrom resources.lib.NetflixCommon import NetflixCommon\n-from resources.lib.KodiMonitor import KodiMonitor\nfrom resources.lib.MSLHttpRequestHandler import MSLTCPServer\nfrom resources.lib.NetflixHttpRequestHandler import NetflixTCPServer\n+from resources.lib.playback_controlling import PlaybackController\n+from resources.lib.playback_controlling.bookmarks import BookmarkManager\n+from resources.lib.playback_controlling.stream_continuity import (\n+ StreamContinuityManager)\n+from resources.lib.playback_controlling.section_skipping import SectionSkipper\ndef select_unused_port():\n@@ -169,11 +173,16 @@ class NetflixService(object):\nMain loop. Runs until xbmc.Monitor requests abort\n\"\"\"\nself._start_servers()\n- monitor = KodiMonitor(self.nx_common)\n+ controller = PlaybackController(self.nx_common)\n+ controller.action_managers = [\n+ BookmarkManager(self.nx_common),\n+ SectionSkipper(self.nx_common),\n+ StreamContinuityManager(self.nx_common)\n+ ]\nplayer = xbmc.Player()\n- while not monitor.abortRequested():\n+ while not controller.abortRequested():\nif player.isPlayingVideo():\n- monitor.on_playback_tick()\n+ controller.on_playback_tick()\ntry:\nif self.library_update_scheduled() and self._is_idle():\n@@ -182,7 +191,7 @@ class NetflixService(object):\nself.nx_common.log(\n'RuntimeError: {}'.format(exc), xbmc.LOGERROR)\n- if monitor.waitForAbort(1):\n+ if controller.waitForAbort(1):\nbreak\nself._shutdown()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Add save and restore of audio/subtitle settings across all episodes of a show. Heavily refactor code for action to be taken during playback (KodiMonitor) |
105,989 | 07.08.2018 12:55:21 | -7,200 | c753d809f58db501eef4b756a8d8762000275f37 | Exclude new skins directory from codeclimate checks | [
{
"change_type": "MODIFY",
"old_path": ".codeclimate.yml",
"new_path": ".codeclimate.yml",
"diff": "@@ -18,6 +18,7 @@ exclude_paths:\n- \"resources/lib/UniversalAnalytics/\"\n- \"resources/language/\"\n- \"resources/media/\"\n+ - \"resources/skins/\"\n- \"resources/fanart.jpg\"\n- \"resources/icon.png\"\n- \"resources/screenshot-01.jpg\"\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Exclude new skins directory from codeclimate checks |
105,989 | 08.08.2018 16:24:54 | -7,200 | a93dc37cd996c6915e9a5d4f0c7d5bca930171d4 | Clean up package structure | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/KodiHelper.py",
"new_path": "resources/lib/KodiHelper.py",
"diff": "@@ -15,7 +15,7 @@ import xbmc\nimport xbmcgui\nimport xbmcplugin\nimport inputstreamhelper\n-from resources.lib.kodi.Dialogs import Dialogs\n+from resources.lib.ui.Dialogs import Dialogs\nfrom resources.lib.NetflixCommon import Signals\nfrom utils import get_user_agent\nfrom UniversalAnalytics import Tracker\n"
},
{
"change_type": "DELETE",
"old_path": "resources/lib/kodi/skip.py",
"new_path": null,
"diff": "-# pylint: disable=invalid-name,missing-docstring\n-# pylint: disable=attribute-defined-outside-init,import-error\n-from platform import machine\n-\n-import xbmc\n-import xbmcgui\n-\n-\n-ACTION_PLAYER_STOP = 13\n-OS_MACHINE = machine()\n-\n-\n-class Skip(xbmcgui.WindowXMLDialog):\n- \"\"\"\n- Dialog for skipping video parts (intro, recap, ...)\n- \"\"\"\n- def __init__(self, *args, **kwargs):\n- self.skip_to = kwargs['skip_to']\n- self.label = kwargs['label']\n- if OS_MACHINE[0:5] == 'armv7':\n- xbmcgui.WindowXMLDialog.__init__(self)\n- else:\n- xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n-\n- def onInit(self):\n- self.action_exitkeys_id = [10, 13]\n- self.getControl(6012).setLabel(self.label)\n-\n- def onClick(self, controlID):\n- if controlID == 6012:\n- xbmc.Player().seekTime(self.skip_to)\n- self.close()\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/playback_controlling/__init__.py",
"new_path": "resources/lib/playback/__init__.py",
"diff": "# -*- coding: utf-8 -*-\n# Author: caphm\n-# Package: playback_controlling\n+# Package: playback\n# Created on: 08.02.2018\n# License: MIT https://goo.gl/5bMj3H\n# pylint: disable=import-error\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/playback_controlling/bookmarks.py",
"new_path": "resources/lib/playback/bookmarks.py",
"diff": "\"\"\"Save bookmarks for library items and mark them as watched\"\"\"\n-from resources.lib.playback_controlling import PlaybackActionManager, json_rpc\n+from resources.lib.playback import PlaybackActionManager, json_rpc\nOFFSET_WATCHED_TO_END = 'watchedToEndOffset'\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/playback_controlling/section_skipping.py",
"new_path": "resources/lib/playback/section_skipping.py",
"diff": "import xbmc\nimport xbmcgui\n-from resources.lib.playback_controlling import PlaybackActionManager\n-from resources.lib.kodi import show_modal_dialog\n-from resources.lib.kodi.skip import Skip\n-\n+import resources.lib.ui as ui\n+from resources.lib.playback import PlaybackActionManager\nSKIPPABLE_SECTIONS = {'credit': 30076, 'recap': 30077}\nOFFSET_CREDITS = 'creditsOffset'\n@@ -77,7 +75,7 @@ class SectionSkipper(PlaybackActionManager):\nself.markers[section]['start'])\nseconds = dialog_duration % 60\nminutes = (dialog_duration - seconds) / 60\n- show_modal_dialog(Skip,\n+ ui.show_modal_dialog(ui.xmldialogs.Skip,\n\"plugin-video-netflix-Skip.xml\",\nself.addon.getAddonInfo('path'),\nminutes=minutes,\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/playback_controlling/stream_continuity.py",
"new_path": "resources/lib/playback/stream_continuity.py",
"diff": "@@ -11,9 +11,8 @@ episodes of a tv show\n\"\"\"\nimport xbmc\n-from resources.lib.playback_controlling import PlaybackActionManager\n-from resources.lib.kodi import show_modal_dialog\n-from resources.lib.kodi.save_stream_settings import SaveStreamSettings\n+import resources.lib.ui as ui\n+from resources.lib.playback import PlaybackActionManager\nSTREAMS = {\n'audio': {\n@@ -91,7 +90,7 @@ class StreamContinuityManager(PlaybackActionManager):\nself.log('Asking to save {} stream #{}'.format(stype, index))\nstream_settings = self.storage.get(self.current_show, {})\nstream_settings[stype] = index\n- show_modal_dialog(SaveStreamSettings,\n+ ui.show_modal_dialog(ui.xmldialogs.SaveStreamSettings,\n\"plugin-video-netflix-SaveStreamSettings.xml\",\nself.addon.getAddonInfo('path'),\nminutes=0,\n"
},
{
"change_type": "RENAME",
"old_path": "resources/lib/kodi/Dialogs.py",
"new_path": "resources/lib/ui/Dialogs.py",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "resources/lib/kodi/__init__.py",
"new_path": "resources/lib/ui/__init__.py",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "resources/lib/kodi/save_stream_settings.py",
"new_path": "resources/lib/ui/xmldialogs.py",
"diff": "@@ -4,23 +4,47 @@ from platform import machine\nimport xbmcgui\n-\nACTION_PLAYER_STOP = 13\nOS_MACHINE = machine()\n+class XMLDialog(xbmcgui.WindowXMLDialog):\n+ def __init__(self, *args, **kwargs):\n+ if OS_MACHINE[0:5] == 'armv7':\n+ xbmcgui.WindowXMLDialog.__init__(self)\n+ else:\n+ xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\n+\n+\n+class Skip(XMLDialog):\n+ \"\"\"\n+ Dialog for skipping video parts (intro, recap, ...)\n+ \"\"\"\n+ def __init__(self, *args, **kwargs):\n+ super(Skip, self).__init__(*args, **kwargs)\n+ self.skip_to = kwargs['skip_to']\n+ self.label = kwargs['label']\n+\n+ def onInit(self):\n+ self.action_exitkeys_id = [10, 13]\n+ self.getControl(6012).setLabel(self.label)\n+\n+ def onClick(self, controlID):\n+ if controlID == 6012:\n+ import xbmc\n+ xbmc.Player().seekTime(self.skip_to)\n+ self.close()\n+\n+\nclass SaveStreamSettings(xbmcgui.WindowXMLDialog):\n\"\"\"\nDialog for skipping video parts (intro, recap, ...)\n\"\"\"\ndef __init__(self, *args, **kwargs):\n+ super(SaveStreamSettings, self).__init__(*args, **kwargs)\nself.stream_settings = kwargs['stream_settings']\nself.tvshowid = kwargs['tvshowid']\nself.storage = kwargs['storage']\n- if OS_MACHINE[0:5] == 'armv7':\n- xbmcgui.WindowXMLDialog.__init__(self)\n- else:\n- xbmcgui.WindowXMLDialog.__init__(self, *args, **kwargs)\ndef onInit(self):\nself.action_exitkeys_id = [10, 13]\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/test/test_KodiHelper_Dialogs.py",
"new_path": "resources/test/test_KodiHelper_Dialogs.py",
"diff": "import unittest\nimport mock\nfrom resources.lib.KodiHelper import KodiHelper\n-from resources.lib.kodi.Dialogs import Dialogs\n+from resources.lib.ui.Dialogs import Dialogs\nclass KodiHelperDialogsTestCase(unittest.TestCase):\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Clean up package structure |
105,989 | 08.08.2018 17:21:57 | -7,200 | d01c7835bda635f84e9ca168514772f5746770f3 | Fix login problems | [
{
"change_type": "MODIFY",
"old_path": "resources/lib/NetflixSession.py",
"new_path": "resources/lib/NetflixSession.py",
"diff": "@@ -302,13 +302,13 @@ class NetflixSession(object):\nuser_data, profiles = self.extract_inline_netflix_page_data(\ncontent=page.content)\nlogin_payload = {\n- 'email': account.get('email'),\n+ 'userLoginId': account.get('email'),\n'password': account.get('password'),\n'rememberMe': 'true',\n'flow': 'websiteSignUp',\n'mode': 'login',\n'action': 'loginAction',\n- 'withFields': 'email,password,rememberMe,nextPage,showPassword',\n+ 'withFields': 'rememberMe,nextPage,userLoginId,password',\n'authURL': user_data.get('authURL'),\n'nextPage': '',\n'showPassword': ''\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | Fix login problems |
105,992 | 09.08.2018 17:21:13 | -7,200 | 097cff8c3856b9450560b6c38d149d9e29c996c4 | check regular for ESN changes | [
{
"change_type": "MODIFY",
"old_path": "service.py",
"new_path": "service.py",
"diff": "@@ -102,9 +102,6 @@ class NetflixService(object):\nself.ns_thread = threading.Thread(\ntarget=self.ns_server.serve_forever)\n- if self.ns_server.esn_changed():\n- self.msl_server.reset_msl_data()\n-\ndef _start_servers(self):\nself.msl_server.server_activate()\nself.msl_server.timeout = 1\n@@ -171,6 +168,8 @@ class NetflixService(object):\nmonitor = KodiMonitor(self.nx_common, self.nx_common.log)\nwhile not monitor.abortRequested():\nmonitor.update_playback_progress()\n+ if self.ns_server.esn_changed():\n+ self.msl_server.reset_msl_data()\ntry:\nif self.library_update_scheduled() and self._is_idle():\nself.update_library()\n"
}
] | Python | MIT License | castagnait/plugin.video.netflix | check regular for ESN changes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.