Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MythMetadataLookup: Copy recording rule inetrefs to recordings.
If a mass update is run (--refresh-all, --refresh-all-rules, or no arguments), attempt to populate inetrefs bidirectionally.

With --refresh-all, see if a inetref'less program's recording rule has an inetref.  If it does, copy it across before performing a lookup.

With --refresh-all-rules, after looking up the rules themselves, copy newly-found inetrefs to the affected recordings.
  • Loading branch information
Robert McNamara committed Jul 11, 2011
1 parent ecfc2ba commit 6443825
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
32 changes: 32 additions & 0 deletions mythtv/programs/mythmetadatalookup/lookup.cpp
Expand Up @@ -104,6 +104,38 @@ void LookerUpper::HandleAllRecordingRules()
}
}

void LookerUpper::CopyRuleInetrefsToRecordings()
{
QMap< QString, ProgramInfo* > recMap;
QMap< QString, uint32_t > inUseMap = ProgramInfo::QueryInUseMap();
QMap< QString, bool > isJobRunning = ProgramInfo::QueryJobsRunning(JOB_COMMFLAG);

ProgramList progList;

LoadFromRecorded( progList, false, inUseMap, isJobRunning, recMap, -1 );

for( int n = 0; n < (int)progList.size(); n++)
{
ProgramInfo *pginfo = new ProgramInfo(*(progList[n]));
if (pginfo && pginfo->GetInetRef().isEmpty())
{
RecordingRule *rule = new RecordingRule();
rule->LoadByProgram(pginfo);
if (rule && rule->Load() && !rule->m_inetref.isEmpty())
{
QString msg = QString("%1").arg(pginfo->GetTitle());
if (!pginfo->GetSubtitle().isEmpty())
msg += QString(": %1").arg(pginfo->GetSubtitle());
msg += " has no inetref, but its recording rule does. Copying...";
LOG(VB_GENERAL, LOG_INFO, msg);
pginfo->SaveInetRef(rule->m_inetref);
delete rule;
}
delete pginfo;
}
}
}

void LookerUpper::customEvent(QEvent *levent)
{
if (levent->type() == MetadataFactoryMultiResult::kEventType)
Expand Down
2 changes: 2 additions & 0 deletions mythtv/programs/mythmetadatalookup/lookup.h
Expand Up @@ -21,6 +21,8 @@ class LookerUpper : public QObject
void HandleAllRecordings(bool updaterules = false);
void HandleAllRecordingRules(void);

void CopyRuleInetrefsToRecordings();

private:
void customEvent(QEvent *event);

Expand Down
14 changes: 12 additions & 2 deletions mythtv/programs/mythmetadatalookup/main.cpp
Expand Up @@ -45,14 +45,18 @@ void MythMetadataLookupCommandLineParser::LoadArguments(void)
addLogging();

add("--refresh-all", "refresh-all", false,
"Batch update recorded program metadata.", "");
"Batch update recorded program metadata. If a recording's "
"rule has an inetref but the recording does not, it will "
"be inherited.", "");
add("--refresh-rules", "refresh-rules", false,
"Also update inetref for recording rules when metadata is "
"found for a recording (Best effort only, imperfect)", "");
add("--refresh-all-rules", "refresh-all-rules", false,
"Batch update metadata for recording rules. This will "
"set inetrefs for your recording rules based on an automated "
"lookup. This is a best effort, and not guaranteed!", "");
"lookup. This is a best effort, and not guaranteed! If your "
"recordings lack inetrefs but one is found for the rule, it "
"will be inherited.", "");
}

int main(int argc, char *argv[])
Expand Down Expand Up @@ -155,9 +159,15 @@ int main(int argc, char *argv[])
}

if (refreshall)
{
lookup->CopyRuleInetrefsToRecordings();
lookup->HandleAllRecordings(refreshrules);
}
else if (refreshallrules)
{
lookup->HandleAllRecordingRules();
lookup->CopyRuleInetrefsToRecordings();
}
else
lookup->HandleSingleRecording(chanid, starttime, refreshrules);

Expand Down

0 comments on commit 6443825

Please sign in to comment.