From 98a7ace54103c27c0c56e74c60285aaa38e0bd20 Mon Sep 17 00:00:00 2001
From: fezster <97789007+fezster@users.noreply.github.com>
Date: Thu, 4 Jan 2024 16:39:51 +0000
Subject: [PATCH] Pass HDR library metadata to kodi to display logos

Fix indentation error

Update actions.py

Update api.py
---
 jellyfin_kodi/helper/api.py           | 13 +++++++++++++
 jellyfin_kodi/objects/actions.py      |  1 +
 jellyfin_kodi/objects/kodi/queries.py |  6 +++---
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/jellyfin_kodi/helper/api.py b/jellyfin_kodi/helper/api.py
index ea8e9ee9..5ae68eda 100644
--- a/jellyfin_kodi/helper/api.py
+++ b/jellyfin_kodi/helper/api.py
@@ -73,7 +73,20 @@ class API(object):
 
         for track in tracks:
 
+            if "DvProfile" in track:
+                track['hdrtype'] = "dolbyvision"
+			
+            elif track['VideoRangeType'] in ["HDR10", "HDR10Plus"]:
+                track['hdrtype'] = "hdr10"
+
+            elif "HLG" in track['VideoRangeType']:
+                track['hdrtype'] = "hlg"
+			
+            elif track['VideoRangeType'] in ["SDR", "Unknown"]:
+                track['hdrtype'] = ""
+
             track.update({
+                'hdrtype': track.get('hdrtype', "").lower(),
                 'codec': track.get('Codec', "").lower(),
                 'profile': track.get('Profile', "").lower(),
                 'height': track.get('Height'),
diff --git a/jellyfin_kodi/objects/actions.py b/jellyfin_kodi/objects/actions.py
index 06a73d55..34760167 100644
--- a/jellyfin_kodi/objects/actions.py
+++ b/jellyfin_kodi/objects/actions.py
@@ -455,6 +455,7 @@ class Actions(object):
 
             for track in obj['Streams']['video']:
                 listitem.addStreamInfo('video', {
+                    'hdrtype': track['hdrtype'],
                     'duration': obj['Runtime'],
                     'aspect': track['aspect'],
                     'codec': track['codec'],
diff --git a/jellyfin_kodi/objects/kodi/queries.py b/jellyfin_kodi/objects/kodi/queries.py
index 71459e2c..e142f306 100644
--- a/jellyfin_kodi/objects/kodi/queries.py
+++ b/jellyfin_kodi/objects/kodi/queries.py
@@ -258,10 +258,10 @@ add_bookmark_obj = ["{FileId}", "{PlayCount}", "{DatePlayed}", "{Resume}", "{Run
 add_streams_obj = ["{FileId}", "{Streams}", "{Runtime}"]
 add_stream_video = """
 INSERT INTO     streamdetails(idFile, iStreamType, strVideoCodec, fVideoAspect, iVideoWidth,
-                iVideoHeight, iVideoDuration, strStereoMode)
-VALUES          (?, ?, ?, ?, ?, ?, ?, ?)
+                iVideoHeight, iVideoDuration, strStereoMode, strHdrType)
+VALUES          (?, ?, ?, ?, ?, ?, ?, ?, ?)
 """
-add_stream_video_obj = ["{FileId}", 0, "{codec}", "{aspect}", "{width}", "{height}", "{Runtime}", "{3d}"]
+add_stream_video_obj = ["{FileId}", 0, "{codec}", "{aspect}", "{width}", "{height}", "{Runtime}", "{3d}", "{hdrtype}"]
 add_stream_audio = """
 INSERT INTO     streamdetails(idFile, iStreamType, strAudioCodec, iAudioChannels, strAudioLanguage)
 VALUES          (?, ?, ?, ?, ?)