Skip to content

Commit

Permalink
Merge pull request #524 from quickmic/next-gen-dev-python3
Browse files Browse the repository at this point in the history
10.0.30, review changelog for details
  • Loading branch information
quickmic authored Jun 14, 2024
2 parents 8391035 + f464b5d commit d78f512
Show file tree
Hide file tree
Showing 38 changed files with 1,698 additions and 1,435 deletions.
34 changes: 14 additions & 20 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,70 +1,64 @@
<?xml version='1.0' encoding='UTF-8' standalone="yes"?>
<addon id="plugin.video.emby-next-gen" name="Emby for Kodi Next Gen" version="10.0.24" provider-name="quickmic">
<addon id="plugin.service.emby-next-gen" name="Emby for Kodi Next Gen" version="10.0.30" provider-name="quickmic">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.urllib3" version="1.0.0"/>
<import addon="script.module.dateutil" version="2.8.1" />
<import addon="plugin.audio.emby-next-gen" version="10.0.0" />
<import addon="plugin.image.emby-next-gen" version="10.0.0" />
</requires>
<extension point="xbmc.python.pluginsource" library="events.py">
<provides>video</provides>
</extension>
<extension point="xbmc.service" library="service.py" />
<extension point="kodi.context.item">
<menu id="kodi.core.main">
<item library="events.py" args="record">
<item library="service.py" args="record">
<label>33490</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRecording),True) + String.StartsWith(ListItem.Path,"pvr://guide/") + !String.IsEmpty(ListItem.EPGEventIcon)]</visible>
</item>
<item library="events.py" args="specials">
<item library="service.py" args="specials">
<label>33485</label>
<visible>[String.IsEqual(Window(10000).Property(EmbySpecials),True) + String.Contains(ListItem.FileName,"-s-")]</visible>
</item>
<menu>
<label>33669</label>
<item library="events.py" args="gotoshow">
<item library="service.py" args="gotoshow">
<label>33670</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyGoto),True) + String.IsEqual(ListItem.DBTYPE,episode)]</visible>
</item>
<item library="events.py" args="gotoseason">
<item library="service.py" args="gotoseason">
<label>33671</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyGoto),True) + String.IsEqual(ListItem.DBTYPE,episode)]</visible>
</item>
</menu>
<item library="events.py" args="download">
<item library="service.py" args="download">
<label>33570</label>
<visible>String.IsEqual(Window(10000).Property(EmbyDownload),True) + [[String.StartsWith(ListItem.FileName,"e-") | String.StartsWith(ListItem.FileName,"m-") | String.StartsWith(ListItem.FileName,"M-") | [[[String.IsEqual(ListItem.DBTYPE,"tvshow") | String.IsEqual(ListItem.DBTYPE,"season")] + !String.EndsWith(ListItem.Label," (download)")] + [String.Contains(ListItem.Path,"/emby_addon_mode/") | String.Contains(ListItem.Path,"http://127.0.0.1:57342/")]]] + !String.Contains(ListItem.Path,"/EMBY-offline-content/") + !String.Contains(ListItem.Path,"/dynamic/") + !String.IsEmpty(ListItem.DBID)]</visible>
</item>
<item library="events.py" args="deletedownload">
<item library="service.py" args="deletedownload">
<label>33571</label>
<visible>String.IsEqual(Window(10000).Property(EmbyDownload),True) + [String.Contains(ListItem.Path,"/EMBY-offline-content/") | [[String.IsEqual(ListItem.DBTYPE,"tvshow") | String.IsEqual(ListItem.DBTYPE,"season")] + String.EndsWith(ListItem.Label," (download)")]]</visible>
</item>
<item library="events.py" args="favorites">
<item library="service.py" args="favorites">
<label>33547</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyFavourite),True) + String.IsEqual(Window(10000).Property(EmbyFavourite),True) + !String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"plugin://") + !String.StartsWith(ListItem.FolderPath,"favourites:") + !String.StartsWith(ListItem.Path,"pvr://")]</visible>
</item>
<item library="events.py" args="watchtogether">
<item library="service.py" args="watchtogether">
<label>33548</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRemote),True) + !String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"favourites:") + !String.IsEmpty(ListItem.Filename) + !String.IsEqual(ListItem.FileExtension,"m3u") + !String.StartsWith(ListItem.Path,"pvr://")]</visible>
</item>
<item library="events.py" args="remoteplay">
<item library="service.py" args="remoteplay">
<label>33652</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRemote),True) + !String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"favourites:") + !String.IsEmpty(ListItem.Filename) + !String.IsEqual(ListItem.FileExtension,"m3u") + !String.StartsWith(ListItem.Path,"pvr://")]</visible>
</item>
<item library="events.py" args="addremoteclient">
<item library="service.py" args="addremoteclient">
<label>33519</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRemote),True) + !String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"plugin://")]</visible>
</item>
<item library="events.py" args="removeremoteclient">
<item library="service.py" args="removeremoteclient">
<label>33518</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRemote),True) + String.IsEqual(Window(10000).Property(EmbyRemoteclient),True)]</visible>
</item>
<item library="events.py" args="refreshitem">
<item library="service.py" args="refreshitem">
<label>30410</label>
<visible>[String.IsEqual(Window(10000).Property(EmbyRefresh),True) + !String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"plugin://") + !String.StartsWith(ListItem.FolderPath,"favourites:") + !String.IsEmpty(ListItem.Filename) + !String.IsEqual(ListItem.FileExtension,"m3u") + !String.StartsWith(ListItem.Path,"pvr://")]</visible>
</item>
<item library="events.py" args="deleteitem">
<item library="service.py" args="deleteitem">
<label>30409</label>
<visible>[!String.StartsWith(ListItem.FolderPath,"library://") + !String.StartsWith(ListItem.FolderPath,"addons://") + !String.StartsWith(ListItem.FolderPath,"plugin://") + String.IsEqual(Window(10000).Property(EmbyDelete),True)]</visible>
</item>
Expand Down
52 changes: 52 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
10.0.30
=============
fix transcoding playback



