Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #539 "cast not available" #731

Merged
merged 27 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
437df77
WIP
GregoireDruant May 2, 2023
fcda2ec
Feat: added idParentPath to tvshows
GregoireDruant May 4, 2023
5b0fecf
WIP: other path update approach
GregoireDruant May 5, 2023
0473c1e
Revert "Feat: added idParentPath to tvshows"
GregoireDruant May 4, 2023
1a3f312
WIP: parent path id
GregoireDruant May 5, 2023
8de0a02
Feat: Set mediaType and scrapper to all paths for movies and tvshows
GregoireDruant May 6, 2023
98e8064
Merge branch 'fix/cast-not-available-blunt-method'
GregoireDruant May 6, 2023
7031a3e
Merge branch 'fix/cast-not-available-parentId-method' into fix/cast-n…
GregoireDruant May 6, 2023
da6a725
Remove TODO tags
GregoireDruant May 6, 2023
5b14abb
Set pathId to the episode
GregoireDruant May 7, 2023
ff95157
Set parent pathId only when in native mode
GregoireDruant May 7, 2023
e28a041
Set full path in episode
GregoireDruant May 7, 2023
435ad78
Set idParentPath even in add-on mode
GregoireDruant May 7, 2023
dd66f50
Merge branch 'fix/cast-not-available-mediaType-scrapper-parentTrail'
GregoireDruant May 7, 2023
e8188ca
WIP add-on mode
GregoireDruant May 7, 2023
a7e2060
Fix idParentPath addon mode
GregoireDruant May 7, 2023
a8f2935
Fix add-on mode.
GregoireDruant May 7, 2023
4f448e7
Merge branch 'fix/cast-not-availaible-addon-mode-ugly-hack'
GregoireDruant May 13, 2023
7f11de7
Fix duplicate artist links
GregoireDruant Jun 13, 2023
d1fab6c
Fix: remove override of previously set libraryId and name
GregoireDruant Jun 13, 2023
e42542d
Merge branch 'jellyfin:master' into master
GregoireDruant Jun 13, 2023
7486830
Revert "Fix duplicate artist links"
GregoireDruant Jun 13, 2023
628debe
Revert "Fix: remove override of previously set libraryId and name"
GregoireDruant Jun 13, 2023
aa7bc89
Merge branch 'jellyfin:master' into master
GregoireDruant Aug 27, 2023
abda975
Chore: added new line at the end of file
GregoireDruant Aug 27, 2023
9d93ae5
Merge branch 'jellyfin:master' into master
GregoireDruant Sep 23, 2023
68b3e8d
Merge branch 'jellyfin:master' into master
GregoireDruant Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions jellyfin_kodi/database/jellyfin_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
except TypeError:
return

def get_episode_kodi_parent_path_id(self, *args):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.

try:
self.cursor.execute(QU.get_episode_kodi_parent_path_id, args)

Check warning on line 77 in jellyfin_kodi/database/jellyfin_db.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/database/jellyfin_db.py#L76-L77

Added lines #L76 - L77 were not covered by tests

return self.cursor.fetchone()[0]
except TypeError:
return

Check warning on line 81 in jellyfin_kodi/database/jellyfin_db.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/database/jellyfin_db.py#L79-L81

Added lines #L79 - L81 were not covered by tests
oddstr13 marked this conversation as resolved.
Show resolved Hide resolved

def get_full_item_by_kodi_id(self, *args):

try:
Expand Down
14 changes: 14 additions & 0 deletions jellyfin_kodi/database/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,17 @@
delete_version = """
DELETE FROM version
"""

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 = ?
AND s.media_type = ?
AND sh.media_type = ?
AND e.jellyfin_id = ?;
"""
get_episode_kodi_parent_path_id_obj = ["episode", "season", "tvshow", "{Id}"]
3 changes: 3 additions & 0 deletions jellyfin_kodi/objects/kodi/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
except TypeError:
return

def update_path_parent_id(self, path_id, parent_path_id):
self.cursor.execute(QU.update_path_parent_id, (parent_path_id, path_id))

Check warning on line 81 in jellyfin_kodi/objects/kodi/kodi.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/kodi/kodi.py#L81

Added line #L81 was not covered by tests

def update_path(self, *args):
self.cursor.execute(QU.update_path, args)

Expand Down
20 changes: 14 additions & 6 deletions jellyfin_kodi/objects/kodi/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,17 +334,22 @@
"""
add_episode = """
INSERT INTO episode(idEpisode, idFile, c00, c01, c03, c04, c05, c09, c10, c12, c13, c14,
idShow, c15, c16, idSeason)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
idShow, c15, c16, idSeason, c18, c19, c20)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
"""
add_episode_obj = ["{EpisodeId}", "{FileId}", "{Title}", "{Plot}", "{RatingId}", "{Writers}", "{Premiere}", "{Runtime}",
"{Directors}", "{Season}", "{Index}", "{Title}", "{ShowId}", "{AirsBeforeSeason}",
"{AirsBeforeEpisode}", "{SeasonId}"]
"{AirsBeforeEpisode}", "{SeasonId}", "{FullFilePath}", "{PathId}", "{Unique}"]
add_art = """
INSERT INTO art(media_id, media_type, type, url)
VALUES (?, ?, ?, ?)
"""

