Skip to content

Commit

Permalink
Update Torrent.php
Browse files Browse the repository at this point in the history
- Added trackerStats object which returns: host, leecherCount, seederCount, lastScrapeResult, lastAnnounceResult
- Added startDate integer: unix timestamp of when the torrent was started
- Added peersConnected integer: number of peers connected
  • Loading branch information
bilalghouri committed Mar 17, 2015
1 parent 08170ad commit 91b7c27
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions lib/Transmission/Model/Torrent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class Torrent extends AbstractModel
*/
protected $finished;

/**
* @var integer
*/
protected $startDate;
/**
* @var integer
*/
Expand All @@ -53,6 +57,11 @@ class Torrent extends AbstractModel
*/
protected $downloadRate;

/**
* @var integer
*/
protected $peersConnected;

/**
* @var double
*/
Expand All @@ -73,6 +82,11 @@ class Torrent extends AbstractModel
*/
protected $trackers = array();

/**
* @var array
*/
protected $trackerStats = array();

/**
* @var double
*/
Expand Down Expand Up @@ -190,6 +204,21 @@ public function isFinished()
return ($this->finished || (int) $this->getPercentDone() == 100);
}

/**
* @var integer $startDate
*/
public function setStartDate($startDate)
{
$this->startDate = (integer) $startDate;
}

/**
* @return integer
*/
public function getStartDate()
{
return $this->startDate;
}
/**
* @var integer $rate
*/
Expand All @@ -213,6 +242,22 @@ public function setDownloadRate($rate)
{
$this->downloadRate = (integer) $rate;
}

/**
* @param integer $peersConnected
*/
public function setPeersConnected($peersConnected)
{
$this->peersConnected = (integer) $peersConnected;
}

/**
* @return integer
*/
public function getPeersConnected()
{
return $this->peersConnected;
}

/**
* @return integer
Expand Down Expand Up @@ -273,6 +318,23 @@ public function getPeers()
{
return $this->peers;
}
/**
* @param array $trackerStats
*/
public function setTrackerStats(array $trackerStats)
{
$this->trackerStats = array_map(function ($trackerStats) {
return PropertyMapper::map(new trackerStats(), $trackerStats);
}, $trackerStats);
}

/**
* @return array
*/
public function getTrackerStats()
{
return $this->trackerStats;
}

/**
* @param array $trackers
Expand Down Expand Up @@ -357,7 +419,10 @@ public static function getMapping()
'percentDone' => 'percentDone',
'files' => 'files',
'peers' => 'peers',
'peersConnected' => 'peersConnected',
'trackers' => 'trackers',
'trackerStats' => 'trackerStats',
'startDate' => 'startDate',
'uploadRatio' => 'uploadRatio',
'hashString' => 'hash'
);
Expand Down

0 comments on commit 91b7c27

Please sign in to comment.