10.0.29
=============
intercept pillow library issue



10.0.28
=============
minor changes in Player session ops
fix websocket messages delay
fix session logout



10.0.27
=============
fix several minor http issues
faster https socket connection
support http redirects (including websocket connections)
fix Emby session stop
sync pause only for Emby scan tasks



10.0.26
=============
rewrite http communication with Emby server (remove urllib3 dependency, http comminicaion is now on low level socket-basis)
fix context menu
rewrite emby login handshakes
fix textoverlay position
fix minor artwork issues
remove song artwork from synced content (let Kodi handle it)
fix menu options in content helper plugins
fix library Id filters for dynamic nodes
fix dynamic node Genre for Audiobooks and Podcasts



10.0.25
=============
fix sort orders for dynamic nodes
improve performance for dynamic nodes
change plugin structure (fixes content detection issues for dynamic nodes)



10.0.24
=============
fix server busy progress bar when server restarted or shutdown
Expand Down
42 changes: 26 additions & 16 deletions core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"Person": (('Primary', 'poster'), ("Art", 'clearart'), ("Banner", 'banner'), ("Thumb", 'thumb'), ("Thumb", 'landscape'), ("Backdrop", 'fanart'), ('Primary', 'thumb'), ("Primary", 'landscape'))
}


def load_ExistingItem(Item, EmbyServer, emby_db, EmbyType):
if Item['LibraryId'] not in EmbyServer.library.WhitelistUnique:
xbmc.log(f"EMBY.core.common: Library not synced: {Item['LibraryId']}", 3) # LOGERROR
Expand Down Expand Up @@ -593,7 +594,7 @@ def set_common(Item, ServerId, DynamicNode):
if 'PrimaryImageTag' in ArtistItem:
ArtistItem['imageurl'] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{ArtistItem['Id']}-0-p-{ArtistItem['PrimaryImageTag']}|redirect-limit=1000"
else:
ArtistItem['imageurl'] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{ArtistItem['Id']}-0-p-0|redirect-limit=1000"
ArtistItem['imageurl'] = ""

