Skip to content

Commit

Permalink
Service API: Enhance the Dvr/AllowReRecord method
Browse files Browse the repository at this point in the history
Allow Dvr/AllowReRecord to be called with chanid and start time, so
that recordings that are being prevented by a history entry can be
allowed to record.
  • Loading branch information
bennettpeter committed May 24, 2024
1 parent 2831f67 commit 3d03063
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
40 changes: 30 additions & 10 deletions mythtv/programs/mythbackend/servicesv2/v2dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,18 +720,38 @@ bool V2Dvr::RescheduleRecordings(void)
//
/////////////////////////////////////////////////////////////////////////////

bool V2Dvr::AllowReRecord ( int RecordedId )
bool V2Dvr::AllowReRecord ( int RecordedId, int ChanId, const QDateTime &StartTime)
{
if (RecordedId <= 0)
throw QString("RecordedId param is invalid.");

RecordingInfo ri = RecordingInfo(RecordedId);

if (!ri.GetChanID())
throw QString("RecordedId %1 not found").arg(RecordedId);

ri.ForgetHistory();
if (RecordedId > 0)
{
if (ChanId > 0 || StartTime.isValid())
throw QString("ERROR RecordedId param cannot be used with ChanId or StartTime.");
}
else if (ChanId > 0)
{
if (!StartTime.isValid())
throw QString("ERROR ChanId param requires a valid StartTime.");
}
else
throw QString("ERROR RecordedId or (ChanId and StartTime) required.");

if (RecordedId > 0)
{
RecordingInfo ri = RecordingInfo(RecordedId);
if (!ri.GetChanID())
throw QString("ERROR RecordedId %1 not found").arg(RecordedId);
ri.ForgetHistory();
}
else
{
ProgramInfo *progInfo = LoadProgramFromProgram(ChanId, StartTime);
if (progInfo == nullptr)
throw QString("ERROR Guide data for Chanid %1 at StartTime %2 not found")
.arg(ChanId).arg(StartTime.toString());
RecordingInfo recInfo(*progInfo);
recInfo.ForgetHistory();
delete progInfo;
}
return true;
}

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 @@ -146,7 +146,9 @@ class V2Dvr : public MythHTTPService

static bool RescheduleRecordings( void );

static bool AllowReRecord ( int RecordedId );
static bool AllowReRecord ( int RecordedId,
int ChanId,
const QDateTime &StartTime);

static bool UpdateRecordedWatchedStatus ( int RecordedId,
int ChanId,
Expand Down

0 comments on commit 3d03063

Please sign in to comment.