This commit is contained in:
Rijul 2026-04-24 19:04:03 +02:00 committed by GitHub
commit 1c9b911a66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -104,7 +104,43 @@ class Events(object):
elif mode == "play":
item = api_client.get_item(params["id"])
item["resumePlayback"] = sys.argv[3].split(":")[1] == "true"
timestamp = params.get("timestamp")
# check that timestamp is a float
try:
timestamp = float(timestamp)
except (TypeError, ValueError):
timestamp = None
# a timestamp of 0.0 is false-y so check for None
if timestamp is not None:
is_current = False
player = xbmc.Player()
if player.isPlayingVideo():
try:
playing_file = player.getPlayingFile()
if settings( "useDirectPaths" ) == "0":
is_current = params["id"] in playing_file
else:
queue = json.loads(window("jellyfin_play.json") or "[]")
for p_item in queue:
if p_item.get("Path") == playing_file:
if p_item.get("Id") == params["id"]:
is_current = True
break
if is_current:
player.seekTime(timestamp)
return
except Exception as e:
LOG.debug("Failed to check playing file: %s", e)
item["UserData"] = item.get("UserData", {})
item["UserData"]["PlaybackPositionTicks"] = int(timestamp * 10000000.0)
item["resumePlayback"] = True
else:
try:
item["resumePlayback"] = sys.argv[3].split(":")[1] == "true"
except IndexError:
item["resumePlayback"] = False
Actions(server, api_client).play(
item,
params.get("dbid"),