def set_Dates(Item):
if 'ProductionYear' in Item:
Expand Down Expand Up @@ -665,7 +666,7 @@ def set_chapters(Item, ServerId):
else:
ChapterImage = f"http://127.0.0.1:57342/picture/{ServerId}/p-{Item['Id']}-{index}-c-noimage-{quote(Chapter['Name'])}|redirect-limit=1000"

if not Chapter["StartPositionTicks"] in Chapters:
if Chapter["StartPositionTicks"] not in Chapters:
Chapters[Chapter["StartPositionTicks"]] = ChapterImage
else:
# replace existing chapter label with marker label
Expand All @@ -691,6 +692,12 @@ def set_KodiArtwork(Item, ServerId, DynamicNode):
Item['SeriesPrimaryImageTag'] = Item.get('SeriesPrimaryImageTag', None)
Item['KodiArtwork'] = {'clearart': None, 'clearlogo': None, 'discart': None, 'landscape': None, 'thumb': None, 'banner': None, 'poster': None, 'fanart': {}, 'favourite': None}

if not DynamicNode and Item['Type'] == "Audio": # no artwork for synced song content (Kodi handels that based on Albumart etc.)
if Item["AlbumPrimaryImageTag"] and "AlbumId" in Item:
Item['KodiArtwork']['favourite'] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{Item['AlbumId']}-0-p-{Item['AlbumPrimaryImageTag']}|redirect-limit=1000"

return

if Item['Type'] in ImageTagsMappings:
for ImageTagsMapping in ImageTagsMappings[Item['Type']]:
EmbyArtworkId = None
Expand All @@ -717,17 +724,20 @@ def set_KodiArtwork(Item, ServerId, DynamicNode):
elif ImageTagsMapping[0] == "AlbumPrimary":
if "AlbumId" in Item:
EmbyArtworkId = Item["AlbumId"]
elif ImageTagsMapping[0] == "ParentBanner":
if "SeriesId" in Item:
EmbyArtworkId = Item["SeriesId"]

if DynamicNode:
if ImageTagsMapping[0] == "ParentBanner":
if "SeriesId" in Item:
EmbyArtworkId = Item["SeriesId"]
EmbyArtworkTag = ""
elif ImageTagsMapping[0] == "AlbumArtists" and "AlbumArtists" in Item and Item["AlbumArtists"] and Item["AlbumArtists"] != "None":
EmbyArtworkId = Item["AlbumArtists"][0]['Id']
EmbyArtworkTag = ""
elif ImageTagsMapping[0] == "ArtistItems" and "ArtistItems" in Item and Item["ArtistItems"] and Item["ArtistItems"] != "None":
EmbyArtworkId = Item["ArtistItems"][0]['Id']
EmbyArtworkTag = ""
elif ImageTagsMapping[0] == "AlbumArtists" and "AlbumArtists" in Item and Item["AlbumArtists"] and Item["AlbumArtists"] != "None":
EmbyArtworkId = Item["AlbumArtists"][0]['Id']
EmbyArtworkTag = ""
elif ImageTagsMapping[0] == "ArtistItems" and "ArtistItems" in Item and Item["ArtistItems"] and Item["ArtistItems"] != "None":
EmbyArtworkId = Item["ArtistItems"][0]['Id']
EmbyArtworkTag = ""
elif f"{ImageTagsMapping[0]}ImageTags" in Item:

if f"{ImageTagsMapping[0]}ImageTags" in Item:
BackDropsKey = f"{ImageTagsMapping[0]}ImageTags"

if BackDropsKey == "ParentBackdropImageTags":
Expand All @@ -738,19 +748,19 @@ def set_KodiArtwork(Item, ServerId, DynamicNode):
if EmbyBackDropsId:
if Item[BackDropsKey] and Item[BackDropsKey] != "None":
if ImageTagsMapping[1] == "fanart":
if not "fanart" in Item['KodiArtwork']["fanart"]:
if "fanart" not in Item['KodiArtwork']["fanart"]:
Item['KodiArtwork']["fanart"]["fanart"] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{EmbyBackDropsId}-0-B-{Item[BackDropsKey][0]}|redirect-limit=1000"

