mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Remove some generic exceptions
This commit is contained in:
parent
bf372791ab
commit
803081f65a
12 changed files with 43 additions and 33 deletions
|
@ -11,7 +11,7 @@ from dialogs import ServerConnect, UsersConnect, LoginManual, ServerManual
|
|||
from helper import settings, addon_id, event, api, window
|
||||
from jellyfin import Jellyfin
|
||||
from jellyfin.connection_manager import CONNECTION_STATE
|
||||
from jellyfin.exceptions import HTTPException
|
||||
from helper.exceptions import HTTPException
|
||||
from helper import LazyLogger
|
||||
|
||||
##################################################################################################
|
||||
|
|
|
@ -14,7 +14,7 @@ import requests
|
|||
from helper import settings, stop, event, window, create_id
|
||||
from jellyfin import Jellyfin
|
||||
from jellyfin import api
|
||||
from jellyfin.exceptions import HTTPException
|
||||
from helper.exceptions import HTTPException
|
||||
from helper import LazyLogger
|
||||
|
||||
#################################################################################################
|
||||
|
|
|
@ -12,9 +12,10 @@ import downloader as server
|
|||
import helper.xmls as xmls
|
||||
from objects import Movies, TVShows, MusicVideos, Music
|
||||
from database import Database, get_sync, save_sync, jellyfin_db
|
||||
from helper import translate, settings, window, progress, dialog, LibraryException
|
||||
from helper import translate, settings, window, progress, dialog
|
||||
from helper.utils import get_screensaver, set_screensaver
|
||||
from helper import LazyLogger
|
||||
from helper.exceptions import LibraryException, PathValidationException
|
||||
|
||||
##################################################################################################
|
||||
|
||||
|
@ -239,14 +240,16 @@ class FullSync(object):
|
|||
|
||||
raise
|
||||
|
||||
except PathValidationException:
|
||||
raise
|
||||
|
||||
except Exception as error:
|
||||
dialog("ok", "{jellyfin}", translate(33119))
|
||||
|
||||
LOG.error("full sync exited unexpectedly")
|
||||
LOG.exception(error)
|
||||
|
||||
if 'Failed to validate path' not in error:
|
||||
|
||||
dialog("ok", "{jellyfin}", translate(33119))
|
||||
LOG.error("full sync exited unexpectedly")
|
||||
save_sync(self.sync)
|
||||
save_sync(self.sync)
|
||||
|
||||
raise
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
from .lazylogger import LazyLogger
|
||||
|
||||
from .translate import translate
|
||||
from .exceptions import LibraryException
|
||||
|
||||
from .utils import addon_id
|
||||
from .utils import window
|
||||
|
|
|
@ -4,7 +4,19 @@ from __future__ import division, absolute_import, print_function, unicode_litera
|
|||
#################################################################################################
|
||||
|
||||
|
||||
class HTTPException(Exception):
|
||||
# Jellyfin HTTP exception
|
||||
def __init__(self, status, message):
|
||||
self.status = status
|
||||
self.message = message
|
||||
|
||||
|
||||
class LibraryException(Exception):
|
||||
# Jellyfin library sync exception
|
||||
def __init__(self, status):
|
||||
self.status = status
|
||||
|
||||
|
||||
class PathValidationException(Exception):
|
||||
# raise Exception("Failed to validate path. User stopped.")
|
||||
pass
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
class HTTPException(Exception):
|
||||
# Jellyfin HTTP exception
|
||||
def __init__(self, status, message):
|
||||
self.status = status
|
||||
self.message = message
|
|
@ -10,8 +10,7 @@ from six import string_types, ensure_str
|
|||
|
||||
from helper.utils import JsonDebugPrinter
|
||||
from helper import LazyLogger
|
||||
|
||||
from .exceptions import HTTPException
|
||||
from helper.exceptions import HTTPException
|
||||
|
||||
#################################################################################################
|
||||
|
||||
|
|
|
@ -15,8 +15,9 @@ from database import Database, jellyfin_db, get_sync, save_sync
|
|||
from full_sync import FullSync
|
||||
from views import Views
|
||||
from downloader import GetItemWorker
|
||||
from helper import translate, api, stop, settings, window, dialog, event, LibraryException
|
||||
from helper import translate, api, stop, settings, window, dialog, event
|
||||
from helper.utils import split_list, set_screensaver, get_screensaver
|
||||
from helper.exceptions import LibraryException
|
||||
from jellyfin import Jellyfin
|
||||
from helper import LazyLogger
|
||||
|
||||
|
@ -395,14 +396,14 @@ class Library(threading.Thread):
|
|||
try:
|
||||
# Get list of updates from server for synced library types and populate work queues
|
||||
result = self.server.jellyfin.get_sync_queue(last_sync, ",".join([ x for x in query_filter ]))
|
||||
|
||||
|
||||
if result is None:
|
||||
return True
|
||||
|
||||
|
||||
updated = []
|
||||
userdata = []
|
||||
removed = []
|
||||
|
||||
|
||||
updated.extend(result['ItemsAdded'])
|
||||
updated.extend(result['ItemsUpdated'])
|
||||
userdata.extend(result['UserDataChanged'])
|
||||
|
|
|
@ -10,6 +10,7 @@ import downloader as server
|
|||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, validate_bluray_dir, validate_dvd_dir, jellyfin_item, library_check, values, Local
|
||||
from helper import LazyLogger
|
||||
from helper.exceptions import PathValidationException
|
||||
|
||||
from .obj import Objects
|
||||
from .kodi import Movies as KodiDb, queries as QU
|
||||
|
@ -173,7 +174,7 @@ class Movies(KodiDb):
|
|||
if self.direct_path:
|
||||
|
||||
if not validate(obj['Path']):
|
||||
raise Exception("Failed to validate path. User stopped.")
|
||||
raise PathValidationException("Failed to validate path. User stopped.")
|
||||
|
||||
obj['Path'] = obj['Path'].replace(obj['Filename'], "")
|
||||
|
||||
|
|
|
@ -8,9 +8,11 @@ import datetime
|
|||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, jellyfin_item, values, library_check, Local
|
||||
from helper import LazyLogger
|
||||
from helper.exceptions import PathValidationException
|
||||
|
||||
from .obj import Objects
|
||||
from .kodi import Music as KodiDb, queries_music as QU
|
||||
|
||||
##################################################################################################
|
||||
|
||||
LOG = LazyLogger(__name__)
|
||||
|
@ -325,7 +327,7 @@ class Music(KodiDb):
|
|||
if self.direct_path:
|
||||
|
||||
if not validate(obj['Path']):
|
||||
raise Exception("Failed to validate path. User stopped.")
|
||||
raise PathValidationException("Failed to validate path. User stopped.")
|
||||
|
||||
obj['Path'] = obj['Path'].replace(obj['Filename'], "")
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ from kodi_six.utils import py2_encode
|
|||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, library_check, jellyfin_item, values, Local
|
||||
from helper import LazyLogger
|
||||
from helper.exceptions import PathValidationException
|
||||
|
||||
from .obj import Objects
|
||||
from .kodi import MusicVideos as KodiDb, queries as QU
|
||||
|
@ -162,7 +163,7 @@ class MusicVideos(KodiDb):
|
|||
if self.direct_path:
|
||||
|
||||
if not validate(obj['Path']):
|
||||
raise Exception("Failed to validate path. User stopped.")
|
||||
raise PathValidationException("Failed to validate path. User stopped.")
|
||||
|
||||
obj['Path'] = obj['Path'].replace(obj['Filename'], "")
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import downloader as server
|
|||
from database import jellyfin_db, queries as QUEM
|
||||
from helper import api, stop, validate, jellyfin_item, library_check, values, Local
|
||||
from helper import LazyLogger
|
||||
from helper.exceptions import PathValidationException
|
||||
|
||||
from .obj import Objects
|
||||
from .kodi import TVShows as KodiDb, queries as QU
|
||||
|
@ -195,7 +196,7 @@ class TVShows(KodiDb):
|
|||
obj['TopLevel'] = "plugin://plugin.video.jellyfin/"
|
||||
|
||||
if not validate(obj['Path']):
|
||||
raise Exception("Failed to validate path. User stopped.")
|
||||
raise PathValidationException("Failed to validate path. User stopped.")
|
||||
else:
|
||||
obj['TopLevel'] = "plugin://plugin.video.jellyfin/%s/" % obj['LibraryId']
|
||||
obj['Path'] = "%s%s/" % (obj['TopLevel'], obj['Id'])
|
||||
|
@ -218,8 +219,9 @@ class TVShows(KodiDb):
|
|||
|
||||
try:
|
||||
obj['ShowId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_series_obj))[0]
|
||||
except (KeyError, TypeError):
|
||||
except (KeyError, TypeError) as error:
|
||||
LOG.error("Unable to add series %s", obj['SeriesId'])
|
||||
LOG.exception(error)
|
||||
|
||||
return False
|
||||
|
||||
|
@ -390,7 +392,7 @@ class TVShows(KodiDb):
|
|||
if self.direct_path:
|
||||
|
||||
if not validate(obj['Path']):
|
||||
raise Exception("Failed to validate path. User stopped.")
|
||||
raise PathValidationException("Failed to validate path. User stopped.")
|
||||
|
||||
obj['Path'] = obj['Path'].replace(obj['Filename'], "")
|
||||
else:
|
||||
|
@ -411,8 +413,9 @@ class TVShows(KodiDb):
|
|||
try:
|
||||
self.tvshow(self.server.jellyfin.get_item(obj['SeriesId']), library=None)
|
||||
obj['ShowId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_series_obj))[0]
|
||||
except (TypeError, KeyError):
|
||||
except (TypeError, KeyError) as error:
|
||||
LOG.error("Unable to add series %s", obj['SeriesId'])
|
||||
LOG.exception(error)
|
||||
|
||||
return False
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue