Browse Source

add qbit sort

causefx 8 years ago
parent
commit
1243fc031d

+ 2 - 0
api/config/default.php

@@ -54,6 +54,8 @@ return array(
     'qBittorrentPassword' => '',
     'qBittorrentHideSeeding' => false,
     'qBittorrentHideCompleted' => false,
+    'qBittorrentSortOrder' => 'eta',
+    'qBittorrentReverseSorting' => false,    
     'homepageSabnzbdEnabled' => false,
     'homepageSabnzbdAuth' => '1',
 	'homepageSonarrEnabled' => false,

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

@@ -632,7 +632,8 @@ function qBittorrentConnect() {
                 $headers = array(
                     'Cookie' => 'SID=' . $cookie['SID']->value
                 );
-                $url = $digest['scheme'].'://'.$digest['host'].$digest['port'].$digest['path'].'/query/torrents?sort=eta';
+				$reverse = $GLOBALS['qBittorrentReverseSorting'] ? 'true' : 'false';
+                $url = $digest['scheme'].'://'.$digest['host'].$digest['port'].$digest['path'].'/query/torrents?sort=' . $GLOBALS['qBittorrentSortOrder'] . '&reverse=' . $reverse;
                 $response = Requests::get($url, $headers, $options);
                 if($response){
                     $torrentList = json_decode($response->body, true);

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

@@ -329,6 +329,68 @@ function getHomepageList(){
 			'value' => 'H:mm'
 		)
 	);
+	$qBittorrentSortOptions = array(
+		array(
+			'name' => 'Hash',
+			'value' => 'hash'
+		),
+		array(
+			'name' => 'Name',
+			'value' => 'name'
+		),
+		array(
+			'name' => 'Size',
+			'value' => 'size'
+		),
+		array(
+			'name' => 'Progress',
+			'value' => 'progress'
+		),
+		array(
+			'name' => 'Download Speed',
+			'value' => 'dlspeed'
+		),
+		array(
+			'name' => 'Upload Speed',
+			'value' => 'upspeed'
+		),
+		array(
+			'name' => 'Priority',
+			'value' => 'priority'
+		),
+		array(
+			'name' => 'Number of Seeds',
+			'value' => 'num_seeds'
+		),
+		array(
+			'name' => 'Number of Seeds in Swarm',
+			'value' => 'num_complete'
+		),
+		array(
+			'name' => 'Number of Leechers',
+			'value' => 'num_leechs'
+		),
+		array(
+			'name' => 'Number of Leechers in Swarm',
+			'value' => 'num_incomplete'
+		),
+		array(
+			'name' => 'Ratio',
+			'value' => 'ratio'
+		),
+		array(
+			'name' => 'ETA',
+			'value' => 'eta'
+		),
+		array(
+			'name' => 'State',
+			'value' => 'state'
+		),
+		array(
+			'name' => 'Category',
+			'value' => 'category'
+		)
+	);
     return array(
         array(
             'name' => 'Plex',
@@ -776,6 +838,18 @@ function getHomepageList(){
                         'label' => 'Hide Completed',
                         'value' => $GLOBALS['qBittorrentHideCompleted']
                     ),
+					array(
+						'type' => 'select',
+						'name' => 'qBittorrentSortOrder',
+						'label' => 'Order',
+						'value' => $GLOBALS['qBittorrentSortOrder'],
+						'options' => qBittorrentSortOptions()
+					),array(
+						'type' => 'switch',
+						'name' => 'qBittorrentReverseSorting',
+						'label' => 'Reverse Sorting',
+						'value' => $GLOBALS['qBittorrentReverseSorting']
+					),
                     array(
                         'type' => 'select',
                         'name' => 'homepageDownloadRefresh',