From f2265a626e404aa2a7e1ce93901d59409b3928ed Mon Sep 17 00:00:00 2001 From: Jan Hoersch Date: Thu, 17 Jan 2013 18:09:27 +0100 Subject: [PATCH 1/3] added limited rate support for downloading files --- README.mkd | 4 +++- putio-cli | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.mkd b/README.mkd index 0f58718..5e8a218 100644 --- a/README.mkd +++ b/README.mkd @@ -23,10 +23,12 @@ Set up the file `~/.config/putio-cli/config`, with the following contents: [download] user=YOUR_PUTIO_USERNAME password=YOUR_PUTIO_PASSWORD + limitrate=0 The `[download]` section is optional, and is used only to retrieve files. If you do not download files using `putio-cli`, then you don't need to fill this -section in. +section in. +You can add limiting bandwith with curl. If 0 it is not limited. The value is in bytes. ## Commands diff --git a/putio-cli b/putio-cli index 2a0f0ac..997e990 100755 --- a/putio-cli +++ b/putio-cli @@ -131,6 +131,8 @@ def fetch_via_curl(url, target, item_name): file_id = open(target, 'wb') c.setopt(pycurl.USERPWD, dl_creds['user']+':'+dl_creds['password']) + if dl_creds['limitrate']: + c.setopt(c.MAX_RECV_SPEED_LARGE, dl_creds['limitrate']) c.setopt(pycurl.WRITEDATA, file_id) c.setopt(pycurl.NOPROGRESS, 0) c.setopt(pycurl.FOLLOWLOCATION, 1) @@ -458,6 +460,7 @@ if __name__ == '__main__': try: dl_creds['user'] = config.get('download', 'user') dl_creds['password'] = config.get('download', 'password') + dl_creds['limitrate'] = config.getint('download','limitrate') except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): dl_creds = {} From 032364e898ec9892953489f0379916fb5823b7b0 Mon Sep 17 00:00:00 2001 From: Jan Hoersch Date: Thu, 17 Jan 2013 18:20:46 +0100 Subject: [PATCH 2/3] fixed bug in putio.py with user info return --- putio-cli | 7 +++++-- putio.py | 25 ++++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/putio-cli b/putio-cli index 997e990..f27f6ca 100755 --- a/putio-cli +++ b/putio-cli @@ -216,8 +216,11 @@ def fetch(url, target, item_name): def info(api, args=[]): """Display user information about available bandwidth and disk space""" me = api.get_user_info() - - print "Available bandwidth : %s/%s" % (putio.human_size(me.bw_quota_available), putio.human_size(me.bw_quota)) + + #print me.bw_quota + print "Name: %s" % (me.name) + print "Friends: %d" % (me.friends_count) + print "Your shared items: %d" % (me.shared_items) print "Available disk space: %s/%s" % (putio.human_size(me.disk_quota_available), putio.human_size(me.disk_quota)) #----- diff --git a/putio.py b/putio.py index 53bbb18..933b219 100644 --- a/putio.py +++ b/putio.py @@ -341,17 +341,13 @@ def __str__(self): class User(BaseObj): """ Sample user: - u.name : 'aft' - u.friends_count : 497 - u.bw_avail_last_month : '0' - u.bw_quota : '161061273600' - u.shared_items : 3 - u.bw_quota_available : '35157040261' - u.disk_quota : '206115891200' - u.disk_quota_available : '158153510402' u.shared_space : 0 - + u.shared_items : 3 + u.mp4_rss : 'http://put.io/rss/mp4/...' + u.disk_quota : '206115891200' + u.disk_quota_available : '158153510402' + u.friends_count : 497 """ def __init__(self, api, dictionary=None, **args): @@ -845,14 +841,13 @@ def get_user_info(self): Returned Attributes: - info.bw_quota - info.disk_quota - info.bw_quota_available - info.disk_quota_available info.name info.shared_space - info.friends_count info.shared_items + info.mp4_rss + info.disk_quota + info.disk_quota_available + info.friends_count """ @@ -1974,4 +1969,4 @@ def __init__(self, api, dictionary=None, **args): if __name__ == '__main__': print "This file should not be executed." - \ No newline at end of file + From 2c69ebc6c792962b8c4e4640d0ace806fd76c368 Mon Sep 17 00:00:00 2001 From: Jan Hoersch Date: Thu, 17 Jan 2013 18:21:36 +0100 Subject: [PATCH 3/3] fixed bug for users with newer python versions --- putio-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/putio-cli b/putio-cli index f27f6ca..9175d74 100755 --- a/putio-cli +++ b/putio-cli @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python2 import sys, os, ConfigParser, time import putio