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->m_recordID = pginfo->GetRecordingRuleID(); rule->Load(); if (!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; } }
DTC::RecRule* Dvr::GetRecordSchedule( uint nRecordId, QString sTemplate, int nRecordedId, int nChanId, QDateTime dStartTimeRaw, bool bMakeOverride ) { RecordingRule rule; QDateTime dStartTime = dStartTimeRaw.toUTC(); if (nRecordId > 0) { rule.m_recordID = nRecordId; if (!rule.Load()) throw QString("Record ID does not exist."); } else if (!sTemplate.isEmpty()) { if (!rule.LoadTemplate(sTemplate)) throw QString("Template does not exist."); } else if (nRecordedId > 0) // Loads from the Recorded/Recorded Program Table { // Despite the use of ProgramInfo, this only applies to Recordings. ProgramInfo recInfo(nRecordedId); if (!rule.LoadByProgram(&recInfo)) throw QString("Recording does not exist"); } else if (nChanId > 0 && dStartTime.isValid()) // Loads from Program Table, should NOT be used with recordings { // Despite the use of RecordingInfo, this only applies to programs in the // present or future, not to recordings? Confused yet? RecordingInfo::LoadStatus status; RecordingInfo info(nChanId, dStartTime, false, 0, &status); if (status != RecordingInfo::kFoundProgram) throw QString("Program does not exist."); RecordingRule *pRule = info.GetRecordingRule(); if (bMakeOverride && rule.m_type != kSingleRecord && rule.m_type != kOverrideRecord && rule.m_type != kDontRecord) pRule->MakeOverride(); rule = *pRule; } else { throw QString("Invalid request."); } DTC::RecRule *pRecRule = new DTC::RecRule(); FillRecRuleInfo( pRecRule, &rule ); return pRecRule; }
DTC::RecRule* Dvr::GetRecordSchedule( uint nRecordId ) { if (nRecordId <= 0 ) throw( QString("Record ID appears invalid.")); RecordingRule *pRule = new RecordingRule(); pRule->m_recordID = nRecordId; pRule->Load(); DTC::RecRule *pRecRule = new DTC::RecRule(); FillRecRuleInfo( pRecRule, pRule ); return pRecRule; }
LookupType GuessLookupType(ProgramInfo *pginfo) { LookupType ret = GuessLookupType(pginfo->GetInetRef()); if (ret != kUnknownVideo) return ret; ProgramInfo::CategoryType catType = pginfo->GetCategoryType(); if (catType == ProgramInfo::kCategoryNone) catType = pginfo->QueryCategoryType(); if ((!pginfo->GetSubtitle().isEmpty() || pginfo->GetEpisode() > 0) && (catType == ProgramInfo::kCategorySeries || catType == ProgramInfo::kCategoryTVShow)) ret = kProbableTelevision; else if (catType == ProgramInfo::kCategoryMovie) ret = kProbableMovie; else if (pginfo->GetSeason() > 0 || pginfo->GetEpisode() > 0 || !pginfo->GetSubtitle().isEmpty()) ret = kProbableTelevision; else { // Before committing to something being a movie, we // want to check its rule. If the rule has a season // or episode number, but the recording doesn't, // and the rec doesn't have a subtitle, this is a // generic recording. If neither the rule nor the // recording have an inetref, season, episode, or // subtitle, it's *probably* a movie. If it's some // weird combination of both, we've got to try everything. RecordingRule *rule = new RecordingRule(); rule->m_recordID = pginfo->GetRecordingRuleID(); rule->Load(); int ruleepisode = rule->m_episode; delete rule; if (ruleepisode == 0 && pginfo->GetEpisode() == 0 && pginfo->GetSubtitle().isEmpty()) ret = kProbableMovie; else if (ruleepisode > 0 && pginfo->GetSubtitle().isEmpty()) ret = kProbableGenericTelevision; else ret = kUnknownVideo; } return ret; }
bool Dvr::DisableRecordSchedule( uint nRecordId ) { bool bResult = false; if (nRecordId <= 0 ) throw QString("Record ID appears invalid."); RecordingRule pRule; pRule.m_recordID = nRecordId; pRule.Load(); if (pRule.IsLoaded()) { pRule.m_isInactive = true; bResult = pRule.Save(); } return bResult; }
DTC::RecRule* Dvr::GetRecordSchedule( uint nRecordId, QString sTemplate, int nChanId, QDateTime dStartTimeRaw, bool bMakeOverride ) { RecordingRule rule; QDateTime dStartTime = dStartTimeRaw.toUTC(); if (nRecordId > 0) { rule.m_recordID = nRecordId; if (!rule.Load()) throw QString("Record ID does not exist."); } else if (!sTemplate.isEmpty()) { if (!rule.LoadTemplate(sTemplate)) throw QString("Template does not exist."); } else if (nChanId > 0 && dStartTime.isValid()) { RecordingInfo::LoadStatus status; RecordingInfo info(nChanId, dStartTime, false, 0, &status); if (status != RecordingInfo::kFoundProgram) throw QString("Program does not exist."); RecordingRule *pRule = info.GetRecordingRule(); if (bMakeOverride && rule.m_type != kSingleRecord && rule.m_type != kOverrideRecord && rule.m_type != kDontRecord) pRule->MakeOverride(); rule = *pRule; } else { throw QString("Invalid request."); } DTC::RecRule *pRecRule = new DTC::RecRule(); FillRecRuleInfo( pRecRule, &rule ); return pRecRule; }
bool Dvr::DisableRecordSchedule( uint nRecordId ) { bool bResult = false; if (nRecordId <= 0 ) throw( QString("Record ID appears invalid.")); RecordingRule *pRule = new RecordingRule(); pRule->m_recordID = nRecordId; pRule->Load(); if (pRule->IsLoaded()) { pRule->m_isInactive = true; pRule->Save(); bResult = true; } return bResult; }
void ProgramRecPriority::remove(void) { MythUIButtonListItem *item = m_programList->GetItemCurrent(); if (!item) return; ProgramRecPriorityInfo *pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>(); if (!pgRecInfo || (pgRecInfo->recType == kTemplateRecord && pgRecInfo->GetCategory() .compare("Default", Qt::CaseInsensitive) == 0)) { return; } RecordingRule *record = new RecordingRule(); record->m_recordID = pgRecInfo->GetRecordingRuleID(); if (!record->Load()) { delete record; return; } QString message = tr("Delete '%1' %2 rule?").arg(record->m_title) .arg(toString(pgRecInfo->GetRecordingRuleType())); MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythConfirmationDialog *okPopup = new MythConfirmationDialog(popupStack, message, true); okPopup->SetReturnEvent(this, "deleterule"); okPopup->SetData(qVariantFromValue(record)); if (okPopup->Create()) popupStack->AddScreen(okPopup); else delete okPopup; }
bool Dvr::UpdateRecordSchedule ( uint nRecordId, QString sTitle, QString sSubtitle, QString sDescription, QString sCategory, QDateTime dStartTimeRaw, QDateTime dEndTimeRaw, QString sSeriesId, QString sProgramId, int nChanId, QString sStation, int nFindDay, QTime tFindTime, bool bInactive, uint nSeason, uint nEpisode, QString sInetref, QString sType, QString sSearchType, int nRecPriority, uint nPreferredInput, int nStartOffset, int nEndOffset, QString sDupMethod, QString sDupIn, uint nFilter, QString sRecProfile, QString sRecGroup, QString sStorageGroup, QString sPlayGroup, bool bAutoExpire, int nMaxEpisodes, bool bMaxNewest, bool bAutoCommflag, bool bAutoTranscode, bool bAutoMetaLookup, bool bAutoUserJob1, bool bAutoUserJob2, bool bAutoUserJob3, bool bAutoUserJob4, int nTranscoder) { if (nRecordId <= 0 ) throw QString("Record ID is invalid."); RecordingRule pRule; pRule.m_recordID = nRecordId; pRule.Load(); if (!pRule.IsLoaded()) throw QString("Record ID does not exist."); QDateTime recstartts = dStartTimeRaw.toUTC(); QDateTime recendts = dEndTimeRaw.toUTC(); pRule.m_isInactive = bInactive; if (sType.isEmpty()) sType = "single"; if (sSearchType.isEmpty()) sSearchType = "none"; if (sDupMethod.isEmpty()) sDupMethod = "subtitleanddescription"; if (sDupIn.isEmpty()) sDupIn = "all"; pRule.m_type = recTypeFromString(sType); pRule.m_searchType = searchTypeFromString(sSearchType); pRule.m_dupMethod = dupMethodFromString(sDupMethod); pRule.m_dupIn = dupInFromString(sDupIn); if (sRecProfile.isEmpty()) sRecProfile = "Default"; if (sRecGroup.isEmpty()) sRecGroup = "Default"; if (sStorageGroup.isEmpty()) sStorageGroup = "Default"; if (sPlayGroup.isEmpty()) sPlayGroup = "Default"; if (!sTitle.isEmpty()) pRule.m_title = sTitle; if (!sSubtitle.isEmpty()) pRule.m_subtitle = sSubtitle; if(!sDescription.isEmpty()) pRule.m_description = sDescription; if (!sCategory.isEmpty()) pRule.m_category = sCategory; if (!sSeriesId.isEmpty()) pRule.m_seriesid = sSeriesId; if (!sProgramId.isEmpty()) pRule.m_programid = sProgramId; if (nChanId) pRule.m_channelid = nChanId; if (!sStation.isEmpty()) pRule.m_station = sStation; pRule.m_startdate = recstartts.date(); pRule.m_starttime = recstartts.time(); pRule.m_enddate = recendts.date(); pRule.m_endtime = recendts.time(); pRule.m_findday = nFindDay; pRule.m_findtime = tFindTime; pRule.m_recProfile = sRecProfile; pRule.m_recGroupID = RecordingInfo::GetRecgroupID(sRecGroup) > 0 ? RecordingInfo::GetRecgroupID(sRecGroup) : RecordingInfo::kDefaultRecGroup; pRule.m_storageGroup = sStorageGroup; pRule.m_playGroup = sPlayGroup; pRule.m_isInactive = bInactive; pRule.m_season = nSeason; pRule.m_episode = nEpisode; pRule.m_inetref = sInetref; pRule.m_recPriority = nRecPriority; pRule.m_prefInput = nPreferredInput; pRule.m_startOffset = nStartOffset; pRule.m_endOffset = nEndOffset; pRule.m_filter = nFilter; pRule.m_autoExpire = bAutoExpire; pRule.m_maxEpisodes = nMaxEpisodes; pRule.m_maxNewest = bMaxNewest; pRule.m_autoCommFlag = bAutoCommflag; pRule.m_autoTranscode = bAutoTranscode; pRule.m_autoMetadataLookup = bAutoMetaLookup; pRule.m_autoUserJob1 = bAutoUserJob1; pRule.m_autoUserJob2 = bAutoUserJob2; pRule.m_autoUserJob3 = bAutoUserJob3; pRule.m_autoUserJob4 = bAutoUserJob4; pRule.m_transcoder = nTranscoder; QString msg; if (!pRule.IsValid(msg)) throw msg; bool bResult = pRule.Save(); return bResult; }
void ProgramRecPriority::scheduleChanged(int recid) { // Assumes that the current item didn't change, which isn't guaranteed MythUIButtonListItem *item = m_programList->GetItemCurrent(); ProgramRecPriorityInfo *pgRecInfo = NULL; if (item) pgRecInfo = item->GetData().value<ProgramRecPriorityInfo*>(); // If the recording id doesn't match, the user created a new // template. if (!pgRecInfo || recid != pgRecInfo->getRecordID()) { RecordingRule record; record.m_recordID = recid; if (!record.Load() || record.m_type == kNotRecording) return; ProgramRecPriorityInfo progInfo; progInfo.SetRecordingRuleID(record.m_recordID); progInfo.SetRecordingRuleType(record.m_type); progInfo.SetTitle(record.m_title); progInfo.SetCategory(record.m_category); progInfo.SetRecordingPriority(record.m_recPriority); progInfo.recType = record.m_type; progInfo.sortTitle = record.m_title; progInfo.recstatus = record.m_isInactive ? RecStatus::Inactive : RecStatus::Unknown; progInfo.profile = record.m_recProfile; progInfo.last_record = record.m_lastRecorded; m_programData[recid] = progInfo; m_origRecPriorityData[record.m_recordID] = record.m_recPriority; SortList(&m_programData[recid]); return; } // We need to refetch the recording priority values since the Advanced // Recording Options page could've been used to change them MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT recpriority, type, inactive " "FROM record " "WHERE recordid = :RECORDID"); query.bindValue(":RECORDID", recid); if (!query.exec()) { MythDB::DBError("Get new recording priority query", query); } else if (query.next()) { int recPriority = query.value(0).toInt(); int rectype = query.value(1).toInt(); int inactive = query.value(2).toInt(); // set the recording priorities of that program pgRecInfo->SetRecordingPriority(recPriority); pgRecInfo->recType = (RecordingType)rectype; // also set the m_origRecPriorityData with new recording // priority so we don't save to db again when we exit m_origRecPriorityData[pgRecInfo->GetRecordingRuleID()] = pgRecInfo->GetRecordingPriority(); // also set the active/inactive state pgRecInfo->recstatus = inactive ? RecStatus::Inactive : RecStatus::Unknown; SortList(); } else { RemoveItemFromList(item); } countMatches(); }