Skip to content

Commit

Permalink
Tweak the Get[Filtered]RecordedList() services API calls.
Browse files Browse the repository at this point in the history
Change GetRecordedList() to return recordings from the Deleted group.
This is consistent with the equivalent Myth protocol functionality.
Remove GetFilteredRecordedList() and add the optional filter
parameters to GetRecordedList().  They already used the same function
internally.
  • Loading branch information
gigem committed Jul 1, 2013
1 parent 4885845 commit 0254ef8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 89 deletions.
2 changes: 1 addition & 1 deletion mythtv/html/samples/hlstest.qsp
Expand Up @@ -262,7 +262,7 @@ function listRecordings() {
var recgroup = $("#recGroup").val();

$("#links").html("<i18n>Loading</i18n>...");
$.getJSON("/Dvr/GetFilteredRecordedList",
$.getJSON("/Dvr/GetRecordedList",
{ Descending: 1, StartIndex: 0, Count: 20000,
RecGroup: recgroup },
function(data) {
Expand Down
2 changes: 1 addition & 1 deletion mythtv/html/samples/livestream_rec.qsp
Expand Up @@ -142,7 +142,7 @@ function listFiles() {
var group = $("#rgName").val();
var filter = $("#rgFilter").val().toLowerCase();
$("#links").html("<i18n>Loading</i18n>...");
$.getJSON("/Dvr/GetFilteredRecordedList", { Descending: "1", StartIndex: "1", Count: "2000", TitleRegEx : filter, RecGroup : group }, function(data) {
$.getJSON("/Dvr/GetRecordedList", { Descending: "1", StartIndex: "1", Count: "2000", TitleRegEx : filter, RecGroup : group }, function(data) {
$("#links").html("");
var str = "<hr><form id='playform'>";
str += "Width: <select name='Width'>" +
Expand Down
14 changes: 5 additions & 9 deletions mythtv/libs/libmythservicecontracts/services/dvrServices.h
Expand Up @@ -39,7 +39,7 @@
class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???
{
Q_OBJECT
Q_CLASSINFO( "version" , "1.8" );
Q_CLASSINFO( "version" , "1.9" );
Q_CLASSINFO( "RemoveRecordedItem_Method", "POST" )
Q_CLASSINFO( "AddRecordSchedule_Method", "POST" )
Q_CLASSINFO( "RemoveRecordSchedule_Method", "POST" )
Expand Down Expand Up @@ -67,14 +67,10 @@ class SERVICE_PUBLIC DvrServices : public Service //, public QScriptable ???

virtual DTC::ProgramList* GetRecordedList ( bool Descending,
int StartIndex,
int Count ) = 0;

virtual DTC::ProgramList* GetFilteredRecordedList ( bool Descending,
int StartIndex,
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup ) = 0;
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup ) = 0;

virtual DTC::Program* GetRecorded ( int ChanId,
const QDateTime &StartTime ) = 0;
Expand Down
79 changes: 23 additions & 56 deletions mythtv/programs/mythbackend/services/dvr.cpp
Expand Up @@ -49,20 +49,12 @@ extern AutoExpire *expirer;
//
/////////////////////////////////////////////////////////////////////////////

DTC::ProgramList* Dvr::GetRecordedList( bool bDescending,
int nStartIndex,
int nCount )
{
return GetFilteredRecordedList( bDescending, nStartIndex, nCount,
QString(), QString(), QString() );
}

DTC::ProgramList* Dvr::GetFilteredRecordedList( bool bDescending,
int nStartIndex,
int nCount,
const QString &sTitleRegEx,
const QString &sRecGroup,
const QString &sStorageGroup )
DTC::ProgramList* Dvr::GetRecordedList( bool bDescending,
int nStartIndex,
int nCount,
const QString &sTitleRegEx,
const QString &sRecGroup,
const QString &sStorageGroup )
{
QMap< QString, ProgramInfo* > recMap;

Expand Down Expand Up @@ -92,58 +84,33 @@ DTC::ProgramList* Dvr::GetFilteredRecordedList( bool bDescending,
DTC::ProgramList *pPrograms = new DTC::ProgramList();
int nAvailable = 0;

if ((sTitleRegEx.isEmpty()) &&
(sRecGroup.isEmpty()) &&
(sStorageGroup.isEmpty()))
{
nStartIndex = min( nStartIndex, (int)progList.size() );
nCount = (nCount > 0) ? min( nCount, (int)progList.size() ) : progList.size();
int nEndIndex = min((nStartIndex + nCount), (int)progList.size() );
nCount = nEndIndex - nStartIndex;
int nMax = (nCount > 0) ? nCount : progList.size();

nAvailable = progList.size();
nAvailable = 0;
nCount = 0;

for( int n = nStartIndex; n < nEndIndex; n++)
{
ProgramInfo *pInfo = progList[ n ];
if (pInfo->GetRecordingGroup() != "Deleted")
{
DTC::Program *pProgram = pPrograms->AddNewProgram();
QRegExp rTitleRegEx = QRegExp(sTitleRegEx, Qt::CaseInsensitive);

FillProgramInfo( pProgram, pInfo, true );
}
}
}
else
for( unsigned int n = 0; n < progList.size(); n++)
{
int nMax = (nCount > 0) ? nCount : progList.size();
ProgramInfo *pInfo = progList[ n ];

nAvailable = 0;
nCount = 0;
if ((!sTitleRegEx.isEmpty() && !pInfo->GetTitle().contains(rTitleRegEx)) ||
(!sRecGroup.isEmpty() && sRecGroup != pInfo->GetRecordingGroup()) ||
(!sStorageGroup.isEmpty() && sStorageGroup != pInfo->GetStorageGroup()))
continue;

QRegExp rTitleRegEx = QRegExp(sTitleRegEx, Qt::CaseInsensitive);
++nAvailable;

for( unsigned int n = 0; n < progList.size(); n++)
{
ProgramInfo *pInfo = progList[ n ];

if ((!sTitleRegEx.isEmpty() && !pInfo->GetTitle().contains(rTitleRegEx)) ||
(!sRecGroup.isEmpty() && sRecGroup != pInfo->GetRecordingGroup()) ||
(!sStorageGroup.isEmpty() && sStorageGroup != pInfo->GetStorageGroup()))
continue;

++nAvailable;
if ((nAvailable < nStartIndex) ||
(nCount >= nMax))
continue;

if ((nAvailable < nStartIndex) ||
(nCount >= nMax))
continue;
++nCount;

++nCount;

DTC::Program *pProgram = pPrograms->AddNewProgram();
DTC::Program *pProgram = pPrograms->AddNewProgram();

FillProgramInfo( pProgram, pInfo, true );
}
FillProgramInfo( pProgram, pInfo, true );
}

// ----------------------------------------------------------------------
Expand Down
33 changes: 11 additions & 22 deletions mythtv/programs/mythbackend/services/dvr.h
Expand Up @@ -45,14 +45,10 @@ class Dvr : public DvrServices

DTC::ProgramList* GetRecordedList ( bool Descending,
int StartIndex,
int Count );

DTC::ProgramList* GetFilteredRecordedList ( bool Descending,
int StartIndex,
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup );
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup );

DTC::Program* GetRecorded ( int ChanId,
const QDateTime &StartTime );
Expand Down Expand Up @@ -214,21 +210,14 @@ class ScriptableDvr : public QObject

QObject* GetRecordedList ( bool Descending,
int StartIndex,
int Count )
{
return m_obj.GetRecordedList( Descending, StartIndex, Count );
}

QObject* GetFilteredRecordedList ( bool Descending,
int StartIndex,
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup)
int Count,
const QString &TitleRegEx,
const QString &RecGroup,
const QString &StorageGroup)
{
return m_obj.GetFilteredRecordedList( Descending, StartIndex, Count,
TitleRegEx, RecGroup,
StorageGroup);
return m_obj.GetRecordedList( Descending, StartIndex, Count,
TitleRegEx, RecGroup,
StorageGroup);
}

QObject* GetRecorded ( int ChanId,
Expand Down

0 comments on commit 0254ef8

Please sign in to comment.