mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +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"?>
|
||||
<addon id="plugin.video.emby"
|
||||
name="Emby"
|
||||
version="4.0.0"
|
||||
version="4.0.1"
|
||||
provider-name="angelblue05">
|
||||
<requires>
|
||||
<import addon="xbmc.python" version="2.25.0"/>
|
||||
|
@ -39,6 +39,7 @@
|
|||
<news>
|
||||
New stable release
|
||||
The wiki has been updated: https://github.com/MediaBrowser/plugin.video.emby/wiki
|
||||
Small fixes
|
||||
</news>
|
||||
</extension>
|
||||
</addon>
|
||||
|
|
|
@ -40,11 +40,16 @@ def ensure_client():
|
|||
|
||||
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
|
||||
|
||||
default_client = Emby()['config/app']
|
||||
another_client = Emby('123456')['config/app']
|
||||
Emby('123456')['config/app']
|
||||
|
||||
# Permanent client reference
|
||||
client = Emby('123456').get_client()
|
||||
client['config/app']
|
||||
'''
|
||||
|
||||
# Borg - multiple instances, shared state
|
||||
|
@ -57,6 +62,9 @@ class Emby(object):
|
|||
self.__dict__ = self._shared_state
|
||||
self.server_id = server_id or "default"
|
||||
|
||||
def get_client(self):
|
||||
return self.client[self.server_id]
|
||||
|
||||
@classmethod
|
||||
def set_loghandler(cls, func=loghandler, level=logging.INFO):
|
||||
|
||||
|
|
|
@ -215,17 +215,17 @@ class HTTP(object):
|
|||
def _authorization(self, data):
|
||||
|
||||
auth = "MediaBrowser "
|
||||
auth += "Client=%s, " % self.config['app.name']
|
||||
auth += "Device=%s, " % self.config['app.device_name']
|
||||
auth += "DeviceId=%s, " % self.config['app.device_id']
|
||||
auth += "Version=%s" % self.config['app.version']
|
||||
auth += "Client=%s, " % self.config['app.name'].encode('utf-8')
|
||||
auth += "Device=%s, " % self.config['app.device_name'].encode('utf-8')
|
||||
auth += "DeviceId=%s, " % self.config['app.device_id'].encode('utf-8')
|
||||
auth += "Version=%s" % self.config['app.version'].encode('utf-8')
|
||||
|
||||
data['headers'].update({'Authorization': auth})
|
||||
|
||||
if self.config['auth.token']:
|
||||
|
||||
auth += ', UserId=%s' % self.config['auth.user_id']
|
||||
data['headers'].update({'Authorization': auth, 'X-MediaBrowser-Token': self.config['auth.token']})
|
||||
auth += ', UserId=%s' % self.config['auth.user_id'].encode('utf-8')
|
||||
data['headers'].update({'Authorization': auth, 'X-MediaBrowser-Token': self.config['auth.token'].encode('utf-8')})
|
||||
|
||||
return data
|
||||
|
||||
|
|
|
@ -498,11 +498,11 @@ class Service(xbmc.Monitor):
|
|||
window('emby_should_stop.bool', True)
|
||||
|
||||
properties = [ # TODO: review
|
||||
"emby_state", "emby_serverStatus",
|
||||
"emby_syncRunning", "emby_currUser",
|
||||
"emby_state", "emby_serverStatus", "emby_currUser",
|
||||
|
||||
"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:
|
||||
window(prop, clear=True)
|
||||
|
|
|
@ -14,7 +14,7 @@ import downloader as server
|
|||
import helper.xmls as xmls
|
||||
from database import Database, get_sync, save_sync, emby_db
|
||||
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 emby import Emby
|
||||
|
||||
|
@ -31,12 +31,20 @@ class FullSync(object):
|
|||
_shared_state = {}
|
||||
sync = None
|
||||
running = False
|
||||
screensaver = None
|
||||
|
||||
def __init__(self, library, library_id=None, update=False):
|
||||
|
||||
''' Map the syncing process and start the sync. Ensure only one sync is running.
|
||||
'''
|
||||
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:
|
||||
|
||||
|
@ -162,32 +170,15 @@ class FullSync(object):
|
|||
save_sync(self.sync)
|
||||
start_time = datetime.datetime.now()
|
||||
|
||||
if not settings('dbSyncScreensaver.bool'):
|
||||
for library in list(self.sync['Libraries']):
|
||||
|
||||
xbmc.executebuiltin('InhibitIdleShutdown(true)')
|
||||
screensaver = get_screensaver()
|
||||
set_screensaver(value="")
|
||||
self.process_library(library)
|
||||
|
||||
try:
|
||||
for library in list(self.sync['Libraries']):
|
||||
if not library.startswith('Boxsets:') and library not in self.sync['Whitelist']:
|
||||
self.sync['Whitelist'].append(library)
|
||||
|
||||
self.process_library(library)
|
||||
|
||||
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
|
||||
self.sync['Libraries'].pop(self.sync['Libraries'].index(library))
|
||||
self.sync['RestorePoint'] = {}
|
||||
|
||||
elapsed = datetime.datetime.now() - start_time
|
||||
settings('SyncInstallRunDone.bool', True)
|
||||
|
@ -198,7 +189,6 @@ class FullSync(object):
|
|||
dialog("notification", heading="{emby}", message="%s %s" % (_(33025), str(elapsed).split('.')[0]),
|
||||
icon="{emby}", sound=False)
|
||||
LOG.info("Full sync completed in: %s", str(elapsed).split('.')[0])
|
||||
self.running = False
|
||||
|
||||
def process_library(self, library_id):
|
||||
|
||||
|
@ -249,6 +239,19 @@ class FullSync(object):
|
|||
|
||||
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()
|
||||
def movies(self, library, dialog):
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ class Library(threading.Thread):
|
|||
self.pending_refresh = False
|
||||
self.save_last_sync()
|
||||
self.total_updates = 0
|
||||
window('emby_sync', clear=True)
|
||||
|
||||
if self.progress_updates:
|
||||
|
||||
|
@ -196,6 +197,13 @@ class Library(threading.Thread):
|
|||
def stop_client(self):
|
||||
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):
|
||||
|
||||
''' Get how many items are queued up for worker threads.
|
||||
|
@ -251,7 +259,7 @@ class Library(threading.Thread):
|
|||
new_thread.start()
|
||||
LOG.info("-->[ q:updated/%s/%s ]", queues, id(new_thread))
|
||||
self.writer_threads['updated'].append(new_thread)
|
||||
self.pending_refresh = True
|
||||
self.enable_pending_refresh()
|
||||
|
||||
def worker_userdata(self):
|
||||
|
||||
|
@ -270,7 +278,7 @@ class Library(threading.Thread):
|
|||
new_thread.start()
|
||||
LOG.info("-->[ q:userdata/%s/%s ]", queues, id(new_thread))
|
||||
self.writer_threads['userdata'].append(new_thread)
|
||||
self.pending_refresh = True
|
||||
self.enable_pending_refresh()
|
||||
|
||||
def worker_remove(self):
|
||||
|
||||
|
@ -289,7 +297,7 @@ class Library(threading.Thread):
|
|||
new_thread.start()
|
||||
LOG.info("-->[ q:removed/%s/%s ]", queues, id(new_thread))
|
||||
self.writer_threads['removed'].append(new_thread)
|
||||
self.pending_refresh = True
|
||||
self.enable_pending_refresh()
|
||||
|
||||
def worker_notify(self):
|
||||
|
||||
|
@ -517,7 +525,8 @@ class Library(threading.Thread):
|
|||
|
||||
@progress(_(33144))
|
||||
def remove_library(self, library_id, dialog):
|
||||
|
||||
window('emby_sync.bool', True)
|
||||
|
||||
try:
|
||||
with Database('emby') as embydb:
|
||||
|
||||
|
@ -572,10 +581,11 @@ class Library(threading.Thread):
|
|||
except Exception as error:
|
||||
|
||||
LOG.exception(error)
|
||||
dialog.close()
|
||||
window('emby_sync', clear=True)
|
||||
|
||||
return False
|
||||
|
||||
window('emby_sync', clear=True)
|
||||
Views().get_views()
|
||||
Views().get_nodes()
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
version = "171076028"
|
||||
version = "171076029"
|
||||
|
||||
from movies import Movies
|
||||
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}",
|
||||
"{Plot}","{Album}","{Artists}","{Genre}","{Index}","{Premiere}"
|
||||
]
|
||||
add_tvshow = """ INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c12, c13, c14, c15)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
add_tvshow = """ INSERT INTO tvshow(idShow, c00, c01, c02, c04, c05, c08, c09, c10, c12, c13, c14, c15)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
"""
|
||||
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)
|
||||
VALUES (?, ?, ?)
|
||||
|
@ -446,12 +446,12 @@ update_musicvideo_obj = [ "{Title}","{Runtime}","{Directors}","{Studio}","
|
|||
"{Artists}","{Genre}","{Index}","{Premiere}","{MvideoId}"
|
||||
]
|
||||
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 = ?
|
||||
WHERE idShow = ?
|
||||
"""
|
||||
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)
|
||||
VALUES (?, ?)
|
||||
|
|
|
@ -148,7 +148,7 @@ class Player(xbmc.Player):
|
|||
'CurrentPosition': item.get('CurrentPosition') or int(seektime),
|
||||
'Muted': muted,
|
||||
'Volume': volume,
|
||||
'Server': Emby(item['ServerId']),
|
||||
'Server': Emby(item['ServerId']).get_client(),
|
||||
'Paused': False
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue