transmission-php icon indicating copy to clipboard operation
transmission-php copied to clipboard

torrent-set method

Open firesalp opened this issue 10 years ago • 12 comments

Hi there!

I saw that the torrent-set method isn't available in the project, and i'd like to add it, but i think i will need a litle help to do it right.

Can I ask you to prepare the PHP Class (Model?) with the right response validator (if it's nedded to be modified), then i will try to add the functions.

Let me know if it's possible.

Thanks, Firescalp

Here is a list of supported requests: 3.2. Torrent Mutators Method name: "torrent-set" Request arguments: string | value type & description

----------------------+------------------------------------------------- "bandwidthPriority" | number this torrent's bandwidth tr_priority_t "downloadLimit" | number maximum download speed (KBps) "downloadLimited" | boolean true if "downloadLimit" is honored "files-wanted" | array indices of file(s) to download "files-unwanted" | array indices of file(s) to not download "honorsSessionLimits" | boolean true if session upload limits are honored "ids" | array torrent list, as described in 3.1 "location" | string new location of the torrent's content "peer-limit" | number maximum number of peers "priority-high" | array indices of high-priority file(s) "priority-low" | array indices of low-priority file(s) "priority-normal" | array indices of normal-priority file(s) "queuePosition" | number position of this torrent in its queue [0...n) "seedIdleLimit" | number torrent-level number of minutes of seeding inactivity "seedIdleMode" | number which seeding inactivity to use. See tr_idlelimit "seedRatioLimit" | double torrent-level seeding ratio "seedRatioMode" | number which ratio to use. See tr_ratiolimit "trackerAdd" | array strings of announce URLs to add "trackerRemove" | array ids of trackers to remove "trackerReplace" | array pairs of <trackerId/new announce URLs> "uploadLimit" | number maximum upload speed (KBps) "uploadLimited" | boolean true if "uploadLimit" is honored

firesalp avatar Oct 10 '14 11:10 firesalp

Can someone give me little help with this? (To do it the right way && project compliant :+1: )

firesalp avatar Oct 20 '14 12:10 firesalp

Hi there! First of all: awesome that you want to contribute! Second, I think this is (with the current setup) a tough one... I'll look into how to best implement it, give me a couple of days!

kleiram avatar Oct 20 '14 13:10 kleiram

Yep that's right, that's why I would your point of view about it. Thanks you for your help!

firesalp avatar Oct 20 '14 14:10 firesalp

I'm currently designing a 2.0 version, it would be awesome if you're willing to help!

kleiram avatar Oct 21 '14 12:10 kleiram

Sure that I want to help! I'm just not as experimented as you but you're welcome. How can I help?

firesalp avatar Oct 21 '14 13:10 firesalp

Quick thing about this, I saw that it actually is implemented (I just wrote it a long time ago).

You can use it by calling save on a torrent object. So I'm going to close this issue!

kleiram avatar Oct 21 '14 13:10 kleiram

I saw yhis was implemented in 'Session.php', but not in torrent.php

firesalp avatar Oct 21 '14 13:10 firesalp

@kleiram Are you sure it's implemented for torrent objects? Can't see it in torrent.php, but it's only existing in session.php.

firesalp avatar Oct 21 '14 15:10 firesalp

Heh, would you look at that. Guess I'll reopen this one again... my bad!

kleiram avatar Oct 21 '14 16:10 kleiram

I took a look at this, created the mapping already and copied the save fonction whith torrent-set method. Now i'm stucking on the class definition; Schould it be "class TorrentSet extends Torrent"?

Can we maybe create a GIT based page where i can put the code I already wrote?

firesalp avatar Oct 22 '14 12:10 firesalp

The thing is: if we use the same "save" fonction, it will save all the mapped parameters. But, as specified in the doc: "Just as an empty "ids" value is shorthand for "all ids", using an empty array for "files-wanted", "files-unwanted", "priority-high", "priority-low", or "priority-normal" is shorthand for saying "all files"."

So I thought doing something like this below, with the proper TorrentSet class defined with differents case switchs. /** * @param string $argument * @param array|bool|string|int|double $value */ public function setOptions($this->id, $argument, $value) { if (TorrentSet::set($this->id, $argument, $value)) { return true; } else { return false } }

This is not very project friendly... Do you have another idea?

firesalp avatar Oct 23 '14 14:10 firesalp

As an alternative, you can make any API call in the spec manually by using the Client class directly.

$transmission = new Transmission\Transmission();
// Make the call manually
$response = $transmission->getClient->call('torrent-set', array(
    ...
));

kristoftorfs avatar Apr 23 '15 08:04 kristoftorfs