update_path_parent_id = """
UPDATE path
SET idParentPath = ?
where idPath = ?
"""

update_path = """
UPDATE path
Expand All @@ -353,9 +358,11 @@
"""
update_path_movie_obj = ["{Path}", "movies", "metadata.local", 1, "{PathId}"]
update_path_toptvshow_obj = ["{TopLevel}", "tvshows", "metadata.local", 1, "{TopPathId}"]
update_path_toptvshow_addon_obj = ["{TopLevel}", None, None, 1, "{TopPathId}"]
update_path_tvshow_obj = ["{Path}", None, None, 1, "{PathId}"]
update_path_episode_obj = ["{Path}", None, None, 1, "{PathId}"]
update_path_mvideo_obj = ["{Path}", "musicvideos", None, 1, "{PathId}"]
update_path_mvideo_obj = ["{Path}", "musicvideos", "metadata.local", 1, "{PathId}"]

update_file = """
UPDATE files
SET idPath = ?, strFilename = ?, dateAdded = ?
Expand Down Expand Up @@ -475,12 +482,13 @@
update_episode = """
UPDATE episode
SET c00 = ?, c01 = ?, c03 = ?, c04 = ?, c05 = ?, c09 = ?, c10 = ?,
c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?, idShow = ?
c12 = ?, c13 = ?, c14 = ?, c15 = ?, c16 = ?, idSeason = ?, idShow = ?,
c18 = ?, c19 = ?, c20 = ?
WHERE idEpisode = ?
"""
update_episode_obj = ["{Title}", "{Plot}", "{RatingId}", "{Writers}", "{Premiere}", "{Runtime}", "{Directors}",
"{Season}", "{Index}", "{Title}", "{AirsBeforeSeason}", "{AirsBeforeEpisode}", "{SeasonId}",
"{ShowId}", "{EpisodeId}"]
"{ShowId}", "{FullFilePath}", "{PathId}", "{Unique}", "{EpisodeId}"]


delete_path = """
Expand Down
37 changes: 35 additions & 2 deletions jellyfin_kodi/objects/tvshows.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,28 @@
self.add_unique_id(*values(obj, QU.add_unique_id_tvshow_obj))

obj['TopPathId'] = self.add_path(obj['TopLevel'])
self.update_path(*values(obj, QU.update_path_toptvshow_obj))

if self.direct_path:
# Normal way, we use the actual top path
self.update_path(*values(obj, QU.update_path_toptvshow_obj))

Check warning on line 175 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L175

Added line #L175 was not covered by tests
else:
# Hack to allow cast information in add-on mode
# We create a path on top of all others that holds mediaType and scrapper
self.update_path(*values(obj, QU.update_path_toptvshow_addon_obj))
temp_obj = dict()
temp_obj['TopLevel'] = 'plugin://plugin.video.jellyfin/'
temp_obj['TopPathId'] = self.add_path(temp_obj['TopLevel'])
self.update_path(*values(temp_obj, QU.update_path_toptvshow_obj))
self.update_path_parent_id(obj['TopPathId'], temp_obj['TopPathId'])

Check warning on line 184 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L179-L184

Added lines #L179 - L184 were not covered by tests

obj['PathId'] = self.add_path(*values(obj, QU.get_path_obj))

self.add(*values(obj, QU.add_tvshow_obj))
self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_tvshow_obj))
LOG.debug("ADD tvshow [%s/%s/%s] %s: %s", obj['TopPathId'], obj['PathId'], obj['ShowId'], obj['Title'], obj['Id'])

