From dc12f05ba823f7347ef95bec773dc55d1e000183 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 3 Feb 2016 16:43:29 -0600 Subject: [PATCH 1/8] Fix indentation Somehow using tabs rather than spaces --- resources/lib/playlist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/lib/playlist.py b/resources/lib/playlist.py index e353f8e7..6b4c1e54 100644 --- a/resources/lib/playlist.py +++ b/resources/lib/playlist.py @@ -62,7 +62,7 @@ class Playlist(): mediatype = embydb_item[4] except TypeError: # Item is not found in our database, add item manually - self.logMsg("Item was not found in the database, manually adding item.", 1) + self.logMsg("Item was not found in the database, manually adding item.", 1) item = self.emby.getItem(itemid) self.addtoPlaylist_xbmc(playlist, item) else: @@ -79,7 +79,7 @@ class Playlist(): # Seek to the starting position seektime = startat / 10000000.0 player.seekTime(seektime) - self.logMsg("Seeking to: %s" % seektime, 1) + self.logMsg("Seeking to: %s" % seektime, 1) self.verifyPlaylist() embycursor.close() From c4608b38e131ecdf61d32b24ee0baa687bb00a39 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 3 Feb 2016 19:06:12 -0600 Subject: [PATCH 2/8] Fix resume when using play-to --- resources/lib/kodimonitor.py | 3 +-- resources/lib/player.py | 11 +++++++++++ resources/lib/playlist.py | 18 +++++++----------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/resources/lib/kodimonitor.py b/resources/lib/kodimonitor.py index 05ecf8a5..ac781e5a 100644 --- a/resources/lib/kodimonitor.py +++ b/resources/lib/kodimonitor.py @@ -200,5 +200,4 @@ class KodiMonitor(xbmc.Monitor): utils.window('emby_onWake', value="true") elif method == "Playlist.OnClear": - utils.window('emby_customPlaylist', clear=True) - self.logMsg("Clear playlist properties.") \ No newline at end of file + pass \ No newline at end of file diff --git a/resources/lib/player.py b/resources/lib/player.py index 7972edec..354b8984 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -98,6 +98,15 @@ class Player(xbmc.Player): itemType = utils.window("%s.type" % embyitem) utils.window('emby_skipWatched%s' % itemId, value="true") + + if (utils.window('emby_customPlaylist') == "true" and + utils.window('emby_customPlaylist.seektime')): + # Start at, when using custom playlist (play to Kodi from webclient) + seektime = utils.window('emby_customPlaylist.seektime') + self.logMsg("Seeking to: %s" % seektime, 1) + xbmcplayer.seekTime(int(seektime)/10000000.0) + utils.window('emby_customPlaylist.seektime', clear=True) + seekTime = xbmcplayer.getTime() # Get playback volume @@ -401,6 +410,7 @@ class Player(xbmc.Player): # Will be called when user stops xbmc playing a file self.logMsg("ONPLAYBACK_STOPPED", 2) utils.window('emby_customPlaylist', clear=True) + utils.window('emby_customPlaylist.seektime', clear=True) utils.window('emby_playbackProps', clear=True) self.logMsg("Clear playlist properties.", 1) self.stopAll() @@ -408,6 +418,7 @@ class Player(xbmc.Player): def onPlayBackEnded( self ): # Will be called when xbmc stops playing a file self.logMsg("ONPLAYBACK_ENDED", 2) + utils.window('emby_customPlaylist.seektime', clear=True) self.stopAll() def stopAll(self): diff --git a/resources/lib/playlist.py b/resources/lib/playlist.py index 6b4c1e54..c265cb79 100644 --- a/resources/lib/playlist.py +++ b/resources/lib/playlist.py @@ -43,17 +43,19 @@ class Playlist(): embycursor = embyconn.cursor() emby_db = embydb.Embydb_Functions(embycursor) - self.logMsg("---*** PLAY ALL ***---", 1) - self.logMsg("Items: %s and start at: %s" % (itemids, startat)) - player = xbmc.Player() playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() - started = False + self.logMsg("---*** PLAY ALL ***---", 1) + self.logMsg("Items: %s and start at: %s" % (itemids, startat)) + + started = False utils.window('emby_customplaylist', value="true") - position = 0 + if startat != 0: + # Seek to the starting position + utils.window('emby_customplaylist.seektime', str(startat)) for itemid in itemids: embydb_item = emby_db.getItem_byId(itemid) @@ -75,12 +77,6 @@ class Playlist(): started = True player.play(playlist) - if startat: - # Seek to the starting position - seektime = startat / 10000000.0 - player.seekTime(seektime) - self.logMsg("Seeking to: %s" % seektime, 1) - self.verifyPlaylist() embycursor.close() From 452df0614d712d35cb0a7b1a2e310862b730d43e Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Wed, 3 Feb 2016 23:08:00 -0600 Subject: [PATCH 3/8] Update labels for settings + modify h265 transcode This convert the setting into convert H265 for resolution and higher (for example: 480p and higher) Also prepare for string translation --- resources/language/English/strings.xml | 66 ++++++++++++++------ resources/lib/playutils.py | 50 +++++++++------ resources/settings.xml | 84 +++++++++++++------------- 3 files changed, 122 insertions(+), 78 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 727f4019..61624c4e 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -1,9 +1,9 @@  - Primary Server Address - Auto enter single folder items: - Play from HTTP instead of SMB: - Log Level: + + Primary Server Address + Play from HTTP instead of SMB + Log level Username: Password: Network Username: @@ -17,11 +17,10 @@ Device Name Advanced - Username: - Password: + Username Use SIMPLEJSON instead of JSON - Port Number: + Port Number Number of recent Movies to show: Number of recent TV episodes to show: Number of recent Music Albums to show: @@ -97,9 +96,9 @@ Include Stream Info Include People Include Overview - Offer delete after playback - For Episodes - For Movies + Offer delete after playback + For Episodes + For Movies Background Art Refresh Rate (seconds) Add Resume Percent Add Episode Number @@ -143,10 +142,10 @@ - Show Unplayed Count Indicator - Show Played Percentage Indicator Sort NextUp by Show Title - Enable Enhanced Images (eg CoverArt) + Enable Enhanced Images (eg CoverArt) Metadata Artwork - Video Quality + Video Quality Enable Suggested Loader (Requires Restart) Add Season Number @@ -224,23 +223,22 @@ Random Items Recommended Items - Extras + Extras Sync Theme Music Sync Extra Fanart Sync Movie BoxSets - Reset Local Kodi DB + Reset local Kodi database Enable watched/resume status sync DB Sync Indication: Play Count Sync Indication: - Enable HTTPS + Enable HTTPS Force Transcoding Codecs Enable Netflix style next up notification - The number of seconds before the end to show the notification Show Emby Info dialog on play/select action - Enable server connection message on start-up - Use local paths instead of addon redirect for playback + Enable server connection message on startup Recently added Home Videos Recently added Photos @@ -278,6 +276,40 @@ Emby addon settings Delete item from the server + + Verify Host SSL Certificate + Client SSL certificate + Use alternate address + Alternate Server Address + Use altername device Name + [COLOR yellow]Retry login[/COLOR] + Sync Options + Show syncing progress + Sync empty TV Shows + Enable Music Library + Direct stream music library + Playback Mode + Force artwork caching + Limit artwork cache threads + Enable fast startup (requires server plugin) + Maximum items to request from the server at once + Playback + Network credentials + Enable Emby cinema mode + Ask to play trailers + Skip delete confirmation + Jump back on resume (in seconds) + Force transcode H265 + Music metadata options (not compatible with direct stream) + Import music song rating directly from files + Convert music song rating to Emby rating + Allow rating in song files to be updated + Ignore specials in next episodes + Permanent users to add to the session + Startup delay (in seconds) + Enable server restart message + Enable new content notification + Welcome Error connecting diff --git a/resources/lib/playutils.py b/resources/lib/playutils.py index 6751ec45..4504bc4a 100644 --- a/resources/lib/playutils.py +++ b/resources/lib/playutils.py @@ -97,17 +97,22 @@ class PlayUtils(): self.logMsg("Can't direct play, play from HTTP enabled.", 1) return False - if (utils.settings('transcodeH265') == "true" and - item['MediaSources'][0]['Name'].startswith(("1080P/HEVC","1080P/H265"))): - # Avoid H265 1080p - self.logMsg("Option to transcode 1080P/H265 enabled.", 1) - return False + videotrack = item['MediaSources'][0]['Name'] + transcodeH265 = utils.settings('transcodeH265') - elif (utils.settings('transcode720H265') == "true" and - item['MediaSources'][0]['Name'].startswith(("720P/HEVC","720P/H265"))): - # Avoid H265 720p - self.logMsg("Option to transcode 720P/H265 enabled.", 1) - return False + if transcodeH265 != "0" and ("HEVC" in videotrack or "H265" in videotrack): + # Avoid H265/HEVC depending on the resolution + resolution = int(videotrack.split("P", 1)[0]) + res = { + + '1': 480, + '2': 720, + '3': 1080 + } + self.logMsg("Resolution is: %sP, transcode for resolution: %sP+" + % (resolution, res[transcodeH265]), 1) + if res[transcodeH265] <= resolution: + return False canDirectPlay = item['MediaSources'][0]['SupportsDirectPlay'] # Make sure direct play is supported by the server @@ -203,17 +208,22 @@ class PlayUtils(): item = self.item - if (utils.settings('transcodeH265') == "true" and - item['MediaSources'][0]['Name'].startswith(("1080P/HEVC","1080P/H265"))): - # Avoid H265 1080p - self.logMsg("Option to transcode 1080P/H265 enabled.", 1) - return False + videotrack = item['MediaSources'][0]['Name'] + transcodeH265 = utils.settings('transcodeH265') - elif (utils.settings('transcode720H265') == "true" and - item['MediaSources'][0]['Name'].startswith(("720P/HEVC","720P/H265"))): - # Avoid H265 720p - self.logMsg("Option to transcode 720P/H265 enabled.", 1) - return False + if transcodeH265 != "0" and ("HEVC" in videotrack or "H265" in videotrack): + # Avoid H265/HEVC depending on the resolution + resolution = int(videotrack.split("P", 1)[0]) + res = { + + '1': 480, + '2': 720, + '3': 1080 + } + self.logMsg("Resolution is: %sP, transcode for resolution: %sP+" + % (resolution, res[transcodeH265]), 1) + if res[transcodeH265] <= resolution: + return False # Requirement: BitRate, supported encoding canDirectStream = item['MediaSources'][0]['SupportsDirectStream'] diff --git a/resources/settings.xml b/resources/settings.xml index 4a9ba88f..a2ee222e 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -5,72 +5,74 @@ - - + + - - - - - - + + + + + + - + - + - - - - - - - - - - + + + + + + + + + + + + + + + - - + + - - + + - - + + + - - + - + - - - - - - - + + + + + + - - - - - + + + From 95ed1992180969a111d72bf95797b5983e0f97ec Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 4 Feb 2016 17:09:35 +1100 Subject: [PATCH 4/8] use retention date from server --- resources/lib/librarysync.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index 704b8e1a..b3ccfc8f 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -104,7 +104,25 @@ class LibrarySync(threading.Thread): if not lastSync: lastSync = "2010-01-01T00:00:00Z" self.logMsg("Last sync run: %s" % lastSync, 1) + + lastSyncTime = datetime.strptime(lastSync, "%Y-%m-%dT%H:%M:%SZ") + self.logMsg("LastIncrementalSync : %s" % lastSyncTime, 1) + + # get server RetentionDateTime + url = "{server}/Emby.Kodi.SyncQueue/GetServerDateTime?format=json" + result = self.doUtils.downloadUrl(url) + retention_time = "2010-01-01T00:00:00Z" + if result and result['RetentionDateTime']: + self.logMsg("RetentionDateTime Found", 1) + retention_time = result['RetentionDateTime'] + retention_time = datetime.strptime(retention_time, "%Y-%m-%dT%H:%M:%SZ") + self.logMsg("RetentionDateTime : %s" % retention_time, 1) + # if last sync before retention time do a full sync + if retention_time > lastSyncTime: + self.logMsg("Fast sync server retention insurficient, fall back to full sync", 1) + return False + url = "{server}/emby/Emby.Kodi.SyncQueue/{UserId}/GetItems?format=json" params = {'LastUpdateDT': lastSync} result = self.doUtils.downloadUrl(url, parameters=params) From 6b00eb466eb5e261e207b37ecfcea551f6d49437 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 4 Feb 2016 03:41:39 -0600 Subject: [PATCH 5/8] Adjust sources.xml switch to adding only smb:// as suggested on forums --- resources/lib/utils.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 7431c4a2..8da3c9d9 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -312,20 +312,21 @@ def sourcesXML(): etree.SubElement(video, 'default', attrib={'pathversion': "1"}) # Add elements - for i in range(1, 3): - - for source in root.findall('.//path'): - if source.text == "smb://embydummy/dummypath%s/" % i: - # Already there, skip - break - else: - source = etree.SubElement(video, 'source') - etree.SubElement(source, 'name').text = "Emby" - etree.SubElement(source, 'path', attrib={'pathversion': "1"}).text = ( - - "smb://embydummy/dummypath%s/" % i - ) - etree.SubElement(source, 'allowsharing').text = "true" + count = 2 + for source in root.findall('.//path'): + if source.text == "smb://": + count -= 1 + + if count == 0: + # sources already set + break + else: + # Missing smb:// occurences, re-add. + for i in range(0, count): + source = etree.SubElement(video, 'source') + etree.SubElement(source, 'name').text = "Emby" + etree.SubElement(source, 'path', attrib={'pathversion': "1"}).text = "smb://" + etree.SubElement(source, 'allowsharing').text = "true" # Prettify and write to file try: indent(root) From 4df6bb68d3ebd3793253a997ea92b5f91921f63f Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 4 Feb 2016 04:06:28 -0600 Subject: [PATCH 6/8] Fix typo in manual sync --- resources/lib/librarysync.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/lib/librarysync.py b/resources/lib/librarysync.py index b3ccfc8f..4ea39bdd 100644 --- a/resources/lib/librarysync.py +++ b/resources/lib/librarysync.py @@ -1375,10 +1375,10 @@ class ManualSync(LibrarySync): # Only update if songs is not in Kodi or checksum is different updatelist.append(itemid) - self.logMsg("%s to update: %s" % (type, updatelist), 1) - embyitems = emby.getFullItems(updatelist) - total = len(updatelist) - del updatelist[:] + self.logMsg("%s to update: %s" % (type, updatelist), 1) + embyitems = emby.getFullItems(updatelist) + total = len(updatelist) + del updatelist[:] if pdialog: pdialog.update(heading="Processing %s / %s items" % (type, total)) From c2dace4c1e8cd4b37860b65991eb0b9d82f3f581 Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 4 Feb 2016 05:42:17 -0600 Subject: [PATCH 7/8] Add control over notification time for new content Video and music library --- resources/language/English/strings.xml | 6 ++---- resources/lib/itemtypes.py | 13 ++++++++----- resources/settings.xml | 2 ++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 61624c4e..59ae3caf 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -233,11 +233,7 @@ DB Sync Indication: Play Count Sync Indication: Enable HTTPS - Force Transcoding Codecs - Enable Netflix style next up notification - - The number of seconds before the end to show the notification - Show Emby Info dialog on play/select action Enable server connection message on startup Recently added Home Videos @@ -309,6 +305,8 @@ Startup delay (in seconds) Enable server restart message Enable new content notification + For the video library (in seconds) + For the music library (in seconds) Welcome diff --git a/resources/lib/itemtypes.py b/resources/lib/itemtypes.py index 3f022273..71d81d5f 100644 --- a/resources/lib/itemtypes.py +++ b/resources/lib/itemtypes.py @@ -39,6 +39,8 @@ class Items(object): self.directpath = utils.settings('useDirectPaths') == "1" self.music_enabled = utils.settings('enableMusic') == "true" self.contentmsg = utils.settings('newContent') == "true" + self.newvideo_time = int(utils.settings('newvideotime'))*1000 + self.newmusic_time = int(utils.settings('newmusictime'))*1000 self.artwork = artwork.Artwork() self.emby = embyserver.Read_EmbyServer() @@ -205,11 +207,12 @@ class Items(object): return True - def contentPop(self, name): + def contentPop(self, name, time=5000): xbmcgui.Dialog().notification( heading="Emby for Kodi", message="Added: %s" % name, icon="special://home/addons/plugin.video.emby/icon.png", + time=time, sound=False) @@ -232,7 +235,7 @@ class Movies(Items): count += 1 self.add_update(movie) if not pdialog and self.contentmsg: - self.contentPop(title) + self.contentPop(title, self.newvideo_time) def added_boxset(self, items, pdialog): @@ -627,7 +630,7 @@ class MusicVideos(Items): count += 1 self.add_update(mvideo) if not pdialog and self.contentmsg: - self.contentPop(title) + self.contentPop(title, self.newvideo_time) def add_update(self, item, viewtag=None, viewid=None): @@ -964,7 +967,7 @@ class TVShows(Items): count += 1 self.add_updateEpisode(episode) if not pdialog and self.contentmsg: - self.contentPop(title) + self.contentPop(title, self.newvideo_time) def add_update(self, item, viewtag=None, viewid=None): @@ -1665,7 +1668,7 @@ class Music(Items): count += 1 self.add_updateSong(song) if not pdialog and self.contentmsg: - self.contentPop(title) + self.contentPop(title, self.newmusic_time) def add_updateArtist(self, item, artisttype="MusicArtist"): # Process a single artist diff --git a/resources/settings.xml b/resources/settings.xml index a2ee222e..be8a72c1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -68,6 +68,8 @@ + + From b00bd7b1b780cf31b14d4a1b80613ee4f4a3955b Mon Sep 17 00:00:00 2001 From: angelblue05 Date: Thu, 4 Feb 2016 05:54:58 -0600 Subject: [PATCH 8/8] Update term --- resources/language/English/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 59ae3caf..ccc61957 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -305,8 +305,8 @@ Startup delay (in seconds) Enable server restart message Enable new content notification - For the video library (in seconds) - For the music library (in seconds) + Duration for the video library (in seconds) + Duration for the music library (in seconds) Welcome