Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

torrent-set method #33

Open
firesalp opened this issue Oct 10, 2014 · 12 comments
Open

torrent-set method #33

firesalp opened this issue Oct 10, 2014 · 12 comments

Comments

@firesalp
Copy link
Contributor

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
Copy link
Contributor Author

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

@kleiram
Copy link
Owner

kleiram commented Oct 20, 2014

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!

@firesalp
Copy link
Contributor Author

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

@kleiram
Copy link
Owner

kleiram commented Oct 21, 2014

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

@firesalp
Copy link
Contributor Author

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

@kleiram
Copy link
Owner

kleiram commented Oct 21, 2014

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 kleiram closed this as completed Oct 21, 2014
@firesalp
Copy link
Contributor Author

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

@firesalp
Copy link
Contributor Author

@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.

@kleiram
Copy link
Owner

kleiram commented Oct 21, 2014

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

@kleiram kleiram reopened this Oct 21, 2014
@firesalp
Copy link
Contributor Author

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
Copy link
Contributor Author

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?

@kristoftorfs
Copy link

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(
    ...
));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants