Skip to content

Commit

Permalink
Service API changes for OldRecorded
Browse files Browse the repository at this point in the history
Changes needed to support Previously Recorded page of web app.
Add 1 field to GetOldRecordedList for status.
ADd Remove and Update methods for OldRecorded.
  • Loading branch information
bennettpeter committed Jan 14, 2025
1 parent b71ff42 commit 8664d73
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 27 deletions.
62 changes: 36 additions & 26 deletions mythtv/libs/libmythbase/programinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,41 @@ QString ProgramInfo::GetProgramFlagNames(void) const
return propsValueToString("program", ProgramFlagNames, m_programFlags);
}


QString ProgramInfo::GetRecTypeStatus(bool showrerecord) const
{
QString tmp_rec = ::toString(GetRecordingRuleType());
if (GetRecordingRuleType() != kNotRecording)
{
QDateTime timeNow = MythDate::current();
if (((m_recEndTs > timeNow) && (m_recStatus <= RecStatus::WillRecord)) ||
(m_recStatus == RecStatus::Conflict) || (m_recStatus == RecStatus::LaterShowing))
{
tmp_rec += QString(" %1%2").arg(m_recPriority > 0 ? "+" : "").arg(m_recPriority);
if (m_recPriority2)
tmp_rec += QString("/%1%2").arg(m_recPriority2 > 0 ? "+" : "").arg(m_recPriority2);
tmp_rec += " ";
}
else
{
tmp_rec += " -- ";
}
if (showrerecord && (GetRecordingStatus() == RecStatus::Recorded) &&
!IsDuplicate())
{
tmp_rec += QObject::tr("Re-Record");
}
else
{
tmp_rec += RecStatus::toString(GetRecordingStatus(), GetRecordingRuleType());
}
}
return tmp_rec;
}




