mirror of
https://github.com/nzbget/nzbget.git
synced 2026-04-22 13:56:53 -04:00
when changing category in web-interface the post-processing parameters are now automatically updated according to new category settings; only parameters which are different in old and new category are changed; parameters which present in both or in neither categories are not changed; that ensures that only the relevant parameters are updated and parameters which were manually changed by user remain they settings when it make sense; in the "download details dialog" the new parameters are updated on the postprocess-tab directly after changing of category and can be controlled before saving; in the "edit multiple downloads dialog" the parameters are updated individually for each download on saving; new action "CP" of remote command "--edit/-E" for groups to set category and apply parameters; new action "GroupApplyCategory of RPC-method "editqueue" for the same purpose
This commit is contained in:
@@ -289,7 +289,8 @@ bool QueueEditor::InternEditList(ItemList* pItemList,
|
||||
break;
|
||||
|
||||
case DownloadQueue::eaGroupSetCategory:
|
||||
SetNZBCategory(pItem->m_pNZBInfo, szText);
|
||||
case DownloadQueue::eaGroupApplyCategory:
|
||||
SetNZBCategory(pItem->m_pNZBInfo, szText, eAction == DownloadQueue::eaGroupApplyCategory);
|
||||
break;
|
||||
|
||||
case DownloadQueue::eaGroupSetName:
|
||||
@@ -796,11 +797,94 @@ void QueueEditor::SetNZBPriority(NZBInfo* pNZBInfo, const char* szPriority)
|
||||
pNZBInfo->SetPriority(iPriority);
|
||||
}
|
||||
|
||||
void QueueEditor::SetNZBCategory(NZBInfo* pNZBInfo, const char* szCategory)
|
||||
void QueueEditor::SetNZBCategory(NZBInfo* pNZBInfo, const char* szCategory, bool bApplyParams)
|
||||
{
|
||||
debug("QueueEditor: setting category '%s' for '%s'", szCategory, pNZBInfo->GetName());
|
||||
|
||||
bool bOldUnpack = g_pOptions->GetUnpack();
|
||||
const char* szOldPostScript = g_pOptions->GetPostScript();
|
||||
if (bApplyParams && !Util::EmptyStr(pNZBInfo->GetCategory()))
|
||||
{
|
||||
Options::Category* pCategory = g_pOptions->FindCategory(pNZBInfo->GetCategory(), false);
|
||||
if (pCategory)
|
||||
{
|
||||
bOldUnpack = pCategory->GetUnpack();
|
||||
if (!Util::EmptyStr(pCategory->GetPostScript()))
|
||||
{
|
||||
szOldPostScript = pCategory->GetPostScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_pQueueCoordinator->SetQueueEntryCategory(m_pDownloadQueue, pNZBInfo, szCategory);
|
||||
|
||||
if (!bApplyParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool bNewUnpack = g_pOptions->GetUnpack();
|
||||
const char* szNewPostScript = g_pOptions->GetPostScript();
|
||||
if (!Util::EmptyStr(pNZBInfo->GetCategory()))
|
||||
{
|
||||
Options::Category* pCategory = g_pOptions->FindCategory(pNZBInfo->GetCategory(), false);
|
||||
if (pCategory)
|
||||
{
|
||||
bNewUnpack = pCategory->GetUnpack();
|
||||
if (!Util::EmptyStr(pCategory->GetPostScript()))
|
||||
{
|
||||
szNewPostScript = pCategory->GetPostScript();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bOldUnpack != bNewUnpack)
|
||||
{
|
||||
pNZBInfo->GetParameters()->SetParameter("*Unpack:", bNewUnpack ? "yes" : "no");
|
||||
}
|
||||
|
||||
if (strcasecmp(szOldPostScript, szNewPostScript))
|
||||
{
|
||||
// add new params not existed in old category
|
||||
Tokenizer tokNew(szNewPostScript, ",;");
|
||||
while (const char* szNewScriptName = tokNew.Next())
|
||||
{
|
||||
bool bFound = false;
|
||||
const char* szOldScriptName;
|
||||
Tokenizer tokOld(szOldPostScript, ",;");
|
||||
while ((szOldScriptName = tokOld.Next()) && !bFound)
|
||||
{
|
||||
bFound = !strcasecmp(szNewScriptName, szOldScriptName);
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
char szParam[1024];
|
||||
snprintf(szParam, 1024, "%s:", szNewScriptName);
|
||||
szParam[1024-1] = '\0';
|
||||
pNZBInfo->GetParameters()->SetParameter(szParam, "yes");
|
||||
}
|
||||
}
|
||||
|
||||
// remove old params not existed in new category
|
||||
Tokenizer tokOld(szOldPostScript, ",;");
|
||||
while (const char* szOldScriptName = tokOld.Next())
|
||||
{
|
||||
bool bFound = false;
|
||||
const char* szNewScriptName;
|
||||
Tokenizer tokNew(szNewPostScript, ",;");
|
||||
while ((szNewScriptName = tokNew.Next()) && !bFound)
|
||||
{
|
||||
bFound = !strcasecmp(szNewScriptName, szOldScriptName);
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
char szParam[1024];
|
||||
snprintf(szParam, 1024, "%s:", szOldScriptName);
|
||||
szParam[1024-1] = '\0';
|
||||
pNZBInfo->GetParameters()->SetParameter(szParam, "no");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QueueEditor::SetNZBName(NZBInfo* pNZBInfo, const char* szName)
|
||||
|
||||
Reference in New Issue
Block a user