# Path: resources/lib/storage.py
# class PersistentStorage(LoggingComponent):
#     """
#     Key-Value storage with a backing file on disk.
#     Reads entire dict structure into memory on first access and updates
#     the backing file with each changed entry.
# 
#     IMPORTANT: Changes to mutable objects inserted into the key-value-store
#     are not automatically written to disk. You need to call commit() to
#     persist these changes.
#     """
#     def __init__(self, storage_id, nx_common):
#         LoggingComponent.__init__(self, nx_common)
#         self.storage_id = storage_id
#         self.backing_file = os.path.join(nx_common.data_path,
#                                          self.storage_id + '.ndb')
#         self._contents = {}
#         self._dirty = True
#         self.log('Instantiated {}'.format(self.storage_id))
# 
#     def __getitem__(self, key):
#         self.log('Getting {}'.format(key))
#         return self.contents[key]
# 
#     def __setitem__(self, key, value):
#         self.log('Setting {} to {}'.format(key, value))
#         self._contents[key] = value
#         self.commit()
#         self._dirty = True
# 
#     @property
#     def contents(self):
#         """
#         The contents of the storage file
#         """
#         if self._dirty:
#             self._load_from_disk()
#         return self._contents
# 
#     def get(self, key, default=None):
#         """
#         Return the value associated with key. If key does not exist,
#         return default (defaults to None)
#         """
#         return self.contents.get(key, default)
# 
#     def commit(self):
#         """
#         Write current contents to disk
#         """
#         f = xbmcvfs.File(self.backing_file, 'wb')
#         f.write(bytearray(pickle.dumps(self._contents, protocol=2)))
#         f.close()
#         self.log('Committed changes to backing file')
# 
#     def clear(self):
#         """
#         Clear contents and backing file
#         """
#         self._contents = {}
#         self.commit()
# 
#     def _load_from_disk(self):
#         self.log('Trying to load contents from disk')
#         if xbmcvfs.exists(self.backing_file):
#             f = xbmcvfs.File(self.backing_file, 'rb')
#             self._contents = pickle.loads(f.read())
#             self._dirty = False
#             f.close()
#             self.log('Loaded contents from backing file ({})'.format(self._contents))
#         else:
#             self.log('Backing file does not exist')
# 
# Path: resources/lib/compat.py



import xbmc
import xbmcvfs
import json
from xbmcaddon import Addon
from resources.lib.storage import PersistentStorage
from resources.lib.compat import compat_unicode
        from resources.lib.NetflixCredentials import NetflixCredentials
        from resources.lib.NetflixCredentials import NetflixCredentials
        """Adds a log entry to the Kodi log

        Parameters
        ----------
        msg : :obj:`str`
            Entry that should be turned into a list item

        level : :obj:`int`
            Kodi log level
        """
        if isinstance(msg, str):
            msg = msg.encode('utf-8')
        xbmc.log('[%s] %s' % (self.plugin, msg.__str__()), level)

    @staticmethod
    def check_folder_path(path):
        """
        Check if folderpath ends with path delimator
        If not correct it (makes sure xbmcvfs.exists is working correct)
        """
        if isinstance(path, compat_unicode):
            check = path.encode('ascii', 'ignore')
            if b'/' in check and not str(check).endswith('/'):
                end = u'/'
                path = path + end
                return path
            if b'\\' in check and not str(check).endswith('\\'):
                end = u'\\'
                path = path + end
                return path

# Path: resources/lib/storage.py
# class PersistentStorage(LoggingComponent):
#     """
#     Key-Value storage with a backing file on disk.
#     Reads entire dict structure into memory on first access and updates
#     the backing file with each changed entry.
# 
#     IMPORTANT: Changes to mutable objects inserted into the key-value-store
#     are not automatically written to disk. You need to call commit() to
#     persist these changes.
#     """
#     def __init__(self, storage_id, nx_common):
#         LoggingComponent.__init__(self, nx_common)
#         self.storage_id = storage_id
#         self.backing_file = os.path.join(nx_common.data_path,
#                                          self.storage_id + '.ndb')
#         self._contents = {}
#         self._dirty = True
#         self.log('Instantiated {}'.format(self.storage_id))
# 
#     def __getitem__(self, key):
#         self.log('Getting {}'.format(key))
#         return self.contents[key]
# 
#     def __setitem__(self, key, value):
#         self.log('Setting {} to {}'.format(key, value))
#         self._contents[key] = value
#         self.commit()
#         self._dirty = True
# 
#     @property
#     def contents(self):
#         """
#         The contents of the storage file
#         """
#         if self._dirty:
#             self._load_from_disk()
#         return self._contents
# 
#     def get(self, key, default=None):
#         """
#         Return the value associated with key. If key does not exist,
#         return default (defaults to None)
#         """
#         return self.contents.get(key, default)
# 
#     def commit(self):
#         """
#         Write current contents to disk
#         """
#         f = xbmcvfs.File(self.backing_file, 'wb')
#         f.write(bytearray(pickle.dumps(self._contents, protocol=2)))
#         f.close()
#         self.log('Committed changes to backing file')
# 
#     def clear(self):
#         """
#         Clear contents and backing file
#         """
#         self._contents = {}
#         self.commit()
# 
#     def _load_from_disk(self):
#         self.log('Trying to load contents from disk')
#         if xbmcvfs.exists(self.backing_file):
#             f = xbmcvfs.File(self.backing_file, 'rb')
#             self._contents = pickle.loads(f.read())
#             self._dirty = False
#             f.close()
#             self.log('Loaded contents from backing file ({})'.format(self._contents))
#         else:
#             self.log('Backing file does not exist')
# 
# Path: resources/lib/compat.py



# Path: resources/lib/NetflixCommon.py
import xbmc
import xbmcvfs
import json
from xbmcaddon import Addon
from resources.lib.storage import PersistentStorage
from resources.lib.compat import compat_unicode
        from resources.lib.NetflixCredentials import NetflixCredentials
        from resources.lib.NetflixCredentials import NetflixCredentials

        """Adds a log entry to the Kodi log

        Parameters
        ----------
        msg : :obj:`str`
            Entry that should be turned into a list item

        level : :obj:`int`
            Kodi log level
        """
        if isinstance(msg, str):
            msg = msg.encode('utf-8')
        xbmc.log('[%s] %s' % (self.plugin, msg.__str__()), level)

    @staticmethod
    def check_folder_path(path):
        """
        Check if folderpath ends with path delimator
        If not correct it (makes sure xbmcvfs.exists is working correct)
        """
        if isinstance(path, compat_unicode):
            check = path.encode('ascii', 'ignore')
            if b'/' in check and not str(check).endswith('/'):
                end = u'/'
                path = path + end
                return path
            if b'\\' in check and not str(check).endswith('\\'):
                end = u'\\'
                path = path + end
                return path

        if '/' in path and not compat_unicode(path).endswith('/'):