Skip to content

Commit

Permalink
Services API: Add LastPlayOffset to UpdateRecordedMetadata
Browse files Browse the repository at this point in the history
    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
  • Loading branch information
Bill Meek committed Mar 17, 2024
1 parent 895109d commit abfbd29
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 34 additions & 1 deletion mythtv/programs/mythbackend/servicesv2/v2dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion mythtv/programs/mythbackend/servicesv2/v2dvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit abfbd29

Please sign in to comment.