From abfbd2914f2b08e3368fa77c0578d7d326295a0b Mon Sep 17 00:00:00 2001 From: Bill Meek Date: Sun, 17 Mar 2024 18:20:18 -0500 Subject: [PATCH] Services API: Add LastPlayOffset to UpdateRecordedMetadata Dvr/UpdateRecordedMetadata with one or two parameters e.g.: LastPlayOffset=60000 LastPlayOffsetType=Duration (or Position) LastPlayOffsetType is optional. If LastPlayOffset=-1, then an error fires like Dvr::SetLastPlayPos --- .../programs/mythbackend/servicesv2/v2dvr.cpp | 35 ++++++++++++++++++- .../programs/mythbackend/servicesv2/v2dvr.h | 4 ++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/mythtv/programs/mythbackend/servicesv2/v2dvr.cpp b/mythtv/programs/mythbackend/servicesv2/v2dvr.cpp index 91ecbd5783d..f7e68ac01b4 100644 --- a/mythtv/programs/mythbackend/servicesv2/v2dvr.cpp +++ b/mythtv/programs/mythbackend/servicesv2/v2dvr.cpp @@ -901,6 +901,8 @@ bool V2Dvr::SetLastPlayPos( int RecordedId, const QString &offsettype, long Offset ) { + LOG(VB_GENERAL, LOG_WARNING, "Deprecated, use Dvr/UpdateRecordedMetadata."); + if ((RecordedId <= 0) && (chanid <= 0 || !StartTime.isValid())) throw QString("Recorded ID or Channel ID and StartTime appears invalid."); @@ -2125,7 +2127,9 @@ bool V2Dvr::UpdateRecordedMetadata ( uint RecordedId, const QString &Description, uint Episode, const QString &Inetref, - QDate OriginalAirDate, + long LastPlayOffset, + const QString &LastPlayOffsetType, + QDate OriginalAirDate, bool Preserve, uint Season, uint Stars, @@ -2223,6 +2227,35 @@ bool V2Dvr::UpdateRecordedMetadata ( uint RecordedId, if (HAS_PARAMv2("Inetref")) pi.SaveInetRef(Inetref); + if (HAS_PARAMv2("LastPlayOffset")) + { + + if (LastPlayOffset < 0) + throw QString("LastPlayOffset must be >= 0."); + + uint64_t position = LastPlayOffset; + bool isend=true; + + if (HAS_PARAMv2("LastPlayOffsetType")) + { + if (LastPlayOffsetType.toLower() == "position") + { + if (!ri.QueryPositionKeyFrame(&position, LastPlayOffset, isend)) + return false; + } + else if (LastPlayOffsetType.toLower() == "duration") + { + if (!ri.QueryDurationKeyFrame(&position, LastPlayOffset, isend)) + return false; + } + } + + ri.SaveLastPlayPos(position); + + return true; + + } + if (HAS_PARAMv2("OriginalAirDate")) { // OriginalAirDate can be set to null by submitting value 'null' in json diff --git a/mythtv/programs/mythbackend/servicesv2/v2dvr.h b/mythtv/programs/mythbackend/servicesv2/v2dvr.h index edfd3b3c25c..d07dd99cb37 100644 --- a/mythtv/programs/mythbackend/servicesv2/v2dvr.h +++ b/mythtv/programs/mythbackend/servicesv2/v2dvr.h @@ -375,7 +375,9 @@ class V2Dvr : public MythHTTPService const QString &Description, uint Episode, const QString &Inetref, - QDate OriginalAirDate, + long LastPlayOffset, + const QString &LastPlayOffsetType, + QDate OriginalAirDate, bool Preserve, uint Season, uint Stars,