After creating a client object, communicating with Transmission is a breeze:
>>> response = client('torrent-get', ids=[1,2,3], fields=['name'])
>>> response['torrents']
[{u'name': u'torrent 1'}, {u'name': u'torrent 2'}, {u'name': u'torrent 3'}]
This calls the torrent-get method along with the ids and fields request arguments.
No matter what RPC method you’re calling, the syntax will always be the same:
Parameters: |
|
---|---|
Return type: | A dictionary of the “arguments” object returned from Transmission |
Some request arguments contain dashes in their name. As this is invalid in Python, replace any dashes with underscores:
>>> client('torrent-set', ids=1, peer_limit=30) # instead of 'peer-limit'
The only area where transmission-fluid deviates from the RPC specification is when dealing with timestamps.
The RPC specification returns all date and time information as Unix timestamps. To make life easier for developers, transmission-fluid transparently converts these timestamps to UTC datetime objects:
>>> response = client('torrent-get', ids=1, fields=['addedDate'])
>>> response['torrents']
[{u'addedDate': datetime.datetime(2011, 10, 31, 20, 1, 23)}]
Similarly, you can pass datetime objects as request arguments and they’ll be converted to Unix timestamps before being transmitted to Transmission.
New in version 0.3.