for index, EmbyArtworkTag in enumerate(Item[BackDropsKey][1:], 1):
if not f"fanart{index}" in Item['KodiArtwork']["fanart"]:
if f"fanart{index}" not in Item['KodiArtwork']["fanart"]:
Item['KodiArtwork']["fanart"][f"fanart{index}"] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{EmbyBackDropsId}-{index}-B-{EmbyArtworkTag}|redirect-limit=1000"
else:
if not Item['KodiArtwork'][ImageTagsMapping[1]]:
Item['KodiArtwork'][ImageTagsMapping[1]] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{EmbyBackDropsId}-0-{EmbyArtworkIdShort[ImageTagsMapping[0]]}-{Item[BackDropsKey][0]}|redirect-limit=1000"

if EmbyArtworkId:
if ImageTagsMapping[1] == "fanart":
if not "fanart" in Item['KodiArtwork']["fanart"]:
if "fanart" not in Item['KodiArtwork']["fanart"]:
Item['KodiArtwork']["fanart"]["fanart"] = f"http://127.0.0.1:57342/picture/{ServerId}/p-{EmbyArtworkId}-0-{EmbyArtworkIdShort[ImageTagsMapping[0]]}-{EmbyArtworkTag}|redirect-limit=1000"
else:
if not Item['KodiArtwork'][ImageTagsMapping[1]]:
Expand Down Expand Up @@ -1169,7 +1179,7 @@ def update_multiversion(EmbyDB, Item, EmbyType):

def update_boxsets(StartSync, ParentId, LibraryId, SQLs, EmbyServer):
if not StartSync:
for BoxSet in EmbyServer.API.get_Items(ParentId, ["BoxSet"], True, True, {'GroupItemsIntoCollections': True}):
for BoxSet in EmbyServer.API.get_Items(ParentId, ["BoxSet"], True, True, {'GroupItemsIntoCollections': True}, "", False):
SQLs["emby"].add_UpdateItem(BoxSet['Id'], "BoxSet", LibraryId)

def set_Favorites_Artwork(Item, ServerId):
Expand Down
1 change: 0 additions & 1 deletion core/musicartist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def change(self, Item):
xbmc.log(f"EMBY.core.musicartist: Process item: {Item['Name']}", 0) # DEBUG
common.set_MetaItems(Item, self.SQLs, self.MusicGenreObject, self.EmbyServer, "MusicGenre", 'GenreItems')
common.set_common(Item, self.EmbyServer.ServerData['ServerId'], False)
common.set_KodiArtwork(Item, self.EmbyServer.ServerData['ServerId'], False)
isFavorite = common.set_Favorite(Item)
_, KodiDB = self.EmbyServer.library.WhitelistUnique[str(Item['LibraryId'])]
NewItem = False
Expand Down
2 changes: 1 addition & 1 deletion core/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def change(self, Item):
common.load_ExistingItem(Item, self.EmbyServer, self.SQLs["emby"], "Playlist")
IsFavorite = common.set_Favorite(Item)
xbmc.log(f"EMBY.core.playlist: Process item: {Item['Name']}", 0) # DEBUG
PlaylistItems = self.EmbyServer.API.get_Items(Item['Id'], ["Episode", "Movie", "Trailer", "MusicVideo", "Audio", "Video", "Photo"], True, True, {},"")
PlaylistItems = self.EmbyServer.API.get_Items(Item['Id'], ["Episode", "Movie", "Trailer", "MusicVideo", "Audio", "Video", "Photo"], True, True, {}, "", True)
KodiItemId = utils.valid_Filename(Item['Name'])
PlaylistFilename = f"{utils.PlaylistPath}{KodiItemId}.m3u"
isFavorite = common.set_Favorite(Item)
Expand Down
2 changes: 1 addition & 1 deletion database/emby_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def add_multiversion(self, item, EmbyType, API, SQLs):
SQLs['video'].delete_musicvideos(ItemReferenced['KodiItemId'], ItemReferenced['KodiFileId'])

# Add references
if not "ParentId" in item:
if "ParentId" not in item:
item['ParentId'] = None

if EmbyType == "Episode":
Expand Down
Loading

0 comments on commit d78f512

Please sign in to comment.