mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
Adjust sleep behavior
This commit is contained in:
parent
f9e26e1c23
commit
dcd594cdb5
4 changed files with 21 additions and 14 deletions
|
@ -68,7 +68,7 @@ class Events(object):
|
|||
|
||||
elif mode =='play':
|
||||
|
||||
item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get()
|
||||
item = TheVoid('GetItem', {'Id': params['id'], 'ServerId': server}).get(10, {'Items': {}})
|
||||
Actions(server).play(item, params.get('dbid'), playlist=params.get('playlist') == 'true')
|
||||
|
||||
elif mode == 'playlist':
|
||||
|
@ -271,7 +271,7 @@ def browse(media, view_id=None, folder=None, server_id=None):
|
|||
elif (folder or "").startswith('firstletter-'):
|
||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'NameStartsWith': folder.split('-')[1]}}).get()
|
||||
elif (folder or "").startswith('genres-'):
|
||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'GenreIds': folder.split('genres-')[1]}}).get()
|
||||
listing = TheVoid('Browse', {'Id': view_id, 'ServerId': server_id, 'Media': get_media_type(content_type), 'Params': {'GenreIds': folder.split('-')[1]}}).get()
|
||||
elif folder == 'favepisodes':
|
||||
listing = TheVoid('Browse', {'Media': get_media_type(content_type), 'ServerId': server_id, 'Limit': 25, 'Filters': ['IsFavorite']}).get()
|
||||
elif media == 'homevideos':
|
||||
|
|
|
@ -102,6 +102,7 @@ class Service(xbmc.Monitor):
|
|||
difference = datetime.today() - self.settings['last_progress']
|
||||
|
||||
if difference.seconds > 10:
|
||||
|
||||
update = difference.seconds > 250
|
||||
event('ReportProgressRequested', {'Report': update})
|
||||
|
||||
|
@ -247,7 +248,7 @@ class Service(xbmc.Monitor):
|
|||
|
||||
self.stop_default()
|
||||
|
||||
if self.waitForAbort(10):
|
||||
if self.waitForAbort(15):
|
||||
return
|
||||
|
||||
self.start_default()
|
||||
|
@ -324,7 +325,9 @@ class Service(xbmc.Monitor):
|
|||
xbmc.executebuiltin("Container.Refresh")
|
||||
|
||||
elif method == 'System.OnSleep':
|
||||
|
||||
LOG.info("-->[ sleep ]")
|
||||
window('emby_should_stop.bool', True)
|
||||
|
||||
if self.library_thread is not None:
|
||||
|
||||
|
@ -332,11 +335,15 @@ class Service(xbmc.Monitor):
|
|||
self.library_thread = None
|
||||
|
||||
Emby.close_all()
|
||||
self.monitor.server = []
|
||||
self.monitor.sleep = True
|
||||
|
||||
elif method == 'System.OnWake':
|
||||
|
||||
LOG.info("--<[ sleep ]")
|
||||
xbmc.sleep(10000)# Allow network to wake up
|
||||
self.monitor.sleep = False
|
||||
window('emby_should_stop', clear=True)
|
||||
|
||||
try:
|
||||
self.connect.register()
|
||||
|
|
|
@ -28,6 +28,7 @@ LOG = logging.getLogger("EMBY."+__name__)
|
|||
class Monitor(xbmc.Monitor):
|
||||
|
||||
servers = []
|
||||
sleep = False
|
||||
|
||||
def __init__(self):
|
||||
|
||||
|
@ -61,15 +62,20 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
data = json.loads(data)[0]
|
||||
else:
|
||||
if method not in ('Player.OnPlay', 'VideoLibrary.OnUpdate', 'System.OnSleep', 'Player.OnAVChange'):
|
||||
if method not in ('Player.OnPlay', 'VideoLibrary.OnUpdate', 'Player.OnAVChange'):
|
||||
return
|
||||
|
||||
data = json.loads(data)
|
||||
|
||||
LOG.info("[ %s: %s ] %s", sender, method, json.dumps(data, indent=4))
|
||||
LOG.debug("[ %s: %s ] %s", sender, method, json.dumps(data, indent=4))
|
||||
|
||||
if self.sleep:
|
||||
LOG.info("System.OnSleep detected, ignore monitor request.")
|
||||
|
||||
return
|
||||
|
||||
try:
|
||||
if method != 'LoadServer' and data.get('ServerId') and data['ServerId'] not in self.servers:
|
||||
if method != 'LoadServer' and data['ServerId'] not in self.servers:
|
||||
|
||||
try:
|
||||
connect.Connect().register(data['ServerId'])
|
||||
|
@ -81,10 +87,8 @@ class Monitor(xbmc.Monitor):
|
|||
|
||||
return
|
||||
|
||||
server = Emby(data.get('ServerId'))
|
||||
except Exception as error:
|
||||
|
||||
LOG.error(error)
|
||||
server = Emby(data['ServerId'])
|
||||
except Exception:
|
||||
server = Emby()
|
||||
|
||||
if method == 'GetItem':
|
||||
|
@ -230,9 +234,6 @@ class Monitor(xbmc.Monitor):
|
|||
server['api'].session_add_user(server['config/app.session'], data['Id'], data['Add'])
|
||||
self.additional_users(server)
|
||||
|
||||
elif method == 'System.OnSleep':
|
||||
self.servers = []
|
||||
|
||||
elif method == 'Player.OnPlay':
|
||||
on_play(data, server)
|
||||
|
||||
|
|
|
@ -835,7 +835,6 @@ class Views(object):
|
|||
if self.server['connected']:
|
||||
|
||||
if self.media_folders is None:
|
||||
|
||||
self.media_folders = self.get_libraries()
|
||||
|
||||
for library in self.media_folders:
|
||||
|
|
Loading…
Reference in a new issue