mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
commit
07723ad02b
9 changed files with 72 additions and 50 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.emby"
|
<addon id="plugin.video.emby"
|
||||||
name="Emby"
|
name="Emby"
|
||||||
version="4.0.0"
|
version="4.0.1"
|
||||||
provider-name="angelblue05">
|
provider-name="angelblue05">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.25.0"/>
|
<import addon="xbmc.python" version="2.25.0"/>
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
<news>
|
<news>
|
||||||
New stable release
|
New stable release
|
||||||
The wiki has been updated: https://github.com/MediaBrowser/plugin.video.emby/wiki
|
The wiki has been updated: https://github.com/MediaBrowser/plugin.video.emby/wiki
|
||||||
|
Small fixes
|
||||||
</news>
|
</news>
|
||||||
</extension>
|
</extension>
|
||||||
</addon>
|
</addon>
|
||||||
|
|
|
@ -40,11 +40,16 @@ def ensure_client():
|
||||||
|
|
||||||
class Emby(object):
|
class Emby(object):
|
||||||
|
|
||||||
''' This is your Embyclient, you can create more than one. The server_id is only a temporary thing.
|
''' This is your Embyclient, you can create more than one. The server_id is only a temporary thing
|
||||||
|
to communicate with the EmbyClient().
|
||||||
|
|
||||||
from emby import Emby
|
from emby import Emby
|
||||||
|
|
||||||
default_client = Emby()['config/app']
|
Emby('123456')['config/app']
|
||||||
another_client = Emby('123456')['config/app']
|
|
||||||
|
# Permanent client reference
|
||||||
|
client = Emby('123456').get_client()
|
||||||
|
client['config/app']
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Borg - multiple instances, shared state
|
# Borg - multiple instances, shared state
|
||||||
|
@ -57,6 +62,9 @@ class Emby(object):
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
self.server_id = server_id or "default"
|
self.server_id = server_id or "default"
|
||||||
|
|
||||||
|
def get_client(self):
|
||||||
|
return self.client[self.server_id]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def set_loghandler(cls, func=loghandler, level=logging.INFO):
|
def set_loghandler(cls, func=loghandler, level=logging.INFO):
|
||||||
|
|
||||||
|
|
|
@ -215,17 +215,17 @@ class HTTP(object):
|
||||||
def _authorization(self, data):
|
def _authorization(self, data):
|
||||||
|
|
||||||
auth = "MediaBrowser "
|
auth = "MediaBrowser "
|
||||||
auth += "Client=%s, " % self.config['app.name']
|
auth += "Client=%s, " % self.config['app.name'].encode('utf-8')
|
||||||
auth += "Device=%s, " % self.config['app.device_name']
|
auth += "Device=%s, " % self.config['app.device_name'].encode('utf-8')
|
||||||
auth += "DeviceId=%s, " % self.config['app.device_id']
|
auth += "DeviceId=%s, " % self.config['app.device_id'].encode('utf-8')
|
||||||
auth += "Version=%s" % self.config['app.version']
|
auth += "Version=%s" % self.config['app.version'].encode('utf-8')
|
||||||
|
|
||||||
data['headers'].update({'Authorization': auth})
|
data['headers'].update({'Authorization': auth})
|
||||||
|
|
||||||
if self.config['auth.token']:
|
if self.config['auth.token']:
|
||||||
|
|
||||||
auth += ', UserId=%s' % self.config['auth.user_id']
|
auth += ', UserId=%s' % self.config['auth.user_id'].encode('utf-8')
|
||||||
data['headers'].update({'Authorization': auth, 'X-MediaBrowser-Token': self.config['auth.token']})
|
data['headers'].update({'Authorization': auth, 'X-MediaBrowser-Token': self.config['auth.token'].encode('utf-8')})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -498,11 +498,11 @@ class Service(xbmc.Monitor):
|
||||||
window('emby_should_stop.bool', True)
|
window('emby_should_stop.bool', True)
|
||||||
|
|
||||||
properties = [ # TODO: review
|
properties = [ # TODO: review
|
||||||
"emby_state", "emby_serverStatus",
|
"emby_state", "emby_serverStatus", "emby_currUser",
|
||||||
"emby_syncRunning", "emby_currUser",
|
|
||||||
|
|
||||||
"emby_play", "emby_online", "emby.connected", "emby.resume", "emby_startup",
|
"emby_play", "emby_online", "emby.connected", "emby.resume", "emby_startup",
|
||||||
"emby.external", "emby.external_check", "emby_deviceId", "emby_db_check", "emby_pathverified"
|
"emby.external", "emby.external_check", "emby_deviceId", "emby_db_check", "emby_pathverified",
|
||||||
|
"emby_sync"
|
||||||
]
|
]
|
||||||
for prop in properties:
|
for prop in properties:
|
||||||
window(prop, clear=True)
|
window(prop, clear=True)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import downloader as server
|
||||||
import helper.xmls as xmls
|
import helper.xmls as xmls
|
||||||
from database import Database, get_sync, save_sync, emby_db
|
from database import Database, get_sync, save_sync, emby_db
|
||||||
from objects import Movies, TVShows, MusicVideos, Music
|
from objects import Movies, TVShows, MusicVideos, Music
|
||||||
from helper import _, settings, progress, dialog, LibraryException
|
from helper import _, settings, window, progress, dialog, LibraryException
|
||||||
from helper.utils import get_screensaver, set_screensaver
|
from helper.utils import get_screensaver, set_screensaver
|
||||||
from emby import Emby
|
from emby import Emby
|
||||||
|
|
||||||
|
@ -31,12 +31,20 @@ class FullSync(object):
|
||||||
_shared_state = {}
|
_shared_state = {}
|
||||||
sync = None
|
sync = None
|
||||||
running = False
|
running = False
|
||||||
|
screensaver = None
|
||||||
|
|
||||||
def __init__(self, library, library_id=None, update=False):
|
def __init__(self, library, library_id=None, update=False):
|
||||||
|
|
||||||
''' Map the syncing process and start the sync. Ensure only one sync is running.
|
''' Map the syncing process and start the sync. Ensure only one sync is running.
|
||||||
'''
|
'''
|
||||||
self.__dict__ = self._shared_state
|
self.__dict__ = self._shared_state
|
||||||
|
window('emby_sync.bool', True)
|
||||||
|
|
||||||
|
if not settings('dbSyncScreensaver.bool'):
|
||||||
|
|
||||||
|
xbmc.executebuiltin('InhibitIdleShutdown(true)')
|
||||||
|
self.screensaver = get_screensaver()
|
||||||
|
set_screensaver(value="")
|
||||||
|
|
||||||
if not self.running:
|
if not self.running:
|
||||||
|
|
||||||
|
@ -162,32 +170,15 @@ class FullSync(object):
|
||||||
save_sync(self.sync)
|
save_sync(self.sync)
|
||||||
start_time = datetime.datetime.now()
|
start_time = datetime.datetime.now()
|
||||||
|
|
||||||
if not settings('dbSyncScreensaver.bool'):
|
for library in list(self.sync['Libraries']):
|
||||||
|
|
||||||
xbmc.executebuiltin('InhibitIdleShutdown(true)')
|
self.process_library(library)
|
||||||
screensaver = get_screensaver()
|
|
||||||
set_screensaver(value="")
|
|
||||||
|
|
||||||
try:
|
if not library.startswith('Boxsets:') and library not in self.sync['Whitelist']:
|
||||||
for library in list(self.sync['Libraries']):
|
self.sync['Whitelist'].append(library)
|
||||||
|
|
||||||
self.process_library(library)
|
self.sync['Libraries'].pop(self.sync['Libraries'].index(library))
|
||||||
|
self.sync['RestorePoint'] = {}
|
||||||
if not library.startswith('Boxsets:') and library not in self.sync['Whitelist']:
|
|
||||||
self.sync['Whitelist'].append(library)
|
|
||||||
|
|
||||||
self.sync['Libraries'].pop(self.sync['Libraries'].index(library))
|
|
||||||
self.sync['RestorePoint'] = {}
|
|
||||||
except Exception as error:
|
|
||||||
|
|
||||||
if not settings('dbSyncScreensaver.bool'):
|
|
||||||
|
|
||||||
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
|
||||||
set_screensaver(value=screensaver)
|
|
||||||
|
|
||||||
self.running = False
|
|
||||||
|
|
||||||
raise
|
|
||||||
|
|
||||||
elapsed = datetime.datetime.now() - start_time
|
elapsed = datetime.datetime.now() - start_time
|
||||||
settings('SyncInstallRunDone.bool', True)
|
settings('SyncInstallRunDone.bool', True)
|
||||||
|
@ -198,7 +189,6 @@ class FullSync(object):
|
||||||
dialog("notification", heading="{emby}", message="%s %s" % (_(33025), str(elapsed).split('.')[0]),
|
dialog("notification", heading="{emby}", message="%s %s" % (_(33025), str(elapsed).split('.')[0]),
|
||||||
icon="{emby}", sound=False)
|
icon="{emby}", sound=False)
|
||||||
LOG.info("Full sync completed in: %s", str(elapsed).split('.')[0])
|
LOG.info("Full sync completed in: %s", str(elapsed).split('.')[0])
|
||||||
self.running = False
|
|
||||||
|
|
||||||
def process_library(self, library_id):
|
def process_library(self, library_id):
|
||||||
|
|
||||||
|
@ -249,6 +239,19 @@ class FullSync(object):
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
|
||||||
|
''' Exiting sync
|
||||||
|
'''
|
||||||
|
self.running = False
|
||||||
|
window('emby_sync', clear=True)
|
||||||
|
|
||||||
|
if not settings('dbSyncScreensaver.bool'):
|
||||||
|
|
||||||
|
xbmc.executebuiltin('InhibitIdleShutdown(false)')
|
||||||
|
set_screensaver(value=self.screensaver)
|
||||||
|
|
||||||
|
|
||||||
@progress()
|
@progress()
|
||||||
def movies(self, library, dialog):
|
def movies(self, library, dialog):
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ class Library(threading.Thread):
|
||||||
self.pending_refresh = False
|
self.pending_refresh = False
|
||||||
self.save_last_sync()
|
self.save_last_sync()
|
||||||
self.total_updates = 0
|
self.total_updates = 0
|
||||||
|
window('emby_sync', clear=True)
|
||||||
|
|
||||||
if self.progress_updates:
|
if self.progress_updates:
|
||||||
|
|
||||||
|
@ -196,6 +197,13 @@ class Library(threading.Thread):
|
||||||
def stop_client(self):
|
def stop_client(self):
|
||||||
self.stop_thread = True
|
self.stop_thread = True
|
||||||
|
|
||||||
|
def enable_pending_refresh(self):
|
||||||
|
|
||||||
|
''' When there's an active thread. Let the main thread know.
|
||||||
|
'''
|
||||||
|
self.pending_refresh = True
|
||||||
|
window('emby_sync.bool', True)
|
||||||
|
|
||||||
def worker_queue_size(self):
|
def worker_queue_size(self):
|
||||||
|
|
||||||
''' Get how many items are queued up for worker threads.
|
''' Get how many items are queued up for worker threads.
|
||||||
|
@ -251,7 +259,7 @@ class Library(threading.Thread):
|
||||||
new_thread.start()
|
new_thread.start()
|
||||||
LOG.info("-->[ q:updated/%s/%s ]", queues, id(new_thread))
|
LOG.info("-->[ q:updated/%s/%s ]", queues, id(new_thread))
|
||||||
self.writer_threads['updated'].append(new_thread)
|
self.writer_threads['updated'].append(new_thread)
|
||||||
self.pending_refresh = True
|
self.enable_pending_refresh()
|
||||||
|
|
||||||
def worker_userdata(self):
|
def worker_userdata(self):
|
||||||
|
|
||||||
|
@ -270,7 +278,7 @@ class Library(threading.Thread):
|
||||||
new_thread.start()
|
new_thread.start()
|
||||||
LOG.info("-->[ q:userdata/%s/%s ]", queues, id(new_thread))
|
LOG.info("-->[ q:userdata/%s/%s ]", queues, id(new_thread))
|
||||||
self.writer_threads['userdata'].append(new_thread)
|
self.writer_threads['userdata'].append(new_thread)
|
||||||
self.pending_refresh = True
|
self.enable_pending_refresh()
|
||||||
|
|
||||||
def worker_remove(self):
|
def worker_remove(self):
|
||||||
|
|
||||||
|
@ -289,7 +297,7 @@ class Library(threading.Thread):
|
||||||
new_thread.start()
|
new_thread.start()
|
||||||
LOG.info("-->[ q:removed/%s/%s ]", queues, id(new_thread))
|
LOG.info("-->[ q:removed/%s/%s ]", queues, id(new_thread))
|
||||||
self.writer_threads['removed'].append(new_thread)
|
self.writer_threads['removed'].append(new_thread)
|
||||||
self.pending_refresh = True
|
self.enable_pending_refresh()
|
||||||
|
|
||||||
def worker_notify(self):
|
def worker_notify(self):
|
||||||
|
|
||||||
|
@ -517,6 +525,7 @@ class Library(threading.Thread):
|
||||||
|
|
||||||
@progress(_(33144))
|
@progress(_(33144))
|
||||||
def remove_library(self, library_id, dialog):
|
def remove_library(self, library_id, dialog):
|
||||||
|
window('emby_sync.bool', True)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with Database('emby') as embydb:
|
with Database('emby') as embydb:
|
||||||
|
@ -572,10 +581,11 @@ class Library(threading.Thread):
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
|
||||||
LOG.exception(error)
|
LOG.exception(error)
|
||||||
dialog.close()
|
window('emby_sync', clear=True)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
window('emby_sync', clear=True)
|
||||||
Views().get_views()
|
Views().get_views()
|
||||||
Views().get_nodes()
|
Views().get_nodes()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version = "171076028"
|
version = "171076029"
|
||||||
|
|
||||||
from movies import Movies
|
from movies import Movies
|
||||||
from musicvideos import MusicVideos
|
from musicvideos import MusicVideos
|
||||||
|
|
|
@ -320,11 +320,11 @@ add_musicvideo = """ INSERT INTO musicvideo(idMVideo,idFile, c00, c04, c05,
|
||||||
add_musicvideo_obj = [ "{MvideoId}","{FileId}","{Title}","{Runtime}","{Directors}","{Studio}","{Year}",
|
add_musicvideo_obj = [ "{MvideoId}","{FileId}","{Title}","{Runtime}","{Directors}","{Studio}","{Year}",
|
||||||
"{Plot}","{Album}","{Artists}","{Genre}","{Index}","{Premiere}"
|
"{Plot}","{Album}","{Artists}","{Genre}","{Index}","{Premiere}"
|
||||||
]
|
]
|
||||||
add_tvshow = """ INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c12, c13, c14, c15)
|
add_tvshow = """ INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c10, c12, c13, c14, c15)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
"""
|
"""
|
||||||
add_tvshow_obj = [ "{ShowId}","{Title}","{Plot}","{Status}","{RatingId}","{Premiere}","{Genre}","{Title}",
|
add_tvshow_obj = [ "{ShowId}","{Title}","{Plot}","{Status}","{RatingId}","{Premiere}","{Genre}","{Title}",
|
||||||
"{Unique}","{Mpaa}","{Studio}","{SortTitle}"
|
"disintegrate browse bug", "{Unique}","{Mpaa}","{Studio}","{SortTitle}"
|
||||||
]
|
]
|
||||||
add_season = """ INSERT INTO seasons(idSeason, idShow, season)
|
add_season = """ INSERT INTO seasons(idSeason, idShow, season)
|
||||||
VALUES (?, ?, ?)
|
VALUES (?, ?, ?)
|
||||||
|
@ -446,12 +446,12 @@ update_musicvideo_obj = [ "{Title}","{Runtime}","{Directors}","{Studio}","
|
||||||
"{Artists}","{Genre}","{Index}","{Premiere}","{MvideoId}"
|
"{Artists}","{Genre}","{Index}","{Premiere}","{MvideoId}"
|
||||||
]
|
]
|
||||||
update_tvshow = """ UPDATE tvshow
|
update_tvshow = """ UPDATE tvshow
|
||||||
SET c00 = ?, c01 = ?, c02 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?,
|
SET c00 = ?, c01 = ?, c02 = ?, c04 = ?, c05 = ?, c08 = ?, c09 = ?, c10 = ?,
|
||||||
c12 = ?, c13 = ?, c14 = ?, c15 = ?
|
c12 = ?, c13 = ?, c14 = ?, c15 = ?
|
||||||
WHERE idShow = ?
|
WHERE idShow = ?
|
||||||
"""
|
"""
|
||||||
update_tvshow_obj = [ "{Title}","{Plot}","{Status}","{RatingId}","{Premiere}","{Genre}","{Title}",
|
update_tvshow_obj = [ "{Title}","{Plot}","{Status}","{RatingId}","{Premiere}","{Genre}","{Title}",
|
||||||
"{Unique}","{Mpaa}","{Studio}","{SortTitle}","{ShowId}"
|
"disintegrate browse bug","{Unique}","{Mpaa}","{Studio}","{SortTitle}","{ShowId}"
|
||||||
]
|
]
|
||||||
update_tvshow_link = """ INSERT OR REPLACE INTO tvshowlinkpath(idShow, idPath)
|
update_tvshow_link = """ INSERT OR REPLACE INTO tvshowlinkpath(idShow, idPath)
|
||||||
VALUES (?, ?)
|
VALUES (?, ?)
|
||||||
|
|
|
@ -148,7 +148,7 @@ class Player(xbmc.Player):
|
||||||
'CurrentPosition': item.get('CurrentPosition') or int(seektime),
|
'CurrentPosition': item.get('CurrentPosition') or int(seektime),
|
||||||
'Muted': muted,
|
'Muted': muted,
|
||||||
'Volume': volume,
|
'Volume': volume,
|
||||||
'Server': Emby(item['ServerId']),
|
'Server': Emby(item['ServerId']).get_client(),
|
||||||
'Paused': False
|
'Paused': False
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue