kleiram / transmission-php

PHP Transmission API client
Other
184 stars 62 forks source link

get list of ID's #48

Closed toninog closed 9 years ago

toninog commented 9 years ago

Hi

Is there a way to get a list of the active torrents ? I can see the $torrents = $transmission->all();

but how do you get the id's from that ?

Thanks

kleiram commented 9 years ago

Hi there! The Transmission::all method returns an array of Transmission\Model\Torrent objects. This model has a Torrent::getId() method to retrieve the identifier of the torrent. So for example, you could do:

foreach ($transmission->all() as $torrent) {
    $id = $torrent->getId();
}

I think you should be careful with using the torrents though, since they seem to change when Transmission restarts (could be wrong though!).

toninog commented 9 years ago

Perfect thanks.

kleiram commented 9 years ago

You're welcome!