Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greatly increase the amount of logging information. #38

Merged
merged 6 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# With more recent updates Visual Studio 2017 supports EditorConfig files out of the box
# Visual Studio Code needs an extension: https://github.com/editorconfig/editorconfig-vscode
# For emacs, vim, np++ and other editors, see here: https://github.com/editorconfig
###############################
# Core EditorConfig Options #
###############################
root = true

# All files
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = null

# YAML indentation
[*.{yml,yaml}]
indent_size = 2

# XML indentation
[*.xml]
indent_size = 2
21 changes: 11 additions & 10 deletions resources/lib/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _get_database(self, path, silent=False):
return path

def _discover_database(self, database):

''' Use UpdateLibrary(video) to update the date modified
on the database file used by Kodi.
'''
Expand Down Expand Up @@ -138,6 +138,7 @@ def _sql(self, file):
try:
loaded = self._get_database(databases[file]) if file in databases else file
except Exception as error:
LOG.exception(error)

for i in range(1, 10):
alt_file = "%s-%s" % (file, i)
Expand All @@ -150,8 +151,8 @@ def _sql(self, file):
loaded = None

break
except Exception:
pass
except Exception as error:
LOG.exception(error)

if discovered and discovered != loaded:

Expand Down Expand Up @@ -200,7 +201,7 @@ def jellyfin_tables(cursor):

columns = cursor.execute("SELECT * FROM jellyfin")
if 'jellyfin_parent_id' not in [description[0] for description in columns.description]:

LOG.info("Add missing column jellyfin_parent_id")
cursor.execute("ALTER TABLE jellyfin ADD COLUMN jellyfin_parent_id 'TEXT'")

Expand Down Expand Up @@ -281,7 +282,7 @@ def reset_kodi():
LOG.warn("[ reset kodi ]")

def reset_jellyfin():

with Database('jellyfin') as jellyfindb:
jellyfindb.cursor.execute("SELECT tbl_name FROM sqlite_master WHERE type='table'")

Expand Down Expand Up @@ -327,7 +328,7 @@ def reset_artwork():
def get_sync():

path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')

if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)

Expand All @@ -347,7 +348,7 @@ def get_sync():
def save_sync(sync):

path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')

if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)

Expand All @@ -359,7 +360,7 @@ def save_sync(sync):
def get_credentials():

path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')

if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)

Expand All @@ -372,7 +373,7 @@ def get_credentials():
with open(os.path.join(path, 'data.txt')) as infile:
credentials = json.load(infile)
save_credentials(credentials)

xbmcvfs.delete(os.path.join(path, 'data.txt'))
except Exception:
credentials = {}
Expand All @@ -384,7 +385,7 @@ def get_credentials():
def save_credentials(credentials):
credentials = credentials or {}
path = xbmc.translatePath("special://profile/addon_data/plugin.video.jellyfin/").decode('utf-8')

if not xbmcvfs.exists(path):
xbmcvfs.mkdirs(path)

Expand Down
10 changes: 4 additions & 6 deletions resources/lib/database/jellyfin_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

class JellyfinDatabase():


def __init__(self, cursor):
self.cursor = cursor

Expand All @@ -31,7 +30,7 @@ def update_reference(self, *args):
self.cursor.execute(QU.update_reference, args)

def update_parent_id(self, *args):

''' Parent_id is the parent Kodi id.
'''
self.cursor.execute(QU.update_parent, args)
Expand Down Expand Up @@ -62,7 +61,7 @@ def get_checksum(self, *args):
return self.cursor.fetchall()

def get_item_by_kodi_id(self, *args):

try:
self.cursor.execute(QU.get_item_by_kodi, args)

Expand Down Expand Up @@ -105,14 +104,14 @@ def remove_item_by_kodi_id(self, *args):
def remove_wild_item(self, item_id):
self.cursor.execute(QU.delete_item_by_wild, (item_id + "%",))


def get_view_name(self, item_id):

try:
self.cursor.execute(QU.get_view_name, (item_id,))

return self.cursor.fetchone()[0]
except Exception as error:
LOG.exception(error)
return

def get_view(self, *args):
Expand Down Expand Up @@ -159,7 +158,6 @@ def get_version(self, version=None):
self.cursor.execute(QU.get_version)
version = self.cursor.fetchone()[0]
except Exception as error:
pass
LOG.exception(error)

return version

21 changes: 10 additions & 11 deletions resources/lib/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def browse_info():

def _http(action, url, request={}, server_id=None):
request.update({'url': url, 'type': action})

return Jellyfin(server_id)['http/request'](request)


Expand All @@ -73,7 +73,8 @@ def validate_view(library_id, item_id):
'Recursive': True,
'Ids': item_id
})
except Exception:
except Exception as error:
LOG.exception(error)
return False

