diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-19 19:36:05 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-19 19:36:17 +0200 |
commit | 873f91be7d3316e93672731e2f3d2da02b41fca6 (patch) | |
tree | 5a12d1a5ac1f0a4aa5fca9ab9e6b86e64f25e388 /pyload/plugins/Download.py | |
parent | Explain how to add tips for translators (diff) | |
download | pyload-873f91be7d3316e93672731e2f3d2da02b41fca6.tar.xz |
new plugin type and refactored request classes
Diffstat (limited to 'pyload/plugins/Download.py')
-rw-r--r-- | pyload/plugins/Download.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pyload/plugins/Download.py b/pyload/plugins/Download.py new file mode 100644 index 000000000..e86089dc3 --- /dev/null +++ b/pyload/plugins/Download.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- + +from Request import Request + +class Download(Request): + """ Abstract class for download request """ + + __version__ = "0.1" + + def __init__(self, bucket, request=None): + # Copies the context + context = request.getContext() if request else [{}] + Request.__init__(self, *context) + + self._running = False + self._name = None + self._size = 0 + + #: bucket used for rate limiting + self.bucket = bucket + + def download(self, uri, path, *args, **kwargs): + """ Downloads the resource with additional options depending on implementation """ + raise NotImplementedError + + @property + def running(self): + return self._running + + @property + def size(self): + """ Size in bytes """ + return self._size + + @property + def name(self): + """ Name of the resource if known """ + return self._name + + @property + def speed(self): + """ Download rate in bytes per second """ + return 0 + + @property + def arrived(self): + """ Number of bytes already loaded """ + return 0
\ No newline at end of file |