Skip to content

Commit

Permalink
Fix some confusion over the behaviour/purpose of IsSameProgram
Browse files Browse the repository at this point in the history
Creates a new method similar to IsSameProgram called
IsDuplicateProgram which is purely used for scheduling purposes.

The issue seems to be that IsSameProgram() doesn't do what it appears
it should. Places using it assume that it will match two
programs which are identical - same content - but it's been modified
over time to serve the definition of a 'duplicate' for scheduling
purposes. This means, among other things, that if the duplicate check
method is 'None', then IsSameProgram will return false given two
identical programs.
  • Loading branch information
stuartm committed Apr 26, 2014
1 parent e469043 commit 7fd0a20
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
61 changes: 60 additions & 1 deletion mythtv/libs/libmyth/programinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ bool ProgramInfo::IsSameProgramWeakCheck(const ProgramInfo &other) const
* \brief Checks for duplicates according to dupmethod.
* \param other ProgramInfo to compare this one with.
*/
bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
bool ProgramInfo::IsDuplicateProgram(const ProgramInfo& other) const
{
if (GetRecordingRuleType() == kOneRecord)
return recordid == other.recordid;
Expand Down Expand Up @@ -2114,6 +2114,65 @@ bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
return true;
}

/**
* \brief Checks whether this is the same program as "other", which may or may
* not be a repeat or on another channel. Matches based on programid
* with a fallback to dupmethod
* \param other ProgramInfo to compare this one with.
*/
bool ProgramInfo::IsSameProgram(const ProgramInfo& other) const
{
if (title.compare(other.title, Qt::CaseInsensitive) != 0)
return false;

if (!programid.isEmpty() && !other.programid.isEmpty())
{
if (catType == kCategorySeries)
{
if (programid.endsWith("0000"))
return false;
}

if (usingProgIDAuth)
{
int index = programid.indexOf('/');
int oindex = other.programid.indexOf('/');
if (index == oindex && (index < 0 ||
programid.leftRef(index) == other.programid.leftRef(oindex)))
return programid == other.programid;
}
else
{
return programid == other.programid;
}
}

if ((dupmethod & kDupCheckSub) &&
((subtitle.isEmpty()) ||
(subtitle.compare(other.subtitle, Qt::CaseInsensitive) != 0)))
return false;

if ((dupmethod & kDupCheckDesc) &&
((description.isEmpty()) ||
(description.compare(other.description, Qt::CaseInsensitive) != 0)))
return false;

if ((dupmethod & kDupCheckSubThenDesc) &&
((subtitle.isEmpty() &&
((!other.subtitle.isEmpty() &&
description.compare(other.subtitle, Qt::CaseInsensitive) != 0) ||
(other.subtitle.isEmpty() &&
description.compare(other.description, Qt::CaseInsensitive) != 0))) ||
(!subtitle.isEmpty() &&
((other.subtitle.isEmpty() &&
subtitle.compare(other.description, Qt::CaseInsensitive) != 0) ||
(!other.subtitle.isEmpty() &&
subtitle.compare(other.subtitle, Qt::CaseInsensitive) != 0)))))
return false;

return true;
}

/**
* \brief Match same program, with same starttime (channel may be different)
* \param other ProgramInfo to compare this one with.
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmyth/programinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ class MPUBLIC ProgramInfo
virtual void SubstituteMatches(QString &str);

// Used for scheduling recordings
bool IsSameProgram(const ProgramInfo &other) const;
bool IsSameProgram(const ProgramInfo &other) const; // Exact same program
bool IsDuplicateProgram(const ProgramInfo &other) const; // Is this program considered a duplicate according to rule type and dup method (scheduler only)
bool IsSameProgramAndStartTime(const ProgramInfo &other) const; // Exact same program and same starttime, Any channel
bool IsSameTitleStartTimeAndChannel(const ProgramInfo &other) const; // Same title, starttime and channel
bool IsSameTitleTimeslotAndChannel(const ProgramInfo &other) const;//sched only - Same title, starttime, endtime and channel
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in ABI changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods in exported headers.
#define MYTH_BINARY_VERSION "0.28.20140327-1"
#define MYTH_BINARY_VERSION "0.28.20140426-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
2 changes: 1 addition & 1 deletion mythtv/programs/mythbackend/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ bool Scheduler::IsSameProgram(
if (it != cache_is_same_program.end())
return *it;

return cache_is_same_program[X] = a->IsSameProgram(*b);
return cache_is_same_program[X] = a->IsDuplicateProgram(*b);
}

bool Scheduler::FindNextConflict(
Expand Down

0 comments on commit 7fd0a20

Please sign in to comment.