Browse Source

Added limit to rTorrent

CauseFX 5 years ago
parent
commit
b95378450d

+ 1 - 0
api/config/default.php

@@ -100,6 +100,7 @@ return array(
 	'rTorrentReverseSorting' => false,
 	'rTorrentCombine' => false,
 	'rTorrentDisableCertCheck' => false,
+	'rTorrentLimit' => '200',
 	'homepageCalendarEnabled' => false,
 	'homepageCalendarAuth' => '4',
 	'calendariCal' => '',

+ 2 - 0
api/functions/homepage-connect-functions.php

@@ -1035,6 +1035,7 @@ function rTorrentConnect()
 {
 	if ($GLOBALS['homepagerTorrentEnabled'] && (!empty($GLOBALS['rTorrentURL']) || !empty($GLOBALS['rTorrentURLOverride'])) && qualifyRequest($GLOBALS['homepagerTorrentAuth'])) {
 		try {
+			if($GLOBALS['rTorrentLimit'] == '0') { $GLOBALS['rTorrentLimit'] = '1000'; }
 			$torrents = array();
 			$digest = (empty($GLOBALS['rTorrentURLOverride'])) ? qualifyURL($GLOBALS['rTorrentURL'], true) : qualifyURL(checkOverrideURL($GLOBALS['rTorrentURL'], $GLOBALS['rTorrentURLOverride']), true);
 			$passwordInclude = ($GLOBALS['rTorrentUsername'] !== '' && $GLOBALS['rTorrentPassword'] !== '') ? $GLOBALS['rTorrentUsername'] . ':' . decrypt($GLOBALS['rTorrentPassword']) . "@" : '';
@@ -1124,6 +1125,7 @@ function rTorrentConnect()
 								return $b['date'] <=> $a['date'];
 						}
 					});
+					$torrents = array_slice($torrents, 0, $GLOBALS['rTorrentLimit']);
 				}
 				$api['content']['queueItems'] = $torrents;
 				$api['content']['historyItems'] = false;

+ 6 - 0
api/functions/homepage-functions.php

@@ -1603,6 +1603,12 @@ function getHomepageList()
 						'value' => $GLOBALS['homepageDownloadRefresh'],
 						'options' => optionTime()
 					),
+					array(
+						'type' => 'number',
+						'name' => 'rTorrentLimit',
+						'label' => 'Item Limit',
+						'value' => $GLOBALS['rTorrentLimit'],
+					),
 					array(
 						'type' => 'switch',
 						'name' => 'rTorrentCombine',