Skip to content

Commit 2417198

Browse files
authored
Fix Kodi methods deprecations as of 04.2025 (#31)
1 parent 97bd214 commit 2417198

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

context_info.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
"ListItem.PercentPlayed",
6565
]
6666

67+
build_version = xbmc.getInfoLabel("System.BuildVersion")
68+
kodi_version = int(build_version.split()[0][:2])
69+
6770
if __name__ == '__main__':
6871
item = sys.listitem # xbmcgui.ListItem()
6972
try:
@@ -75,15 +78,15 @@
7578
dbid = xbmc.getInfoLabel('ListItem.DBID')
7679
mediatype = xbmc.getInfoLabel('ListItem.DBTYPE')
7780
try:
78-
tmdbID = item.getUniqueID('tmdb')
81+
tmdbID = item.getUniqueID('tmdb') if kodi_version < 20 else item.getVideoInfoTag().getUniqueID('tmdb')
7982
except AttributeError:
8083
tmdbID = "not supported"
8184

8285
properties = {
83-
'resume_time': item.getProperty('ResumeTime'),
86+
'resume_time': item.getProperty('ResumeTime') if kodi_version < 20 else item.getVideoInfoTag().getResumeTime(),
87+
'total_time': item.getProperty('TotalTime') if kodi_version < 20 else item.getVideoInfoTag().getResumeTimeTotal(),
8488
'start_offset': item.getProperty('StartOffset'),
8589
'start_percent': item.getProperty('StartPercent'),
86-
'total_time': item.getProperty('TotalTime')
8790
}
8891
log.info("Properties: %s;" % properties)
8992

plugin.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
ADDON = xbmcaddon.Addon()
3131
api_key = ""
3232

33+
build_version = xbmc.getInfoLabel("System.BuildVersion")
34+
kodi_version = int(build_version.split()[0][:2])
35+
3336

3437
def doAssign():
3538
mediatype = getMediaType()
@@ -42,7 +45,7 @@ def doAssign():
4245
use_elementum_path = False
4346

4447
try:
45-
tmdbID = sys.listitem.getUniqueID('tmdb')
48+
tmdbID = sys.listitem.getUniqueID('tmdb') if kodi_version < 20 else sys.listitem.getVideoInfoTag().getUniqueID('tmdb')
4649
except AttributeError:
4750
tmdbID = ""
4851

@@ -175,7 +178,7 @@ def doPlayDownload(action, is_custom=False):
175178
def doLibraryAction(action):
176179
dbid = getDbId()
177180
try:
178-
tmdbID = sys.listitem.getUniqueID('tmdb')
181+
tmdbID = sys.listitem.getUniqueID('tmdb') if kodi_version < 20 else sys.listitem.getVideoInfoTag().getUniqueID('tmdb')
179182
except AttributeError:
180183
tmdbID = ""
181184
mediatype = getMediaType()
@@ -208,7 +211,7 @@ def doTraktAction(action):
208211
if not dbid.isdigit():
209212
showtmdbid = xbmc.getInfoLabel('ListItem.Property(ShowTMDBId)')
210213
try:
211-
tmdbID = sys.listitem.getUniqueID('tmdb')
214+
tmdbID = sys.listitem.getUniqueID('tmdb') if kodi_version < 20 else sys.listitem.getVideoInfoTag().getUniqueID('tmdb')
212215
except AttributeError:
213216
tmdbID = ""
214217
if tmdbID == "" or ((mediatype == 'season' or mediatype == 'episode') and showtmdbid == ""):

0 commit comments

Comments
 (0)