return True if len(result['Items']) else False
Expand Down Expand Up @@ -135,8 +136,8 @@ def get_episode_by_show(show_id):
query = {
'url': "Shows/%s/Episodes" % show_id,
'params': {
'EnableUserData': True,
'EnableImages': True,
'EnableUserData': True,
'EnableImages': True,
'UserId': "{UserId}",
'Fields': api.info()
}
Expand All @@ -151,8 +152,8 @@ def get_episode_by_season(show_id, season_id):
'url': "Shows/%s/Episodes" % show_id,
'params': {
'SeasonId': season_id,
'EnableUserData': True,
'EnableImages': True,
'EnableUserData': True,
'EnableImages': True,
'UserId': "{UserId}",
'Fields': api.info()
}
Expand Down Expand Up @@ -257,7 +258,7 @@ def _get_items(query, server_id=None):
items['TotalRecordCount'] = _get(url, test_params, server_id=server_id)['TotalRecordCount']

except Exception as error:
LOG.error("Failed to retrieve the server response %s: %s params:%s", url, error, params)
LOG.exception("Failed to retrieve the server response %s: %s params:%s", url, error, params)

else:
index = params.get('StartIndex', 0)
Expand All @@ -268,7 +269,7 @@ def _get_items(query, server_id=None):
params['StartIndex'] = index
params['Limit'] = LIMIT
result = _get(url, params, server_id=server_id) or {'Items': []}

items['Items'].extend(result['Items'])
items['RestorePoint'] = query
yield items
Expand Down Expand Up @@ -366,7 +367,7 @@ def get(self):

if window('jellyfin_should_stop.bool'):
LOG.info("Abandon mission! A black hole just swallowed [ %s/%s ]", self.method, self.data['VoidName'])

return

xbmc.sleep(100)
Expand Down Expand Up @@ -397,8 +398,6 @@ def get_objects(src, filename):

LOG.error(error)
response = requests.get(src, stream=True, verify=False)
except Exception:
raise

dl = xbmcvfs.File(path, 'w')
dl.write(response.content)
Expand Down
22 changes: 11 additions & 11 deletions resources/lib/entrypoint/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self):
try:
Views().get_nodes()
except Exception as error:
LOG.error(error)
LOG.exception(error)

window('jellyfin.connected.bool', True)
settings('groupedSets.bool', objects.utils.get_grouped_set())
Expand All @@ -87,7 +87,7 @@ def service(self):
''' Keeps the service monitor going.
Exit on Kodi shutdown or profile switch.

if profile switch happens more than once,
if profile switch happens more than once,
Threads depending on abortRequest will not trigger.
'''
self.monitor = monitor.Monitor()
Expand Down Expand Up @@ -137,7 +137,7 @@ def start_default(self):
self.connect.register()
setup.Setup()
except Exception as error:
LOG.error(error)
LOG.exception(error)

def stop_default(self):

Expand Down Expand Up @@ -230,7 +230,7 @@ def onNotification(self, sender, method, data):

if self.waitForAbort(120):
return

self.start_default()

elif method == 'Unauthorized':
Expand All @@ -243,21 +243,21 @@ def onNotification(self, sender, method, data):

if self.waitForAbort(5):
return

self.start_default()

elif method == 'ServerRestarting':
if data.get('ServerId'):
return

if settings('restartMsg.bool'):
dialog("notification", heading="{jellyfin}", message=_(33006), icon="{jellyfin}")

self.stop_default()

if self.waitForAbort(15):
return

self.start_default()

elif method == 'ServerConnect':
Expand Down Expand Up @@ -318,22 +318,22 @@ def onNotification(self, sender, method, data):

if not self.library_thread.remove_library(lib):
return

self.library_thread.add_library(data['Id'])
xbmc.executebuiltin("Container.Refresh")

elif method == 'RemoveLibrary':
libraries = data['Id'].split(',')

for lib in libraries:

if not self.library_thread.remove_library(lib):
return

xbmc.executebuiltin("Container.Refresh")

elif method == 'System.OnSleep':

LOG.info("-->[ sleep ]")
window('jellyfin_should_stop.bool', True)

Expand Down Expand Up @@ -361,7 +361,7 @@ def onNotification(self, sender, method, data):
try:
self.connect.register()
except Exception as error:
LOG.error(error)
LOG.exception(error)

elif method == 'GUI.OnScreensaverDeactivated':

Expand Down
13 changes: 7 additions & 6 deletions resources/lib/full_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FullSync(object):

def __init__(self, library, server):

''' You can call all big syncing methods here.
''' You can call all big syncing methods here.
Initial, update, repair, remove.
'''
self.__dict__ = self._shared_state
Expand Down Expand Up @@ -181,7 +181,7 @@ def select_libraries(self, libraries):


def start(self):

''' Main sync process.
'''
LOG.info("starting sync with %s", self.sync['Libraries'])
Expand Down Expand Up @@ -248,8 +248,9 @@ def process_library(self, library_id):
raise

except Exception as error:
LOG.exception(error)

if not 'Failed to validate path' in error:
if 'Failed to validate path' not in error:

dialog("ok", heading="{jellyfin}", line1=_(33119))
LOG.error("full sync exited unexpectedly")
Expand All @@ -271,7 +272,7 @@ def movies(self, library, dialog):
obj = Movies(self.server, jellyfindb, videodb, self.direct_path)

for items in server.get_items(library['Id'], "Movie", False, self.sync['RestorePoint'].get('params')):

self.sync['RestorePoint'] = items['RestorePoint']
start_index = items['RestorePoint']['params']['StartIndex']

Expand Down Expand Up @@ -413,7 +414,7 @@ def music(self, library, dialog):
obj.artist(artist, library=library)

for albums in server.get_albums_by_artist(artist['Id']):

for album in albums['Items']:
obj.album(album)

Expand Down Expand Up @@ -546,7 +547,7 @@ def remove_library(self, library_id, dialog):

if library_id in self.sync['Whitelist']:
self.sync['Whitelist'].remove(library_id)

elif 'Mixed:%s' % library_id in self.sync['Whitelist']:
self.sync['Whitelist'].remove('Mixed:%s' % library_id)

Expand Down
Loading