QString ProgramInfo::GetSubtitleTypeNames(void) const
{
return propsValueToString("subtitle", SubtitlePropsNames,
Expand Down Expand Up @@ -1724,32 +1759,7 @@ void ProgramInfo::ToMap(InfoMap &progMap,
// constructor.
progMap["rectypechar"] = toQChar(GetRecordingRuleType());
progMap["rectype"] = ::toString(GetRecordingRuleType());
QString tmp_rec = progMap["rectype"];
if (GetRecordingRuleType() != kNotRecording)
{
if (((m_recEndTs > timeNow) && (m_recStatus <= RecStatus::WillRecord)) ||
(m_recStatus == RecStatus::Conflict) || (m_recStatus == RecStatus::LaterShowing))
{
tmp_rec += QString(" %1%2").arg(m_recPriority > 0 ? "+" : "").arg(m_recPriority);
if (m_recPriority2)
tmp_rec += QString("/%1%2").arg(m_recPriority2 > 0 ? "+" : "").arg(m_recPriority2);
tmp_rec += " ";
}
else
{
tmp_rec += " -- ";
}
if (showrerecord && (GetRecordingStatus() == RecStatus::Recorded) &&
!IsDuplicate())
{
tmp_rec += QObject::tr("Re-Record");
}
else
{
tmp_rec += RecStatus::toString(GetRecordingStatus(), GetRecordingRuleType());
}
}
progMap["rectypestatus"] = tmp_rec;
progMap["rectypestatus"] = GetRecTypeStatus(showrerecord);

progMap["card"] = RecStatus::toString(GetRecordingStatus(), m_inputId);
progMap["input"] = RecStatus::toString(GetRecordingStatus(),
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythbase/programinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ class MBASE_PUBLIC ProgramInfo
ProgramInfoType GetProgramInfoType(void) const
{ return (ProgramInfoType)((m_programFlags & FL_TYPEMASK) >> 20); }
QDateTime GetBookmarkUpdate(void) const { return m_bookmarkUpdate; }
QString GetRecTypeStatus(bool showrerecord) const;
bool IsGeneric(void) const;
bool IsInUsePlaying(void) const { return (m_programFlags & FL_INUSEPLAYING) != 0U;}
bool IsCommercialFree(void) const { return (m_programFlags & FL_CHANCOMMFREE) != 0U;}
Expand Down
65 changes: 64 additions & 1 deletion mythtv/programs/mythbackend/servicesv2/v2dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ V2ProgramList* V2Dvr::GetRecordedList( bool bDescending,
}

/////////////////////////////////////////////////////////////////////////////
//
// Note that you should not specify both Title and TitleRegEx, that is counter-
// productive and would only work if the TitleRegEx matched the Title.
/////////////////////////////////////////////////////////////////////////////

V2ProgramList* V2Dvr::GetOldRecordedList( bool bDescending,
Expand All @@ -261,6 +262,7 @@ V2ProgramList* V2Dvr::GetOldRecordedList( bool bDescending,
const QDateTime &sStartTime,
const QDateTime &sEndTime,
const QString &sTitle,
const QString &TitleRegEx,
const QString &sSeriesId,
int nRecordId,
const QString &sSort)
Expand Down Expand Up @@ -311,6 +313,12 @@ V2ProgramList* V2Dvr::GetOldRecordedList( bool bDescending,
bindings[":Title"] = sTitle;
}

if (!TitleRegEx.isEmpty())
{
clause << "title REGEXP :TitleRegEx";
bindings[":TitleRegEx"] = TitleRegEx;
}

if (!sSeriesId.isEmpty())
{
clause << "seriesid = :SeriesId";
Expand Down Expand Up @@ -368,6 +376,61 @@ V2ProgramList* V2Dvr::GetOldRecordedList( bool bDescending,
return pPrograms;
}

bool V2Dvr::RemoveOldRecorded ( int ChanId,
const QDateTime &StartTime,
bool Reschedule )
{
if (!HAS_PARAMv2("ChanId") || !HAS_PARAMv2("StartTime"))
throw QString("Channel ID and StartTime appears invalid.");
QString sql("DELETE FROM oldrecorded "
" WHERE chanid = :ChanId AND starttime = :StartTime" );
MSqlQuery query(MSqlQuery::InitCon());
query.prepare(sql);
query.bindValue(":ChanId", ChanId);
query.bindValue(":StartTime", StartTime);
if (!query.exec())
{
MythDB::DBError("RemoveOldRecorded", query);
return false;
}
if (query.numRowsAffected() <= 0)
return false;
if (!HAS_PARAMv2("Reschedule"))
Reschedule = true;
if (Reschedule)
RescheduleRecordings();
return true;
}

bool V2Dvr::UpdateOldRecorded ( int ChanId,
const QDateTime &StartTime,
bool Duplicate,
bool Reschedule )
{
if (!HAS_PARAMv2("ChanId") || !HAS_PARAMv2("StartTime"))
throw QString("Channel ID and StartTime appears invalid.");
if (!HAS_PARAMv2("Duplicate"))
throw QString("Error: Nothing to change.");
QString sql("UPDATE oldrecorded "
" SET Duplicate = :Duplicate "
" WHERE chanid = :ChanId AND starttime = :StartTime" );
MSqlQuery query(MSqlQuery::InitCon());
query.prepare(sql);
query.bindValue(":Duplicate", Duplicate);
query.bindValue(":ChanId", ChanId);
query.bindValue(":StartTime", StartTime);
if (!query.exec())
{
MythDB::DBError("UpdateOldRecorded", query);
return false;
}
if (!HAS_PARAMv2("Reschedule"))
Reschedule = true;
if (Reschedule)
RescheduleRecordings();
return true;
}

/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 12 additions & 0 deletions mythtv/programs/mythbackend/servicesv2/v2dvr.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class V2Dvr : public MythHTTPService
{
Q_OBJECT
Q_CLASSINFO("Version", "7.1")
Q_CLASSINFO("RemoveOldRecorded", "methods=POST;name=bool")
Q_CLASSINFO("UpdateOldRecorded", "methods=POST;name=bool")
Q_CLASSINFO("AddRecordedCredits", "methods=POST;name=bool")
Q_CLASSINFO("AddRecordedProgram", "methods=POST;name=int")
Q_CLASSINFO("RemoveRecorded", "methods=POST;name=bool")
Expand Down Expand Up @@ -118,10 +120,20 @@ class V2Dvr : public MythHTTPService
const QDateTime &StartTime,
const QDateTime &EndTime,
const QString &Title,
const QString &TitleRegEx,
const QString &SeriesId,
int RecordId,
const QString &Sort);

bool RemoveOldRecorded ( int ChanId,
const QDateTime &StartTime,
bool Reschedule );

bool UpdateOldRecorded ( int ChanId,
const QDateTime &StartTime,
bool Duplicate,
bool Reschedule );

static V2Program* GetRecorded ( int RecordedId,
int ChanId,
const QDateTime &StartTime );
Expand Down
1 change: 1 addition & 0 deletions mythtv/programs/mythbackend/servicesv2/v2recording.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class V2RecordingInfo : public QObject
SERVICE_PROPERTY2( uint , RecordedId )
SERVICE_PROPERTY2( int , Status )
SERVICE_PROPERTY2( RecStatus::Type , StatusName )
SERVICE_PROPERTY2( QString , RecTypeStatus )
SERVICE_PROPERTY2( int , Priority )
SERVICE_PROPERTY2( QDateTime , StartTs )
SERVICE_PROPERTY2( QDateTime , EndTs )
Expand Down
1 change: 1 addition & 0 deletions mythtv/programs/mythbackend/servicesv2/v2serviceUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ void V2FillProgramInfo( V2Program *pProgram,
pRecording->setRecordedId ( pRecInfo.GetRecordingID() );
pRecording->setStatus ( pRecInfo.GetRecordingStatus() );
pRecording->setStatusName ( pRecInfo.GetRecordingStatus() );
pRecording->setRecTypeStatus ( pRecInfo.GetRecTypeStatus(true) );
pRecording->setPriority( pRecInfo.GetRecordingPriority() );
pRecording->setStartTs ( pRecInfo.GetRecordingStartTime() );
pRecording->setEndTs ( pRecInfo.GetRecordingEndTime() );
Expand Down

0 comments on commit 8664d73

Please sign in to comment.