Skip to content

Commit

Permalink
Merge pull request #555 from quickmic/next-gen-dev-python3
Browse files Browse the repository at this point in the history
11.1.9, review changelog for details
  • Loading branch information
quickmic authored Dec 3, 2024
2 parents 8a6ddab + 83f9a7b commit fdb6611
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8' standalone="yes"?>
<addon id="plugin.service.emby-next-gen" name="Emby for Kodi Next Gen" version="11.1.8" provider-name="quickmic">
<addon id="plugin.service.emby-next-gen" name="Emby for Kodi Next Gen" version="11.1.9" provider-name="quickmic">
<requires>
<import addon="xbmc.python" version="3.0.1"/>
<import addon="script.module.dateutil" version="2.8.1" />
Expand Down Expand Up @@ -28,7 +28,7 @@
</menu>
<item library="service.py" args="download">
<label>33570</label>
<visible>String.IsEqual(Window(10000).Property(EmbyDownload),True) + [[String.Contains(ListItem.Path,"/e-") | String.Contains(ListItem.Path,"/m-") | String.Contains(ListItem.Path,"/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>
<visible>String.IsEqual(Window(10000).Property(EmbyDownload),True) + [[String.Contains(ListItem.Path,"/v-") | String.Contains(ListItem.Path,"/e-") | String.Contains(ListItem.Path,"/m-") | String.Contains(ListItem.Path,"/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="service.py" args="deletedownload">
<label>33571</label>
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
11.1.9
=============
fix delete homevideos via dyanmic nodes
fix download homevideos
fix progress updates for homevideo in native mode



11.1.8
=============
fix log issue
Expand Down
30 changes: 26 additions & 4 deletions database/emby_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,11 @@ def get_SinglePath(self, EmbyId, EmbyType):
for Path in Paths:
# Emby has poorly designed unique IDs (EmbyId, MediasourceID) definitition, therefore this "by path" query is required
self.cursor.execute(f"SELECT EmbyId FROM {EmbyType} WHERE EmbyFolder = ?", (Path[0],))
EmbyIds += self.cursor.fetchone()
PathData += (Path[0],)
Data = self.cursor.fetchone()

if Data:
EmbyIds += Data
PathData += (Path[0],)

return "\n".join(PathData), EmbyIds

Expand Down Expand Up @@ -851,12 +854,19 @@ def remove_item_by_KodiId(self, KodiId, EmbyType, EmbyLibraryId):

def get_EmbyId_by_KodiId_KodiType(self, KodiId, KodiType):
if KodiType not in utils.KodiTypeMapping:
xbmc.log(f"EMBY.database.emby_db: KodiType invalid (get_EmbyId_EmbyFavourite_by_KodiId_KodiType): {KodiType}", 3) # LOGERROR
xbmc.log(f"EMBY.database.emby_db: KodiType invalid (get_EmbyId_by_KodiId_KodiType): {KodiType}", 3) # LOGERROR
return None

self.cursor.execute(f"SELECT EmbyId FROM {utils.KodiTypeMapping[KodiType]} WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()

if Data:
return Data[0]

if KodiType == "movie": # Emby homevideos are synced as "movie" content into Kodi
self.cursor.execute("SELECT EmbyId FROM Video WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()

if Data:
return Data[0]

Expand Down Expand Up @@ -888,6 +898,13 @@ def get_EmbyId_EmbyFavourite_by_KodiId_KodiType(self, KodiId, KodiType):
self.cursor.execute(f"SELECT EmbyId, EmbyFavourite FROM {utils.KodiTypeMapping[KodiType]} WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()

if Data:
return Data[0], Data[1]

if KodiType == "movie": # Emby homevideos are synced as "movie" content into Kodi
self.cursor.execute("SELECT EmbyId, EmbyFavourite FROM Video WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()

if Data:
return Data[0], Data[1]

Expand All @@ -896,6 +913,7 @@ def get_EmbyId_EmbyFavourite_by_KodiId_KodiType(self, KodiId, KodiType):
def get_nativemode_data(self, KodiId, KodiType):
if KodiType == "videoversion":
self.cursor.execute("SELECT EmbyId FROM Video WHERE KodiFileId = ?", (KodiId,))
Data = self.cursor.fetchone()
EmbyType = "Video"
else:
if KodiType not in utils.KodiTypeMapping:
Expand All @@ -904,8 +922,12 @@ def get_nativemode_data(self, KodiId, KodiType):

EmbyType = utils.KodiTypeMapping[KodiType]
self.cursor.execute(f"SELECT EmbyId FROM {EmbyType} WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()

Data = self.cursor.fetchone()
if not Data and KodiType == "movie": # Emby homevideos are synced as "movie" content into Kodi
self.cursor.execute("SELECT EmbyId FROM Video WHERE KodiId = ?", (KodiId,))
Data = self.cursor.fetchone()
EmbyType = "Video"

if Data:
self.cursor.execute("SELECT IntroStart, IntroEnd, CreditsStart FROM MediaSources WHERE EmbyId = ?", (Data[0],))
Expand Down
20 changes: 16 additions & 4 deletions helper/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def load_item(KodiId=None, KodiType=None):
if not KodiType:
KodiType = xbmc.getInfoLabel('ListItem.DBTYPE')

xbmc.log(f"EMBY.helper.context: load_item ServerId: {ServerId}, KodiType: {KodiType}, ListItemEmbyId: {ListItemEmbyId}, ListItem.FolderPath: {xbmc.getInfoLabel('ListItem.FolderPath')}", 0) # LOGDEBUG

if not ServerId:
if not KodiId:
KodiId = xbmc.getInfoLabel('ListItem.DBID')
Expand Down Expand Up @@ -217,16 +219,18 @@ def favorites():
def refreshitem():
EmbyId, ServerId, _, KodiType = load_item()

if not EmbyId or KodiType not in utils.KodiTypeMapping:
if not EmbyId:
return

utils.EmbyServers[ServerId].API.refresh_item(EmbyId)
utils.EmbyServers[ServerId].library.updated([(EmbyId, utils.KodiTypeMapping[KodiType], "unknown")], True)

if KodiType in utils.KodiTypeMapping:
utils.EmbyServers[ServerId].library.updated([(EmbyId, utils.KodiTypeMapping[KodiType], "unknown")], True)

def deleteitem():
EmbyId, ServerId, _, KodiType = load_item()

if not EmbyId or KodiType not in utils.KodiTypeMapping:
if not EmbyId:
return

EmbyIds = ()
Expand All @@ -236,8 +240,16 @@ def deleteitem():
Path, EmbyIds = embydb.get_EpisodePathsBySeason(EmbyId)
elif KodiType == "tvshow":
Path, EmbyIds = embydb.get_EpisodePathsBySeries(EmbyId)
else:
elif KodiType == "movie":
Path, EmbyIds = embydb.get_SinglePath(EmbyId, "Movie")

if not EmbyIds: # Emby homevideos are synced as "movie" content into Kodi
Path, EmbyIds = embydb.get_SinglePath(EmbyId, "Video")
elif KodiType in utils.KodiTypeMapping:
Path, EmbyIds = embydb.get_SinglePath(EmbyId, utils.KodiTypeMapping[KodiType])
else:
Path = ""
EmbyIds = ()

EmbyIds += (EmbyId,)
EmbyIds = set(EmbyIds) # deduplicate Items
Expand Down
3 changes: 2 additions & 1 deletion helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

WidgetsRefreshLock = allocate_lock()
EmbyTypeMapping = {"Person": "actor", "Video": "movie", "Movie": "movie", "Series": "tvshow", "Season": "season", "Episode": "episode", "Audio": "song", "MusicAlbum": "album", "MusicArtist": "artist", "Genre": "genre", "MusicGenre": "genre", "Tag": "tag" , "Studio": "studio" , "BoxSet": "set", "Folder": None, "MusicVideo": "musicvideo", "Playlist": "Playlist"}
KodiTypeMapping = {"actor": "Person", "tvshow": "Series", "season": "Season", "episode": "Episode", "song": "Audio", "album": "MusicAlbum", "artist": "MusicArtist", "genre": "Genre", "tag": "Tag", "studio": "Studio" , "set": "BoxSet", "musicvideo": "MusicVideo", "playlist": "Playlist", "movie": "Movie", "videoversion": "Video"}
KodiTypeMapping = {"actor": "Person", "tvshow": "Series", "season": "Season", "episode": "Episode", "song": "Audio", "album": "MusicAlbum", "artist": "MusicArtist", "genre": "Genre", "tag": "Tag", "studio": "Studio" , "set": "BoxSet", "musicvideo": "MusicVideo", "playlist": "Playlist", "movie": "Movie", "videoversion": "Video", "video": "Video"}

addon_version = Addon.getAddonInfo('version')
addon_name = Addon.getAddonInfo('name')
icon = ""
Expand Down

0 comments on commit fdb6611

Please sign in to comment.