Commits

Erik Svensson committed 05cca26

Added support for Transmission 2.40.

  • Participants
  • Parent commits 1d5a7c4

Comments (0)

Files changed (4)

 Getting started
 ===============
 
-transmissionrpc 0.8 is compatible with Transmission 1.31 - 2.13.
+transmissionrpc 0.8 is compatible with Transmission 1.31 - 2.40.
 
 Requirements
 ------------

transmissionrpc/__init__.py

 # Copyright (c) 2008-2011 Erik Svensson <erik.public@gmail.com>
 # Licensed under the MIT license.
 
-from transmissionrpc.constants import DEFAULT_PORT, DEFAULT_TIMEOUT, STATUS, PRIORITY, RATIO_LIMIT, LOGGER
+from transmissionrpc.constants import DEFAULT_PORT, DEFAULT_TIMEOUT, PRIORITY, RATIO_LIMIT, LOGGER
 from transmissionrpc.error import TransmissionError, HTTPHandlerError
 from transmissionrpc.httphandler import HTTPHandler, DefaultHTTPHandler
 from transmissionrpc.torrent import Torrent

transmissionrpc/constants.py

 
 DEFAULT_TIMEOUT = 30.0
 
-TR_STATUS_CHECK_WAIT   = (1<<0)
-TR_STATUS_CHECK        = (1<<1)
-TR_STATUS_DOWNLOAD     = (1<<2)
-TR_STATUS_SEED         = (1<<3)
-TR_STATUS_STOPPED      = (1<<4)
-
-STATUS = mirror_dict({
-    'check pending' : TR_STATUS_CHECK_WAIT,
-    'checking'      : TR_STATUS_CHECK,
-    'downloading'   : TR_STATUS_DOWNLOAD,
-    'seeding'       : TR_STATUS_SEED,
-    'stopped'       : TR_STATUS_STOPPED,
-})
-
 TR_PRI_LOW    = -1
 TR_PRI_NORMAL =  0
 TR_PRI_HIGH   =  1
         'id':                           ('number', 1, None, None, None, ''),
         'isFinished':                   ('boolean', 9, None, None, None, ''),
         'isPrivate':                    ('boolean', 1, None, None, None, ''),
+        'isStalled':                    ('boolean', 14, None, None, None, ''),
         'lastAnnounceTime':             ('number', 1, 7, None, None, ''),
         'lastScrapeTime':               ('number', 1, 7, None, None, ''),
         'leechers':                     ('number', 1, 7, None, None, ''),
         'pieceCount':                   ('number', 1, None, None, None, ''),
         'pieceSize':                    ('number', 1, None, None, None, ''),
         'priorities':                   ('array', 1, None, None, None, ''),
+        'queuePosition':                ('number', 14, None, None, None, ''),
         'rateDownload':                 ('number', 1, None, None, None, ''),
         'rateUpload':                   ('number', 1, None, None, None, ''),
         'recheckProgress':              ('double', 1, None, None, None, ''),
         'priority-high':                ('array', 1, None, None, None, "A list of file id's that should have high priority."),
         'priority-low':                 ('array', 1, None, None, None, "A list of file id's that should have normal priority."),
         'priority-normal':              ('array', 1, None, None, None, "A list of file id's that should have low priority."),
+        'queuePosition':                ('number', 14, None, None, None, 'Position of this torrent in its queue.'),
         'seedIdleLimit':                ('number', 10, None, None, None, 'Seed inactivity limit in minutes.'),
         'seedIdleMode':                 ('number', 10, None, None, None, 'Seed inactivity mode. 0 = Use session limit, 1 = Use transfer limit, 2 = Disable limit.'),
         'seedRatioLimit':               ('double', 5, None, None, None, 'Seeding ratio.'),
         "dht-enabled":                  ('boolean', 6, None, None, None, ''),
         "download-dir":                 ('string', 1, None, None, None, ''),
         "download-dir-free-space":      ('number', 12, None, None, None, ''),
+        "download-queue-size":          ('number', 14, None, None, None, ''),
+        "download-queue-enabled":       ('boolean', 14, None, None, None, ''),
         "encryption":                   ('string', 1, None, None, None, ''),
         "idle-seeding-limit":           ('number', 10, None, None, None, ''),
         "idle-seeding-limit-enabled":   ('boolean', 10, None, None, None, ''),
         "peer-port":                    ('number', 5, None, None, None, ''),
         "peer-port-random-on-start":    ('boolean', 5, None, None, None, ''),
         "port-forwarding-enabled":      ('boolean', 1, None, None, None, ''),
+        "queue-stalled-minutes":        ('number', 14, None, None, None, ''),
+        "queue-stalled-enabled":        ('boolean', 14, None, None, None, ''),
         "rename-partial-files":         ('boolean', 8, None, None, None, ''),
         "rpc-version":                  ('number', 4, None, None, None, ''),
         "rpc-version-minimum":          ('number', 4, None, None, None, ''),
         "script-torrent-done-filename": ('string', 9, None, None, None, ''),
         "seedRatioLimit":               ('double', 5, None, None, None, ''),
         "seedRatioLimited":             ('boolean', 5, None, None, None, ''),
+        "seed-queue-size":              ('number', 14, None, None, None, ''),
+        "seed-queue-enabled":           ('boolean', 14, None, None, None, ''),
         "speed-limit-down":             ('number', 1, None, None, None, ''),
         "speed-limit-down-enabled":     ('boolean', 1, None, None, None, ''),
         "speed-limit-up":               ('number', 1, None, None, None, ''),

transmissionrpc/torrent.py

 
 import sys, datetime
 
-from transmissionrpc.constants import STATUS, PRIORITY
+from transmissionrpc.constants import PRIORITY
 from transmissionrpc.utils import format_timedelta
 
 class Torrent(object):
 
     def __copy__(self):
         return Torrent(self.client, self.fields)
+    
+    def _status_old(self, code):
+        mapping = {
+            (1<<0): 'check pending',
+            (1<<1): 'checking',
+            (1<<2): 'downloading',
+            (1<<3): 'seeding',
+            (1<<4): 'stopped',
+        }
+        return mapping[code]
+    
+    def _status_new(self, code):
+        mapping = {
+            0: 'stopped',
+            1: 'check pending',
+            2: 'checking',
+            3: 'download pending',
+            4: 'downloading',
+            5: 'seed pending',
+            6: 'seeding',
+        }
+        return mapping[code]
+    
+    def _status(self):
+        code = self.fields['status']
+        if self.client.protocol_version >= 14:
+            return self._status_new(code)
+        else:
+            return self._status_old(code)
 
     def update(self, other):
         """
         'downloading', 'seeding' or 'stopped'. The first two is related to
         verification.
         """
-        return STATUS[self.fields['status']]
+        return self._status()
 
     @property
     def progress(self):