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