self.update_path_parent_id(obj['PathId'], obj['TopPathId'])

Check warning on line 192 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L192

Added line #L192 was not covered by tests

def tvshow_update(self, obj):

''' Update object to kodi.
Expand All @@ -187,10 +201,14 @@
obj['Unique'] = self.get_unique_id(*values(obj, QU.get_unique_id_tvshow_obj))
self.update_unique_id(*values(obj, QU.update_unique_id_tvshow_obj))

obj['TopPathId'] = self.get_path(obj['TopLevel'])

Check warning on line 204 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L204

Added line #L204 was not covered by tests

self.update(*values(obj, QU.update_tvshow_obj))
self.jellyfin_db.update_reference(*values(obj, QUEM.update_reference_obj))
LOG.debug("UPDATE tvshow [%s/%s] %s: %s", obj['PathId'], obj['ShowId'], obj['Title'], obj['Id'])

self.update_path_parent_id(obj['PathId'], obj['TopPathId'])

Check warning on line 210 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L210

Added line #L210 was not covered by tests

def get_path_filename(self, obj):

''' Get the path and build it into protocol://path
Expand All @@ -200,6 +218,9 @@
if '\\' in obj['Path']:
obj['Path'] = "%s\\" % obj['Path']
obj['TopLevel'] = "%s\\" % dirname(dirname(obj['Path']))
elif 'smb://' in obj['Path'] or 'nfs://' in obj['Path']:
obj['Path'] = "%s/" % obj['Path']
obj['TopLevel'] = "%s/" % dirname(dirname(obj['Path']))

Check warning on line 223 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L222-L223

Added lines #L222 - L223 were not covered by tests
else:
obj['Path'] = "%s/" % obj['Path']
obj['TopLevel'] = "plugin://plugin.video.jellyfin/"
Expand Down Expand Up @@ -377,6 +398,12 @@
return self.episode_add(obj)

self.jellyfin_db.add_reference(*values(obj, QUEM.add_reference_episode_obj))

parentPathId = self.jellyfin_db.get_episode_kodi_parent_path_id(*values(obj, QUEM.get_episode_kodi_parent_path_id_obj))

Check warning on line 402 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L402

Added line #L402 was not covered by tests
if obj['PathId'] != parentPathId:
oddstr13 marked this conversation as resolved.
Show resolved Hide resolved
LOG.debug("Setting episode pathParentId, episode %s, title %s, pathId %s, pathParentId %s", obj['Id'], obj['Title'], obj['PathId'], parentPathId)
self.update_path_parent_id(obj['PathId'], parentPathId)

Check warning on line 405 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L404-L405

Added lines #L404 - L405 were not covered by tests

LOG.debug("ADD episode [%s/%s] %s: %s", obj['PathId'], obj['FileId'], obj['Id'], obj['Title'])

def episode_update(self, obj):
Expand Down Expand Up @@ -423,15 +450,21 @@
obj['Filename'] = 'index.bdmv'
LOG.debug("Bluray directory %s", obj['Path'])

obj['FullFilePath'] = obj['Path'] + obj['Filename']

Check warning on line 453 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L453

Added line #L453 was not covered by tests

else:
obj['Path'] = "plugin://plugin.video.jellyfin/%s/" % obj['SeriesId']
# We need LibraryId
library = self.library or find_library(self.server, obj)
obj['LibraryId'] = library['Id']
obj['Path'] = "plugin://plugin.video.jellyfin/%s/%s/" % (obj['LibraryId'], obj['SeriesId'])

Check warning on line 459 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L457-L459

Added lines #L457 - L459 were not covered by tests
params = {
'filename': py2_encode(obj['Filename'], 'utf-8'),
'id': obj['Id'],
'dbid': obj['EpisodeId'],
'mode': "play"
}
obj['Filename'] = "%s?%s" % (obj['Path'], urlencode(params))
obj['FullFilePath'] = obj['Filename']

Check warning on line 467 in jellyfin_kodi/objects/tvshows.py

View check run for this annotation

Codecov / codecov/patch

jellyfin_kodi/objects/tvshows.py#L467

Added line #L467 was not covered by tests

def get_show_id(self, obj):
obj['ShowId'] = self.jellyfin_db.get_item_by_id(*values(obj, QUEM.get_item_series_obj))
Expand Down