WIP: other path update approach

Use jellyfin db to determine parent path id
This commit is contained in:
GrégoireDruant 2023-05-05 13:18:37 +02:00
parent fcda2ec043
commit 5b0fecf50c
3 changed files with 47 additions and 0 deletions

View file

@ -71,6 +71,24 @@ class JellyfinDatabase():
except TypeError: except TypeError:
return return
def get_season_kodi_parent_path_id(self, *args):
try:
self.cursor.execute(QU.get_season_kodi_parent_path_id_obj, args)
return self.cursor.fetchone()[0]
except TypeError:
return
def get_episode_kodi_parent_path_id(self, *args):
try:
self.cursor.execute(QU.get_episode_kodi_parent_path_id_obj, args)
return self.cursor.fetchone()[0]
except TypeError:
return
def get_full_item_by_kodi_id(self, *args): def get_full_item_by_kodi_id(self, *args):
try: try:

View file

@ -166,3 +166,26 @@ WHERE jellyfin_parent_id = ?
delete_version = """ delete_version = """
DELETE FROM version DELETE FROM version
""" """
get_season_kodi_parent_path_id = """
SELECT sh.kodi_pathid
FROM jellyfin s
JOIN jellyfin sh
ON s.parent_id = sh.kodi_id
WHERE s.media_type = ?
AND sh.media_type = ?
AND s.id = ?
"""
get_season_kodi_parent_path_id_obj = ["season", "tvshow", "{SeasonId}"]
get_episode_kodi_parent_path_id = """
SELECT sh.kodi_pathid
FROM jellyfin e
JOIN jellyfin s
ON e.parent_id = s.kodi_id
JOIN jellyfin sh
ON s.parent_id = sh.kodi_id
WHERE e.media_type = "episode"
AND s.media_type = "season"
AND sh.media_type = "tvshow"
AND e.kodi_fileid = 698;
"""
get_episode_kodi_parent_path_id = ["episode", "season", "tvshow", "{EpisodeId}"]

View file

@ -116,6 +116,7 @@ class TVShows(KodiDb):
self.tvshow_add(obj) self.tvshow_add(obj)
self.link(*values(obj, QU.update_tvshow_link_obj)) self.link(*values(obj, QU.update_tvshow_link_obj))
# Ne marche pas en mode update...
self.update_path(*values(obj, QU.update_path_tvshow_obj)) self.update_path(*values(obj, QU.update_path_tvshow_obj))
self.add_tags(*values(obj, QU.add_tags_tvshow_obj)) self.add_tags(*values(obj, QU.add_tags_tvshow_obj))
self.add_people(*values(obj, QU.add_people_tvshow_obj)) self.add_people(*values(obj, QU.add_people_tvshow_obj))
@ -152,6 +153,8 @@ class TVShows(KodiDb):
season_id = self.get_season(*values(obj, QU.get_season_special_obj)) season_id = self.get_season(*values(obj, QU.get_season_special_obj))
self.artwork.add(obj['Artwork'], season_id, "season") self.artwork.add(obj['Artwork'], season_id, "season")
# verifier ici
for season in season_episodes: for season in season_episodes:
for episodes in server.get_episode_by_season(season_episodes[season], season): for episodes in server.get_episode_by_season(season_episodes[season], season):
@ -259,6 +262,9 @@ class TVShows(KodiDb):
obj = self.objects.map(item, 'Episode') obj = self.objects.map(item, 'Episode')
update = True update = True
LOG.debug("EPISODE item: [%s]", item)
LOG.debug("EPISODE e_item: [%s]", e_item)
if obj['Location'] == "Virtual": if obj['Location'] == "Virtual":
LOG.info("Skipping virtual episode %s: %s", obj['Title'], obj['Id']) LOG.info("Skipping virtual episode %s: %s", obj['Title'], obj['Id'])