Skip to content

Commit

Permalink
Add $savepath argument to $transmission->add() function
Browse files Browse the repository at this point in the history
If $savepath argument is specified, the torrent will be downloaded to the value of $savepath
  • Loading branch information
firesalp committed Sep 3, 2014
1 parent e1f355d commit 8c9f647
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/Transmission/Transmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,17 @@ public function getFreeSpace($path=null)
* @param boolean $metainfo
* @return Transmission\Model\Torrent
*/
public function add($torrent, $metainfo = false)
public function add($torrent, $metainfo = false, $savepath = null)
{
$parameters = array($metainfo ? 'metainfo' : 'filename' => $torrent);

if ($savepath !== null) {
$parameters['download-dir'] = (string) $savepath;
}

$response = $this->getClient()->call(
'torrent-add',
array($metainfo ? 'metainfo' : 'filename' => $torrent)
$parameters)
);

return $this->getMapper()->map(
Expand Down

0 comments on commit 8c9f647

Please sign in to comment.