diff --git a/ArticleDownloader.cpp b/ArticleDownloader.cpp index ec843c8b..5d0824b8 100644 --- a/ArticleDownloader.cpp +++ b/ArticleDownloader.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2004 Sven Henkel - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -229,24 +229,26 @@ void ArticleDownloader::Run() } #endif - if (g_pOptions->GetPauseDownload() || g_pOptions->GetPauseDownload2()) - { - Status = adRetry; - break; - } - if (((Status == adFailed) || (Status == adCrcError && g_pOptions->GetRetryOnCrcError())) && - (iRemainedDownloadRetries > 1 || !bConnected) && !IsStopped()) + (iRemainedDownloadRetries > 1 || !bConnected) && !IsStopped() && + !(g_pOptions->GetPauseDownload() || g_pOptions->GetPauseDownload2())) { detail("Waiting %i sec to retry", g_pOptions->GetRetryInterval()); int msec = 0; - while (!IsStopped() && (msec < g_pOptions->GetRetryInterval() * 1000)) + while (!IsStopped() && (msec < g_pOptions->GetRetryInterval() * 1000) && + !(g_pOptions->GetPauseDownload() || g_pOptions->GetPauseDownload2())) { usleep(100 * 1000); msec += 100; } } + if (g_pOptions->GetPauseDownload() || g_pOptions->GetPauseDownload2()) + { + Status = adRetry; + break; + } + if (IsStopped()) { Status = adFailed; diff --git a/BinRpc.cpp b/BinRpc.cpp index 2541b3da..54843522 100644 --- a/BinRpc.cpp +++ b/BinRpc.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2005 Bo Cordes Petersen - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -505,6 +505,8 @@ void ListBinCommand::Execute() pListAnswer->m_iRemainingSizeHi = htonl(iSizeHi); pListAnswer->m_bFilenameConfirmed = htonl(pFileInfo->GetFilenameConfirmed()); pListAnswer->m_bPaused = htonl(pFileInfo->GetPaused()); + pListAnswer->m_iActiveDownloads = htonl(pFileInfo->GetActiveDownloads()); + pListAnswer->m_iPriority = htonl(pFileInfo->GetPriority()); pListAnswer->m_iSubjectLen = htonl(strlen(pFileInfo->GetSubject()) + 1); pListAnswer->m_iFilenameLen = htonl(strlen(pFileInfo->GetFilename()) + 1); bufptr += sizeof(SNZBListResponseFileEntry); diff --git a/DiskState.cpp b/DiskState.cpp index d408970d..a112775c 100644 --- a/DiskState.cpp +++ b/DiskState.cpp @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,7 +82,7 @@ bool DiskState::SaveDownloadQueue(DownloadQueue* pDownloadQueue) return false; } - fprintf(outfile, "%s%i\n", FORMATVERSION_SIGNATURE, 13); + fprintf(outfile, "%s%i\n", FORMATVERSION_SIGNATURE, 14); // save nzb-infos SaveNZBList(pDownloadQueue, outfile); @@ -132,7 +132,7 @@ bool DiskState::LoadDownloadQueue(DownloadQueue* pDownloadQueue) char FileSignatur[128]; fgets(FileSignatur, sizeof(FileSignatur), infile); int iFormatVersion = ParseFormatVersion(FileSignatur); - if (iFormatVersion < 3 || iFormatVersion > 13) + if (iFormatVersion < 3 || iFormatVersion > 14) { error("Could not load diskstate due to file version mismatch"); fclose(infile); @@ -396,7 +396,8 @@ void DiskState::SaveFileQueue(DownloadQueue* pDownloadQueue, FileQueue* pFileQue if (!pFileInfo->GetDeleted()) { int iNZBIndex = FindNZBInfoIndex(pDownloadQueue, pFileInfo->GetNZBInfo()); - fprintf(outfile, "%i,%i,%i,%i\n", pFileInfo->GetID(), iNZBIndex, (int)pFileInfo->GetPaused(), (int)pFileInfo->GetTime()); + fprintf(outfile, "%i,%i,%i,%i,%i\n", pFileInfo->GetID(), iNZBIndex, (int)pFileInfo->GetPaused(), + (int)pFileInfo->GetTime(), pFileInfo->GetPriority()); } } } @@ -409,15 +410,20 @@ bool DiskState::LoadFileQueue(DownloadQueue* pDownloadQueue, FileQueue* pFileQue if (fscanf(infile, "%i\n", &size) != 1) goto error; for (int i = 0; i < size; i++) { - unsigned int id, iNZBIndex, paused, iTime; - if (iFormatVersion >= 12) + unsigned int id, iNZBIndex, paused; + unsigned int iTime = 0; + int iPriority = 0; + if (iFormatVersion >= 14) + { + if (fscanf(infile, "%i,%i,%i,%i,%i\n", &id, &iNZBIndex, &paused, &iTime, &iPriority) != 5) goto error; + } + else if (iFormatVersion >= 12) { if (fscanf(infile, "%i,%i,%i,%i\n", &id, &iNZBIndex, &paused, &iTime) != 4) goto error; } else { if (fscanf(infile, "%i,%i,%i\n", &id, &iNZBIndex, &paused) != 3) goto error; - iTime = 0; } if (iNZBIndex < 0 || iNZBIndex > pDownloadQueue->GetNZBInfoList()->size()) goto error; @@ -431,6 +437,7 @@ bool DiskState::LoadFileQueue(DownloadQueue* pDownloadQueue, FileQueue* pFileQue pFileInfo->SetID(id); pFileInfo->SetPaused(paused); pFileInfo->SetTime(iTime); + pFileInfo->SetPriority(iPriority); pFileInfo->SetNZBInfo(pDownloadQueue->GetNZBInfoList()->at(iNZBIndex - 1)); pFileQueue->push_back(pFileInfo); } @@ -881,7 +888,7 @@ bool DiskState::DiscardDownloadQueue() char FileSignatur[128]; fgets(FileSignatur, sizeof(FileSignatur), infile); int iFormatVersion = ParseFormatVersion(FileSignatur); - if (3 <= iFormatVersion && iFormatVersion <= 13) + if (3 <= iFormatVersion && iFormatVersion <= 14) { // skip nzb-infos int size = 0; diff --git a/DownloadInfo.cpp b/DownloadInfo.cpp index 6d8b4dd5..8171d829 100644 --- a/DownloadInfo.cpp +++ b/DownloadInfo.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2004 Sven Henkel - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -470,6 +470,8 @@ FileInfo::FileInfo() m_iCompleted = 0; m_bOutputInitialized = false; m_pNZBInfo = NULL; + m_iPriority = 0; + m_iActiveDownloads = 0; m_iIDGen++; m_iID = m_iIDGen; } @@ -588,6 +590,9 @@ GroupInfo::GroupInfo() m_iRemainingParCount = 0; m_tMinTime = 0; m_tMaxTime = 0; + m_iMinPriority = 0; + m_iMaxPriority = 0; + m_iActiveDownloads = 0; } GroupInfo::~GroupInfo() @@ -733,6 +738,8 @@ void DownloadQueue::BuildGroups(GroupQueue* pGroupQueue) pGroupInfo->m_iLastID = pFileInfo->GetID(); pGroupInfo->m_tMinTime = pFileInfo->GetTime(); pGroupInfo->m_tMaxTime = pFileInfo->GetTime(); + pGroupInfo->m_iMinPriority = pFileInfo->GetPriority(); + pGroupInfo->m_iMaxPriority = pFileInfo->GetPriority(); pGroupQueue->push_back(pGroupInfo); } if (pFileInfo->GetID() < pGroupInfo->GetFirstID()) @@ -754,6 +761,16 @@ void DownloadQueue::BuildGroups(GroupQueue* pGroupQueue) pGroupInfo->m_tMaxTime = pFileInfo->GetTime(); } } + if (pFileInfo->GetPriority() < pGroupInfo->GetMinPriority()) + { + pGroupInfo->m_iMinPriority = pFileInfo->GetPriority(); + } + if (pFileInfo->GetPriority() > pGroupInfo->GetMaxPriority()) + { + pGroupInfo->m_iMaxPriority = pFileInfo->GetPriority(); + } + + pGroupInfo->m_iActiveDownloads += pFileInfo->GetActiveDownloads(); pGroupInfo->m_iRemainingFileCount++; pGroupInfo->m_lRemainingSize += pFileInfo->GetRemainingSize(); if (pFileInfo->GetPaused()) diff --git a/DownloadInfo.h b/DownloadInfo.h index 06870c2c..e6b62f74 100644 --- a/DownloadInfo.h +++ b/DownloadInfo.h @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2004 Sven Henkel - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,6 +92,8 @@ private: int m_iCompleted; bool m_bOutputInitialized; Mutex m_mutexOutputFile; + int m_iPriority; + int m_iActiveDownloads; static int m_iIDGen; @@ -129,6 +131,10 @@ public: bool GetOutputInitialized() { return m_bOutputInitialized; } void SetOutputInitialized(bool bOutputInitialized) { m_bOutputInitialized = bOutputInitialized; } bool IsDupe(const char* szFilename); + int GetPriority() { return m_iPriority; } + void SetPriority(int iPriority) { m_iPriority = iPriority; } + int GetActiveDownloads() { return m_iActiveDownloads; } + void SetActiveDownloads(int iActiveDownloads) { m_iActiveDownloads = iActiveDownloads; } }; typedef std::deque FileQueue; @@ -146,6 +152,9 @@ private: int m_iRemainingParCount; time_t m_tMinTime; time_t m_tMaxTime; + int m_iMinPriority; + int m_iMaxPriority; + int m_iActiveDownloads; friend class DownloadQueue; @@ -162,6 +171,9 @@ public: int GetRemainingParCount() { return m_iRemainingParCount; } time_t GetMinTime() { return m_tMinTime; } time_t GetMaxTime() { return m_tMaxTime; } + int GetMinPriority() { return m_iMinPriority; } + int GetMaxPriority() { return m_iMaxPriority; } + int GetActiveDownloads() { return m_iActiveDownloads; } }; typedef std::deque GroupQueue; diff --git a/MessageBase.h b/MessageBase.h index d9282e84..ccf8610d 100644 --- a/MessageBase.h +++ b/MessageBase.h @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2005 Bo Cordes Petersen - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ #ifndef MESSAGEBASE_H #define MESSAGEBASE_H -static const int32_t NZBMESSAGE_SIGNATURE = 0x6E7A6209; // = "nzb9" (protocol version) +static const int32_t NZBMESSAGE_SIGNATURE = 0x6E7A620A; // = "nzbA" (protocol version) static const int NZBREQUESTFILENAMESIZE = 512; static const int NZBREQUESTPASSWORDSIZE = 32; @@ -76,6 +76,7 @@ enum eRemoteEditAction eRemoteEditActionFileDelete, // delete files eRemoteEditActionFilePauseAllPars, // pause only (all) pars (does not affect other files) eRemoteEditActionFilePauseExtraPars, // pause only (almost all) pars, except main par-file (does not affect other files) + eRemoteEditActionFileSetPriority, // set priority for files eRemoteEditActionGroupMoveOffset, // move group to m_iOffset relative to the current position in download-queue eRemoteEditActionGroupMoveTop, // move group to the top of download-queue eRemoteEditActionGroupMoveBottom, // move group to the bottom of download-queue @@ -84,6 +85,7 @@ enum eRemoteEditAction eRemoteEditActionGroupDelete, // delete group eRemoteEditActionGroupPauseAllPars, // pause only (all) pars (does not affect other files) in group eRemoteEditActionGroupPauseExtraPars, // pause only (almost all) pars in group, except main par-file (does not affect other files) + eRemoteEditActionGroupSetPriority, // set priority for groups eRemoteEditActionGroupSetCategory, // set or change category for a group eRemoteEditActionGroupMerge, // merge group eRemoteEditActionGroupSetParameter, // set post-process parameter for group @@ -215,6 +217,8 @@ struct SNZBListResponseFileEntry int32_t m_iRemainingSizeHi; // Remaining size in bytes, High 32-bits of 64-bit value int32_t m_bPaused; // 1 - file is paused int32_t m_bFilenameConfirmed; // 1 - Filename confirmed (read from article body), 0 - Filename parsed from subject (can be changed after reading of article) + int32_t m_iPriority; // Download priority + int32_t m_iActiveDownloads; // Number of active downloads for this file int32_t m_iSubjectLen; // Length of Subject-string (m_szSubject), following to this record int32_t m_iFilenameLen; // Length of Filename-string (m_szFilename), following to this record //char m_szSubject[m_iSubjectLen]; // variable sized diff --git a/NCursesFrontend.cpp b/NCursesFrontend.cpp index 77f20d94..6e3111c2 100644 --- a/NCursesFrontend.cpp +++ b/NCursesFrontend.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2004 Sven Henkel - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -819,6 +819,19 @@ void NCursesFrontend::PrintFilename(FileInfo * pFileInfo, int iRow, bool bSelect color = NCURSES_COLORPAIR_TEXT; } + const char* szDownloading = ""; + if (pFileInfo->GetActiveDownloads() > 0) + { + szDownloading = " *"; + } + + char szPriority[100]; + szPriority[0] = '\0'; + if (pFileInfo->GetPriority() != 0) + { + sprintf(szPriority, " [%+i]", pFileInfo->GetPriority()); + } + char szCompleted[20]; szCompleted[0] = '\0'; if (pFileInfo->GetRemainingSize() < pFileInfo->GetSize()) @@ -840,8 +853,9 @@ void NCursesFrontend::PrintFilename(FileInfo * pFileInfo, int iRow, bool bSelect } char szBuffer[MAX_SCREEN_WIDTH]; - snprintf(szBuffer, MAX_SCREEN_WIDTH, "%s%i%s %s%s (%.2f MB%s)%s", Brace1, pFileInfo->GetID(), - Brace2, szNZBNiceName, pFileInfo->GetFilename(), (float)(Util::Int64ToFloat(pFileInfo->GetSize()) / 1024.0 / 1024.0), + snprintf(szBuffer, MAX_SCREEN_WIDTH, "%s%i%s%s%s %s%s (%.2f MB%s)%s", Brace1, pFileInfo->GetID(), + Brace2, szPriority, szDownloading, szNZBNiceName, pFileInfo->GetFilename(), + (float)(Util::Int64ToFloat(pFileInfo->GetSize()) / 1024.0 / 1024.0), szCompleted, pFileInfo->GetPaused() ? " (paused)" : ""); szBuffer[MAX_SCREEN_WIDTH - 1] = '\0'; @@ -979,21 +993,23 @@ void NCursesFrontend::ResetColWidths() void NCursesFrontend::PrintGroupname(GroupInfo * pGroupInfo, int iRow, bool bSelected, bool bCalcColWidth) { - int color = 0; - const char* Brace1 = "["; - const char* Brace2 = "]"; + int color = NCURSES_COLORPAIR_TEXT; + char chBrace1 = '['; + char chBrace2 = ']'; if (m_eInputMode == eEditQueue && bSelected) { color = NCURSES_COLORPAIR_TEXTHIGHL; if (!m_bUseColor) { - Brace1 = "<"; - Brace2 = ">"; + chBrace1 = '<'; + chBrace2 = '>'; } } - else + + const char* szDownloading = ""; + if (pGroupInfo->GetActiveDownloads() > 0) { - color = NCURSES_COLORPAIR_TEXT; + szDownloading = " *"; } long long lUnpausedRemainingSize = pGroupInfo->GetRemainingSize() - pGroupInfo->GetPausedSize(); @@ -1004,6 +1020,20 @@ void NCursesFrontend::PrintGroupname(GroupInfo * pGroupInfo, int iRow, bool bSel char szNZBNiceName[1024]; pGroupInfo->GetNZBInfo()->GetNiceNZBName(szNZBNiceName, 1023); + char szPriority[100]; + szPriority[0] = '\0'; + if (pGroupInfo->GetMinPriority() != 0 || pGroupInfo->GetMaxPriority() != 0) + { + if (pGroupInfo->GetMinPriority() == pGroupInfo->GetMaxPriority()) + { + sprintf(szPriority, " [%+i]", pGroupInfo->GetMinPriority()); + } + else + { + sprintf(szPriority, " [%+i..%+i]", pGroupInfo->GetMinPriority(), pGroupInfo->GetMaxPriority()); + } + } + char szBuffer[MAX_SCREEN_WIDTH]; // Format: @@ -1032,7 +1062,8 @@ void NCursesFrontend::PrintGroupname(GroupInfo * pGroupInfo, int iRow, bool bSel Util::FormatFileSize(szTotal, sizeof(szTotal), pGroupInfo->GetNZBInfo()->GetSize()); char szNameWithIds[1024]; - snprintf(szNameWithIds, 1024, "%s%i-%i%s %s", Brace1, pGroupInfo->GetFirstID(), pGroupInfo->GetLastID(), Brace2, szNZBNiceName); + snprintf(szNameWithIds, 1024, "%c%i-%i%c%s%s %s", chBrace1, pGroupInfo->GetFirstID(), pGroupInfo->GetLastID(), chBrace2, + szPriority, szDownloading, szNZBNiceName); szNameWithIds[iNameLen] = '\0'; char szTime[100]; @@ -1077,7 +1108,8 @@ void NCursesFrontend::PrintGroupname(GroupInfo * pGroupInfo, int iRow, bool bSel } else { - snprintf(szBuffer, MAX_SCREEN_WIDTH, "%s%i-%i%s %s", Brace1, pGroupInfo->GetFirstID(), pGroupInfo->GetLastID(), Brace2, szNZBNiceName); + snprintf(szBuffer, MAX_SCREEN_WIDTH, "%c%i-%i%c%s %s", chBrace1, pGroupInfo->GetFirstID(), + pGroupInfo->GetLastID(), chBrace2, szDownloading, szNZBNiceName); } szBuffer[MAX_SCREEN_WIDTH - 1] = '\0'; diff --git a/Options.cpp b/Options.cpp index d8bb486b..4f32c6fe 100644 --- a/Options.cpp +++ b/Options.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2004 Sven Henkel - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1058,6 +1058,22 @@ void Options::InitCommandLine(int argc, char* argv[]) abort("FATAL ERROR: Could not parse value of option 'E'\n"); } } + else if (!strcasecmp(optarg, "I")) + { + m_iEditQueueAction = bGroup ? eRemoteEditActionGroupSetPriority : eRemoteEditActionFileSetPriority; + + optind++; + if (optind > argc) + { + abort("FATAL ERROR: Could not parse value of option 'E'\n"); + } + m_szEditQueueText = strdup(argv[optind-1]); + + if (atoi(m_szEditQueueText) == 0 && strcmp("0", m_szEditQueueText)) + { + abort("FATAL ERROR: Could not parse value of option 'E'\n"); + } + } else { m_iEditQueueOffset = atoi(optarg); @@ -1189,6 +1205,7 @@ void Options::PrintUsage(char* com) " N Rename (for groups)\n" " M Merge (for groups)\n" " O = Set post-process parameter (for groups)\n" + " I Set priority (signed integer) for file(s)/group(s)\n" " Comma-separated list of file-ids or ranges\n" " of file-ids, e. g.: 1-5,3,10-22\n", Util::BaseFileName(com)); diff --git a/QueueCoordinator.cpp b/QueueCoordinator.cpp index c422114e..488448af 100644 --- a/QueueCoordinator.cpp +++ b/QueueCoordinator.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2005 Bo Cordes Petersen - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -170,7 +170,7 @@ void QueueCoordinator::Run() AddSpeedReading(0); - iResetCounter+= iSleepInterval; + iResetCounter += iSleepInterval; if (iResetCounter >= 1000) { // this code should not be called too often, once per second is OK @@ -434,31 +434,84 @@ void QueueCoordinator::Stop() debug("ArticleDownloads are notified"); } +/* + * Returns next article for download. + */ bool QueueCoordinator::GetNextArticle(FileInfo* &pFileInfo, ArticleInfo* &pArticleInfo) { + // find an unpaused file with the highest priority, then take the next article from the file. + // if the file doesn't have any articles left for download, we store that fact and search again, + // ignoring all files which were previously marked as not having any articles. + //debug("QueueCoordinator::GetNextArticle()"); - for (FileQueue::iterator it = m_DownloadQueue.GetFileQueue()->begin(); it != m_DownloadQueue.GetFileQueue()->end(); it++) + bool bOK = false; + + // pCheckedFiles stores + bool* pCheckedFiles = NULL; + + while (!bOK) { - pFileInfo = *it; - if (!pFileInfo->GetPaused() && !pFileInfo->GetDeleted()) + //debug("QueueCoordinator::GetNextArticle() - in loop"); + + pFileInfo = NULL; + int iNum = 0; + int iFileNum = 0; + + for (FileQueue::iterator it = m_DownloadQueue.GetFileQueue()->begin(); it != m_DownloadQueue.GetFileQueue()->end(); it++) { - if (pFileInfo->GetArticles()->empty() && g_pOptions->GetSaveQueue() && g_pOptions->GetServerMode()) + FileInfo* pFileInfo1 = *it; + if ((!pCheckedFiles || !pCheckedFiles[iNum]) && + !pFileInfo1->GetPaused() && !pFileInfo1->GetDeleted() && + (!pFileInfo || (pFileInfo1->GetPriority() > pFileInfo->GetPriority()))) { - g_pDiskState->LoadArticles(pFileInfo); + pFileInfo = pFileInfo1; + iFileNum = iNum; } - for (FileInfo::Articles::iterator at = pFileInfo->GetArticles()->begin(); at != pFileInfo->GetArticles()->end(); at++) + iNum++; + } + + if (!pFileInfo) + { + // there are no more files for download + break; + } + + if (pFileInfo->GetArticles()->empty() && g_pOptions->GetSaveQueue() && g_pOptions->GetServerMode()) + { + g_pDiskState->LoadArticles(pFileInfo); + } + + // check if the file has any articles left for download + for (FileInfo::Articles::iterator at = pFileInfo->GetArticles()->begin(); at != pFileInfo->GetArticles()->end(); at++) + { + pArticleInfo = *at; + if (pArticleInfo->GetStatus() == 0) { - pArticleInfo = *at; - if (pArticleInfo->GetStatus() == 0) - { - return true; - } + bOK = true; + break; } } + + if (!bOK) + { + // the file doesn't have any articles left for download, we mark the file as such + if (!pCheckedFiles) + { + int iArrSize = sizeof(bool) * m_DownloadQueue.GetFileQueue()->size(); + pCheckedFiles = (bool*)malloc(iArrSize); + memset(pCheckedFiles, false, iArrSize); + } + pCheckedFiles[iFileNum] = true; + } } - return false; + if (pCheckedFiles) + { + free(pCheckedFiles); + } + + return bOK; } void QueueCoordinator::StartArticleDownload(FileInfo* pFileInfo, ArticleInfo* pArticleInfo, NNTPConnection* pConnection) @@ -474,6 +527,7 @@ void QueueCoordinator::StartArticleDownload(FileInfo* pFileInfo, ArticleInfo* pA BuildArticleFilename(pArticleDownloader, pFileInfo, pArticleInfo); pArticleInfo->SetStatus(ArticleInfo::aiRunning); + pFileInfo->SetActiveDownloads(pFileInfo->GetActiveDownloads() + 1); m_ActiveDownloads.push_back(pArticleDownloader); pArticleDownloader->Start(); @@ -616,6 +670,8 @@ void QueueCoordinator::ArticleCompleted(ArticleDownloader* pArticleDownloader) } } + pFileInfo->SetActiveDownloads(pFileInfo->GetActiveDownloads() - 1); + if (deleteFileObj) { bool fileDeleted = pFileInfo->GetDeleted(); @@ -762,6 +818,7 @@ void QueueCoordinator::ResetHangingDownloads() error("Could not terminate hanging download %s", Util::BaseFileName(pArticleInfo->GetResultFilename())); } m_ActiveDownloads.erase(it); + pArticleDownloader->GetFileInfo()->SetActiveDownloads(pArticleDownloader->GetFileInfo()->GetActiveDownloads() - 1); // it's not safe to destroy pArticleDownloader, because the state of object is unknown delete pArticleDownloader; it = m_ActiveDownloads.begin(); diff --git a/QueueEditor.cpp b/QueueEditor.cpp index a280c64a..c1b1639f 100644 --- a/QueueEditor.cpp +++ b/QueueEditor.cpp @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -110,7 +110,7 @@ void QueueEditor::PauseUnpauseEntry(FileInfo* pFileInfo, bool bPause) } /* - * Removes entry with index iEntry + * Removes entry * returns true if successful, false if operation is not possible */ void QueueEditor::DeleteEntry(FileInfo* pFileInfo) @@ -120,7 +120,7 @@ void QueueEditor::DeleteEntry(FileInfo* pFileInfo) } /* - * Moves entry identified with iID in the queue + * Moves entry in the queue * returns true if successful, false if operation is not possible */ void QueueEditor::MoveEntry(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, int iOffset) @@ -148,6 +148,17 @@ void QueueEditor::MoveEntry(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, } } +/* + * Set priority for entry + * returns true if successful, false if operation is not possible + */ +void QueueEditor::SetPriorityEntry(FileInfo* pFileInfo, const char* szPriority) +{ + debug("Setting priority %s for file %s", szPriority, pFileInfo->GetFilename()); + int iPriority = atoi(szPriority); + pFileInfo->SetPriority(iPriority); +} + bool QueueEditor::EditEntry(int ID, bool bSmartOrder, EEditAction eAction, int iOffset, const char* szText) { IDList cIDList; @@ -228,6 +239,10 @@ bool QueueEditor::InternEditList(DownloadQueue* pDownloadQueue, IDList* pIDList, DeleteEntry(pItem->m_pFileInfo); break; + case eaFileSetPriority: + SetPriorityEntry(pItem->m_pFileInfo, szText); + break; + case eaGroupSetCategory: SetNZBCategory(pItem->m_pFileInfo->GetNZBInfo(), szText); break; @@ -248,7 +263,8 @@ bool QueueEditor::InternEditList(DownloadQueue* pDownloadQueue, IDList* pIDList, case eaGroupMoveOffset: case eaGroupPauseAllPars: case eaGroupPauseExtraPars: - EditGroup(pDownloadQueue, pItem->m_pFileInfo, eAction, iOffset); + case eaGroupSetPriority: + EditGroup(pDownloadQueue, pItem->m_pFileInfo, eAction, iOffset, szText); break; case eaFilePauseAllPars: @@ -369,7 +385,7 @@ void QueueEditor::PrepareList(DownloadQueue* pDownloadQueue, ItemList* pItemList } } -bool QueueEditor::EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, EEditAction eAction, int iOffset) +bool QueueEditor::EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, EEditAction eAction, int iOffset, const char* szText) { IDList cIDList; cIDList.clear(); @@ -435,10 +451,13 @@ bool QueueEditor::EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, pFileInfo->GetNZBInfo()->SetCleanupDisk(CanCleanupDisk(pDownloadQueue, pFileInfo->GetNZBInfo())); } - EEditAction GroupToFileMap[] = { (EEditAction)0, eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, eaFilePause, eaFileResume, eaFileDelete, eaFilePauseAllPars, eaFilePauseExtraPars, - eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, eaFilePause, eaFileResume, eaFileDelete, eaFilePauseAllPars, eaFilePauseExtraPars, (EEditAction)0, (EEditAction)0, (EEditAction)0 }; + EEditAction GroupToFileMap[] = { (EEditAction)0, eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, + eaFilePause, eaFileResume, eaFileDelete, eaFilePauseAllPars, eaFilePauseExtraPars, eaFileSetPriority, + eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, eaFilePause, eaFileResume, eaFileDelete, + eaFilePauseAllPars, eaFilePauseExtraPars, eaFileSetPriority, + (EEditAction)0, (EEditAction)0, (EEditAction)0 }; - return InternEditList(pDownloadQueue, &cIDList, true, GroupToFileMap[eAction], iOffset, NULL); + return InternEditList(pDownloadQueue, &cIDList, true, GroupToFileMap[eAction], iOffset, szText); } void QueueEditor::BuildGroupList(DownloadQueue* pDownloadQueue, FileList* pGroupList) diff --git a/QueueEditor.h b/QueueEditor.h index 92410f05..b035a972 100644 --- a/QueueEditor.h +++ b/QueueEditor.h @@ -1,7 +1,7 @@ /* * This file if part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -43,6 +43,7 @@ public: eaFileDelete, eaFilePauseAllPars, eaFilePauseExtraPars, + eaFileSetPriority, eaGroupMoveOffset, // move to m_iOffset relative to the current position in queue eaGroupMoveTop, eaGroupMoveBottom, @@ -51,10 +52,11 @@ public: eaGroupDelete, eaGroupPauseAllPars, eaGroupPauseExtraPars, + eaGroupSetPriority, eaGroupSetCategory, eaGroupMerge, eaGroupSetParameter, - eaGroupSetName, + eaGroupSetName }; private: @@ -75,7 +77,7 @@ private: int FindFileInfoEntry(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo); bool InternEditList(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, EEditAction eAction, int iOffset, const char* szText); void PrepareList(DownloadQueue* pDownloadQueue, ItemList* pItemList, IDList* pIDList, bool bSmartOrder, EEditAction eAction, int iOffset); - bool EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, EEditAction eAction, int iOffset); + bool EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, EEditAction eAction, int iOffset, const char* szText); void BuildGroupList(DownloadQueue* pDownloadQueue, FileList* pGroupList); void AlignAffectedGroups(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, int iOffset); bool ItemExists(FileList* pFileList, FileInfo* pFileInfo); @@ -91,6 +93,7 @@ private: void PauseUnpauseEntry(FileInfo* pFileInfo, bool bPause); void DeleteEntry(FileInfo* pFileInfo); void MoveEntry(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, int iOffset); + void SetPriorityEntry(FileInfo* pFileInfo, const char* szPriority); public: QueueEditor(); diff --git a/RemoteClient.cpp b/RemoteClient.cpp index 60f31aa1..dedf30e7 100644 --- a/RemoteClient.cpp +++ b/RemoteClient.cpp @@ -2,7 +2,7 @@ * This file is part of nzbget * * Copyright (C) 2005 Bo Cordes Petersen - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -289,6 +289,8 @@ void RemoteClient::BuildFileList(SNZBListResponse* pListResponse, const char* pT pFileInfo->SetSubject(szSubject); pFileInfo->SetFilename(szFileName); pFileInfo->SetFilenameConfirmed(ntohl(pListAnswer->m_bFilenameConfirmed)); + pFileInfo->SetActiveDownloads(ntohl(pListAnswer->m_iActiveDownloads)); + pFileInfo->SetPriority(ntohl(pListAnswer->m_iPriority)); NZBInfo* pNZBInfo = pDownloadQueue->GetNZBInfoList()->at(ntohl(pListAnswer->m_iNZBIndex) - 1); @@ -373,12 +375,27 @@ bool RemoteClient::RequestServerList(bool bFiles, bool bGroups) { FileInfo* pFileInfo = *it; + char szPriority[100]; + szPriority[0] = '\0'; + if (pFileInfo->GetPriority() != 0) + { + sprintf(szPriority, "[%+i] ", pFileInfo->GetPriority()); + } + char szCompleted[100]; szCompleted[0] = '\0'; if (pFileInfo->GetRemainingSize() < pFileInfo->GetSize()) { sprintf(szCompleted, ", %i%s", (int)(100 - Util::Int64ToFloat(pFileInfo->GetRemainingSize()) * 100.0 / Util::Int64ToFloat(pFileInfo->GetSize())), "%"); } + + char szThreads[100]; + szThreads[0] = '\0'; + if (pFileInfo->GetActiveDownloads() > 0) + { + sprintf(szThreads, ", %i thread%s", pFileInfo->GetActiveDownloads(), (pFileInfo->GetActiveDownloads() > 1 ? "s" : "")); + } + char szStatus[100]; if (pFileInfo->GetPaused()) { @@ -390,12 +407,14 @@ bool RemoteClient::RequestServerList(bool bFiles, bool bGroups) szStatus[0] = '\0'; lRemaining += pFileInfo->GetRemainingSize(); } - + char szNZBNiceName[1024]; pFileInfo->GetNZBInfo()->GetNiceNZBName(szNZBNiceName, 1024); - printf("[%i] %s%c%s (%.2f MB%s)%s\n", pFileInfo->GetID(), szNZBNiceName, (int)PATH_SEPARATOR, pFileInfo->GetFilename(), - (float)(Util::Int64ToFloat(pFileInfo->GetSize()) / 1024.0 / 1024.0), szCompleted, szStatus); + printf("[%i] %s%s%c%s (%.2f MB%s%s)%s\n", pFileInfo->GetID(), szPriority, szNZBNiceName, + (int)PATH_SEPARATOR, pFileInfo->GetFilename(), + (float)(Util::Int64ToFloat(pFileInfo->GetSize()) / 1024.0 / 1024.0), + szCompleted, szThreads, szStatus); delete pFileInfo; } @@ -444,6 +463,20 @@ bool RemoteClient::RequestServerList(bool bFiles, bool bGroups) char szRemaining[20]; Util::FormatFileSize(szRemaining, sizeof(szRemaining), lUnpausedRemainingSize); + char szPriority[100]; + szPriority[0] = '\0'; + if (pGroupInfo->GetMinPriority() != 0 || pGroupInfo->GetMaxPriority() != 0) + { + if (pGroupInfo->GetMinPriority() == pGroupInfo->GetMaxPriority()) + { + sprintf(szPriority, "[%+i] ", pGroupInfo->GetMinPriority()); + } + else + { + sprintf(szPriority, "[%+i..%+i] ", pGroupInfo->GetMinPriority(), pGroupInfo->GetMaxPriority()); + } + } + char szPaused[20]; szPaused[0] = '\0'; if (pGroupInfo->GetPausedSize() > 0) @@ -464,6 +497,13 @@ bool RemoteClient::RequestServerList(bool bFiles, bool bGroups) sprintf(szCategory, " (%s)", pGroupInfo->GetNZBInfo()->GetCategory()); } + char szThreads[100]; + szThreads[0] = '\0'; + if (pGroupInfo->GetActiveDownloads() > 0) + { + sprintf(szThreads, ", %i thread%s", pGroupInfo->GetActiveDownloads(), (pGroupInfo->GetActiveDownloads() > 1 ? "s" : "")); + } + char szParameters[1024]; szParameters[0] = '\0'; for (NZBParameterList::iterator it = pGroupInfo->GetNZBInfo()->GetParameters()->begin(); it != pGroupInfo->GetNZBInfo()->GetParameters()->end(); it++) @@ -486,9 +526,9 @@ bool RemoteClient::RequestServerList(bool bFiles, bool bGroups) strncat(szParameters, ")", 1024); } - printf("[%i-%i] %s (%i file%s, %s%s)%s%s\n", pGroupInfo->GetFirstID(), pGroupInfo->GetLastID(), szNZBNiceName, + printf("[%i-%i] %s%s (%i file%s, %s%s%s)%s%s\n", pGroupInfo->GetFirstID(), pGroupInfo->GetLastID(), szPriority, szNZBNiceName, pGroupInfo->GetRemainingFileCount(), pGroupInfo->GetRemainingFileCount() > 1 ? "s" : "", szRemaining, - szPaused, szCategory, szParameters); + szPaused, szThreads, szCategory, szParameters); delete pGroupInfo; } diff --git a/Scanner.cpp b/Scanner.cpp index b4bb58bf..0d95e802 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -270,12 +270,14 @@ void Scanner::ProcessIncomingFile(const char* szDirectory, const char* szBaseFil char* szNZBCategory = strdup(szCategory); NZBParameterList* pParameterList = new NZBParameterList; + int iPriority = 0; bool bExists = true; if (m_bNZBScript && strcasecmp(szExtension, ".nzb_processed")) { - NZBScriptController::ExecuteScript(g_pOptions->GetNZBProcess(), szFullFilename, szDirectory, &szNZBCategory, pParameterList); + NZBScriptController::ExecuteScript(g_pOptions->GetNZBProcess(), szFullFilename, szDirectory, + &szNZBCategory, &iPriority, pParameterList); bExists = Util::FileExists(szFullFilename); if (bExists && strcasecmp(szExtension, ".nzb")) { @@ -294,7 +296,7 @@ void Scanner::ProcessIncomingFile(const char* szDirectory, const char* szBaseFil bool bRenameOK = Util::RenameBak(szFullFilename, "nzb", true, szRenamedName, 1024); if (bRenameOK) { - AddFileToQueue(szRenamedName, szNZBCategory, pParameterList); + AddFileToQueue(szRenamedName, szNZBCategory, iPriority, pParameterList); } else { @@ -303,7 +305,7 @@ void Scanner::ProcessIncomingFile(const char* szDirectory, const char* szBaseFil } else if (bExists && !strcasecmp(szExtension, ".nzb")) { - AddFileToQueue(szFullFilename, szNZBCategory, pParameterList); + AddFileToQueue(szFullFilename, szNZBCategory, iPriority, pParameterList); } for (NZBParameterList::iterator it = pParameterList->begin(); it != pParameterList->end(); it++) @@ -316,7 +318,7 @@ void Scanner::ProcessIncomingFile(const char* szDirectory, const char* szBaseFil free(szNZBCategory); } -void Scanner::AddFileToQueue(const char* szFilename, const char* szCategory, NZBParameterList* pParameterList) +void Scanner::AddFileToQueue(const char* szFilename, const char* szCategory, int iPriority, NZBParameterList* pParameterList) { const char* szBasename = Util::BaseFileName(szFilename); @@ -345,6 +347,12 @@ void Scanner::AddFileToQueue(const char* szFilename, const char* szCategory, NZB pNZBFile->GetNZBInfo()->SetParameter(pParameter->GetName(), pParameter->GetValue()); } + for (NZBFile::FileInfos::iterator it = pNZBFile->GetFileInfos()->begin(); it != pNZBFile->GetFileInfos()->end(); it++) + { + FileInfo* pFileInfo = *it; + pFileInfo->SetPriority(iPriority); + } + g_pQueueCoordinator->AddNZBFileToQueue(pNZBFile, false); info("Collection %s added to queue", szBasename); } diff --git a/Scanner.h b/Scanner.h index 6a36c879..ef9e43d4 100644 --- a/Scanner.h +++ b/Scanner.h @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,7 +60,7 @@ private: FileList m_FileList; void CheckIncomingNZBs(const char* szDirectory, const char* szCategory, bool bCheckStat); - void AddFileToQueue(const char* szFilename, const char* szCategory, NZBParameterList* pParameterList); + void AddFileToQueue(const char* szFilename, const char* szCategory, int iPriority, NZBParameterList* pParameterList); void ProcessIncomingFile(const char* szDirectory, const char* szBaseFilename, const char* szFullFilename, const char* szCategory); bool CanProcessFile(const char* szFullFilename, bool bCheckStat); void DropOldFiles(); diff --git a/ScriptController.cpp b/ScriptController.cpp index 9eef3eee..9b00ffa0 100644 --- a/ScriptController.cpp +++ b/ScriptController.cpp @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -806,7 +806,7 @@ void PostScriptController::Stop() } void NZBScriptController::ExecuteScript(const char* szScript, const char* szNZBFilename, - const char* szDirectory, char** pCategory, NZBParameterList* pParameterList) + const char* szDirectory, char** pCategory, int* iPriority, NZBParameterList* pParameterList) { info("Executing nzb-process-script for %s", Util::BaseFileName(szNZBFilename)); @@ -814,6 +814,7 @@ void NZBScriptController::ExecuteScript(const char* szScript, const char* szNZBF pScriptController->SetScript(szScript); pScriptController->m_pCategory = pCategory; pScriptController->m_pParameterList = pParameterList; + pScriptController->m_iPriority = iPriority; char szInfoName[1024]; snprintf(szInfoName, 1024, "nzb-process-script for %s", Util::BaseFileName(szNZBFilename)); @@ -873,6 +874,10 @@ void NZBScriptController::AddMessage(Message::EKind eKind, bool bDefaultKind, Op } free(szParam); } + else if (!strncmp(szText + 6, "PRIORITY=", 9)) + { + *m_iPriority = atoi(szText + 6 + 9); + } else { error("Invalid command \"%s\" received from %s", szText, GetInfoName()); diff --git a/ScriptController.h b/ScriptController.h index c8a28205..ba8dd93e 100644 --- a/ScriptController.h +++ b/ScriptController.h @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -114,13 +114,14 @@ class NZBScriptController : public ScriptController { private: char** m_pCategory; + int* m_iPriority; NZBParameterList* m_pParameterList; protected: virtual void AddMessage(Message::EKind eKind, bool bDefaultKind, Options::EMessageTarget eMessageTarget, const char* szText); public: - static void ExecuteScript(const char* szScript, const char* szNZBFilename, const char* szDirectory, char** pCategory, NZBParameterList* pParameterList); + static void ExecuteScript(const char* szScript, const char* szNZBFilename, const char* szDirectory, char** pCategory, int* iPriority, NZBParameterList* pParameterList); }; class SchedulerScriptController : public Thread, ScriptController diff --git a/XmlRpc.cpp b/XmlRpc.cpp index 05a0d770..87752b30 100644 --- a/XmlRpc.cpp +++ b/XmlRpc.cpp @@ -1,7 +1,7 @@ /* * This file is part of nzbget * - * Copyright (C) 2007-2010 Andrei Prygounkov + * Copyright (C) 2007-2011 Andrei Prygounkov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1125,6 +1125,8 @@ void ListFilesXmlCommand::Execute() "Filename%s\n" "DestDir%s\n" "Category%s\n" + "Priority%i\n" + "ActiveDownloads%i\n" "\n"; const char* JSON_LIST_ITEM = @@ -1143,7 +1145,9 @@ void ListFilesXmlCommand::Execute() "\"Subject\" : \"%s\",\n" "\"Filename\" : \"%s\",\n" "\"DestDir\" : \"%s\",\n" - "\"Category\" : \"%s\"\n" + "\"Category\" : \"%s\",\n" + "\"Priority\" : %i,\n" + "\"ActiveDownloads\" : %i\n" "}"; int szItemBufSize = 10240; @@ -1172,7 +1176,8 @@ void ListFilesXmlCommand::Execute() pFileInfo->GetID(), iFileSizeLo, iFileSizeHi, iRemainingSizeLo, iRemainingSizeHi, pFileInfo->GetTime(), BoolToStr(pFileInfo->GetFilenameConfirmed()), BoolToStr(pFileInfo->GetPaused()), pFileInfo->GetNZBInfo()->GetID(), - xmlNZBNicename, xmlNZBFilename, xmlSubject, xmlFilename, xmlDestDir, xmlCategory); + xmlNZBNicename, xmlNZBFilename, xmlSubject, xmlFilename, xmlDestDir, xmlCategory, + pFileInfo->GetPriority(), pFileInfo->GetActiveDownloads()); szItemBuf[szItemBufSize-1] = '\0'; free(xmlNZBFilename); @@ -1222,6 +1227,9 @@ void ListGroupsXmlCommand::Execute() "NZBFilename%s\n" "DestDir%s\n" "Category%s\n" + "MinPriority%i\n" + "MaxPriority%i\n" + "ActiveDownloads%i\n" "Parameters\n"; const char* XML_LIST_ITEM_END = @@ -1251,6 +1259,9 @@ void ListGroupsXmlCommand::Execute() "\"NZBFilename\" : \"%s\",\n" "\"DestDir\" : \"%s\",\n" "\"Category\" : \"%s\",\n" + "\"MinPriority\" : %i,\n" + "\"MaxPriority\" : %i,\n" + "\"ActiveDownloads\" : %i,\n" "\"Parameters\" : [\n"; const char* JSON_LIST_ITEM_END = @@ -1304,7 +1315,8 @@ void ListGroupsXmlCommand::Execute() iRemainingSizeLo, iRemainingSizeHi, iRemainingSizeMB, iPausedSizeLo, iPausedSizeHi, iPausedSizeMB, pGroupInfo->GetNZBInfo()->GetFileCount(), pGroupInfo->GetRemainingFileCount(), pGroupInfo->GetRemainingParCount(), pGroupInfo->GetMinTime(), pGroupInfo->GetMaxTime(), - pGroupInfo->GetNZBInfo()->GetID(), xmlNZBNicename, xmlNZBFilename, xmlDestDir, xmlCategory); + pGroupInfo->GetNZBInfo()->GetID(), xmlNZBNicename, xmlNZBFilename, xmlDestDir, xmlCategory, + pGroupInfo->GetMinPriority(), pGroupInfo->GetMaxPriority(), pGroupInfo->GetActiveDownloads()); szItemBuf[szItemBufSize-1] = '\0'; free(xmlNZBNicename); @@ -1368,6 +1380,7 @@ EditCommandEntry EditCommandNameMap[] = { { QueueEditor::eaFileDelete, "FileDelete" }, { QueueEditor::eaFilePauseAllPars, "FilePauseAllPars" }, { QueueEditor::eaFilePauseExtraPars, "FilePauseExtraPars" }, + { QueueEditor::eaFileSetPriority, "FileSetPriority" }, { QueueEditor::eaGroupMoveOffset, "GroupMoveOffset" }, { QueueEditor::eaGroupMoveTop, "GroupMoveTop" }, { QueueEditor::eaGroupMoveBottom, "GroupMoveBottom" }, @@ -1376,6 +1389,7 @@ EditCommandEntry EditCommandNameMap[] = { { QueueEditor::eaGroupDelete, "GroupDelete" }, { QueueEditor::eaGroupPauseAllPars, "GroupPauseAllPars" }, { QueueEditor::eaGroupPauseExtraPars, "GroupPauseExtraPars" }, + { QueueEditor::eaGroupSetPriority, "GroupSetPriority" }, { QueueEditor::eaGroupSetCategory, "GroupSetCategory" }, { QueueEditor::eaGroupMerge, "GroupMerge" }, { QueueEditor::eaGroupSetParameter, "GroupSetParameter" }, diff --git a/nzbget.conf.example b/nzbget.conf.example index 434ead13..5d75d9ea 100644 --- a/nzbget.conf.example +++ b/nzbget.conf.example @@ -202,13 +202,22 @@ MergeNzb=no # "SERVER1_HOST". For options with predefined possible values (yes/no, etc.) # the values are passed always in lower case. # -# The nzbprocess-script can assign category or post-processing parameters -# to current nzb-file by printing special messages into standard output -# (which is processed by NZBGet). +# The nzbprocess-script can assign category, priority and post-processing +# parameters to the current nzb-file by printing special messages into +# standard output (which is processed by NZBGet). # # To assign category use following syntax: # echo "[NZB] CATEGORY=my category"; # +# To assign priority: +# echo "[NZB] PRIORITY="; +# +# for example: to set priority higher than normal: +# echo "[NZB] PRIORITY=50"; +# +# another example: use a negative value for "lower than normal" priority: +# echo "[NZB] PRIORITY=-100"; +# # To assign post-processing parameters: # echo "[NZB] NZBPR_myvar=my value"; #