summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/AccountManager.py15
-rw-r--r--module/FileDatabase.py5
-rw-r--r--module/plugins/Account.py29
-rw-r--r--module/plugins/accounts/HotfileCom.py3
-rw-r--r--module/plugins/accounts/UploadedTo.py2
-rw-r--r--module/plugins/hoster/HotfileCom.py3
-rw-r--r--module/web/pyload/views.py37
-rw-r--r--module/web/templates/default/settings.html21
-rwxr-xr-xpyLoadCore.py2
9 files changed, 76 insertions, 41 deletions
diff --git a/module/AccountManager.py b/module/AccountManager.py
index 7ef986600..5dedacf3c 100644
--- a/module/AccountManager.py
+++ b/module/AccountManager.py
@@ -103,14 +103,11 @@ class AccountManager():
elif line.startswith("@"):
option = line[1:].split()
- self.accounts[plugin][name]["options"].append(tuple(option))
+ self.accounts[plugin][name]["options"][option[0]] = [option[1]] if len(option) < 3 else option[1:]
elif ":" in line:
- name, sep,pw = line.partition(":")
- self.accounts[plugin][name] = {"password": pw, "options": [], "valid": True}
-
-
-
+ name, sep, pw = line.partition(":")
+ self.accounts[plugin][name] = {"password": pw, "options": {}, "valid": True}
#----------------------------------------------------------------------
def saveAccounts(self):
"""save all account information"""
@@ -124,8 +121,8 @@ class AccountManager():
for name,data in accounts.iteritems():
f.write("\n\t%s:%s\n" % (name,data["password"]) )
- for option in data["options"]:
- f.write("\t@%s\n" % " ".join(option) )
+ for option, values in data["options"].iteritems():
+ f.write("\t@%s %s\n" % (option, " ".join(values)))
f.close()
@@ -137,7 +134,7 @@ class AccountManager():
self.accounts[name] = {}
#----------------------------------------------------------------------
- def updateAccount(self, plugin , user, password, options):
+ def updateAccount(self, plugin , user, password=None, options={}):
"""add or update account"""
if self.accounts.has_key(plugin):
p = self.getAccountPlugin(plugin)
diff --git a/module/FileDatabase.py b/module/FileDatabase.py
index 793a4a69e..6e6537f38 100644
--- a/module/FileDatabase.py
+++ b/module/FileDatabase.py
@@ -62,13 +62,12 @@ def formatSize(size):
size = int(size)
steps = 0
sizes = ["B", "KB", "MB", "GB", "TB"]
-
+
while size > 1000:
size /= 1024.0
steps += 1
-
- return "%.2f %s" % (size, sizes[steps])
+ return "%.2f %s" % (size, sizes[steps])
########################################################################
class FileHandler:
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index 16f2a7b92..8c400f6e5 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -60,10 +60,12 @@ class Account():
for user, data in self.accounts.iteritems():
self._login(user, data)
- def updateAccounts(self, user, password, options):
+ def updateAccounts(self, user, password=None, options={}):
if self.accounts.has_key(user):
- self.accounts[user]["password"] = password
- self.accounts[user]["options"] = options
+ if password:
+ self.accounts[user]["password"] = password
+ if options:
+ self.accounts[user]["options"].update(options)
self.accounts[user]["valid"] = True
else:
self.accounts[user] = {"password" : password, "options": options, "valid": True}
@@ -109,12 +111,18 @@ class Account():
def getAccountRequest(self, user=None):
if not user:
user, data = self.selectAccount()
+ if not user:
+ return None
+
req = self.core.requestFactory.getRequest(self.__name__, user)
return req
def getAccountCookies(self, user=None):
if not user:
user, data = self.selectAccount()
+ if not user:
+ return None
+
cj = self.core.requestFactory.getCookieJar(self.__name__, user)
return cj
@@ -126,13 +134,20 @@ class Account():
usable = []
for user,data in self.accounts.iteritems():
if not data["valid"]: continue
- for option, value in data["options"]:
- pass
- #@TODO comparate time option
+
+ if data["options"].has_key("time"):
+ time = data["options"]["time"][0]
+ try:
+ start, end = time.split("-")
+ if not self.core.compare_time(start.split(":"), end.split(":")):
+ continue
+ except:
+ self.core.log.error(_("Your Time %s has wrong format, use: 1:22-3:44") % time)
+
usable.append((user, data))
- if not usable: return None
+ if not usable: return None, None
return choice(usable)
def canUse(self):
diff --git a/module/plugins/accounts/HotfileCom.py b/module/plugins/accounts/HotfileCom.py
index 83551949d..f623e56f1 100644
--- a/module/plugins/accounts/HotfileCom.py
+++ b/module/plugins/accounts/HotfileCom.py
@@ -19,7 +19,6 @@
from module.plugins.Account import Account
from time import strptime, mktime
-from urllib import unquote
import hashlib
class HotfileCom(Account):
@@ -69,7 +68,7 @@ class HotfileCom(Account):
post.update({"action": method})
post.update({"username":user, "passwordmd5dig":pwhash, "digest":digest})
- return unquote(req.load("http://api.hotfile.com/", post=post)).strip()
+ return req.load("http://api.hotfile.com/", post=post)
def login(self, user, data):
req = self.getAccountRequest(user)
diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py
index 9b51f5aad..4c45fb6fc 100644
--- a/module/plugins/accounts/UploadedTo.py
+++ b/module/plugins/accounts/UploadedTo.py
@@ -41,7 +41,7 @@ class UploadedTo(Account):
return tmp
def login(self, user, data):
- req = self.getAccountRequest()
+ req = self.getAccountRequest(user)
page = req.load("http://uploaded.to/login", post={ "email" : user, "password" : data["password"]}, cookies=True)
if "Login failed!" in page:
self.wrongPassword()
diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py
index 3b88efe1f..228f31649 100644
--- a/module/plugins/hoster/HotfileCom.py
+++ b/module/plugins/hoster/HotfileCom.py
@@ -56,7 +56,7 @@ class HotfileCom(Hoster):
elif self.account and login:
return self.account.apiCall(method, post, self.user)
post.update({"action": method})
- return unquote(self.load("http://api.hotfile.com/", post=post)).strip()
+ return self.load("http://api.hotfile.com/", post=post)
def process(self, pyfile):
self.wantReconnect = False
@@ -81,6 +81,7 @@ class HotfileCom(Hoster):
self.freeDownload()
else:
dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}, self.user)
+ dl = unquote(dl).strip()
self.download(dl)
def downloadHTML(self):
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index 678884790..523fe60ea 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -24,6 +24,18 @@ from django.utils.translation import ugettext as _
def get_sort_key(item):
return item[1]["order"]
+def formatSize(size):
+ """formats size of bytes"""
+ size = int(size)
+ steps = 0
+ sizes = ["B", "KB", "MB", "GB", "TB"]
+
+ while size > 1000:
+ size /= 1024.0
+ steps += 1
+
+ return "%.2f %s" % (size, sizes[steps])
+
def check_server(function):
def _dec(view_func):
def _view(request, * args, ** kwargs):
@@ -303,23 +315,25 @@ def config(request):
elif sec == "Accounts":
if ";" in okey:
action, name = okey.split(";")
-
if action == "delete":
settings.PYLOAD.remove_account(skey, name)
- elif action == "password":
-
- for acc in accs[skey]:
- if acc["login"] == name and value.strip():
- settings.PYLOAD.update_account(skey, name, value)
- elif okey == "newacc" and value:
+ if okey == "newacc" and value:
# add account
pw = request.POST.get("Accounts|%s|newpw" % skey)
settings.PYLOAD.update_account(skey, value, pw)
-
-
+
+ for pluginname, accdata in accs.iteritems():
+ for data in accdata:
+ newpw = request.POST.get("Accounts|%s|password;%s" % (pluginname, data["login"]), "").strip()
+ time = request.POST.get("Accounts|%s|time;%s" % (pluginname, data["login"]), "").strip()
+
+ if newpw or (time and (not data["options"].has_key("time") or time != data["options"]["time"][0])):
+ settings.PYLOAD.update_account(pluginname, data["login"], newpw, {"time": [time]})
+
+
if errors:
messages.append(_("Error occured when setting the following options:"))
messages.append("")
@@ -334,6 +348,8 @@ def config(request):
data["trafficleft"] = _("unlimited")
elif not data["trafficleft"]:
data["trafficleft"] = _("not available")
+ else:
+ data["trafficleft"] = formatSize(data["trafficleft"])
if data["validuntil"] == -1:
data["validuntil"] = _("unlimited")
@@ -342,6 +358,9 @@ def config(request):
else:
t = localtime(data["validuntil"])
data["validuntil"] = strftime("%d-%m-%Y",t)
+
+ if data["options"].has_key("time"):
+ data["time"] = data["options"]["time"][0]
return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {'Plugin':plugin, 'General':conf, 'Accounts': accs}, 'errors': messages}, [status_proc]))
diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html
index f23027210..09fe2e8b1 100644
--- a/module/web/templates/default/settings.html
+++ b/module/web/templates/default/settings.html
@@ -133,33 +133,38 @@
<tr>
<td><label for="{{configname}}|{{plugin}}|password;{{account.login}}" style="color:#424242;">{{account.login}}:</label></td>
<td>
- <input id="{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|password;{{account.login}}" type="password" value="{{account.password}}"/>
+ <input id="{{plugin}}|password;{{account.login}}" name="{{configname}}|{{plugin}}|password;{{account.login}}" type="password" value="{{account.password}}" size="14"/>
</td>
<td>
{% trans "Status:" %}
- <span style="font-weight: bold;">
{% if account.valid %}
+ <span style="font-weight: bold; color:#90ee90;">
{% trans "valid" %}
{% else %}
+ <span style="font-weight: bold; color: #f08080;">
{% trans "not valid" %}
{% endif %}
</span>
- &nbsp;|</td>
+ </td>
<td>
{% trans "Valid until:" %}
<span style="font-weight: bold;">
{{ account.validuntil }}
</span>
- &nbsp;|</td>
+ </td>
<td>
{% trans "Traffic left:" %}
<span style="font-weight: bold;">
{{ account.trafficleft }}
</span>
- &nbsp;|</td>
+ </td>
+ <td>
+ {% trans "Time:" %}
+ <input id="{{configname}}|{{plugin}}|time;{{account.login}}" name="{{configname}}|{{plugin}}|time;{{account.login}}" type="text" size="7" value="{{account.time}}"/>
+ </td>
<td>
{% trans "Delete? " %}
- <input id="{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|delete;{{account.login}}" type="checkbox" value="True"/>
+ <input id="{{configname}}|{{plugin}}|delete;{{account.login}}" name="{{configname}}|{{plugin}}|delete;{{account.login}}" type="checkbox" value="True"/>
</td>
</tr>
@@ -170,14 +175,14 @@
<td><label for="{{configname}}|{{plugin}}|{{account.login}}" style="color:#424242;">{% trans "New account:" %}</label></td>
<td>
- <input id="{{plugin}}|newacc" name="{{configname}}|{{plugin}}|newacc" type="text"/>
+ <input id="{{plugin}}|newacc" name="{{configname}}|{{plugin}}|newacc" type="text" size="14"/>
</td>
</tr>
<tr>
<td><label for="{{configname}}|{{plugin}}|{{account.name}}" style="color:#424242;">{% trans "New password:" %}</label></td>
<td>
- <input id="{{config}}|{{plugin}}" name="{{configname}}|{{plugin}}|newpw" type="password"/>
+ <input id="{{configname}}|{{plugin}}" name="{{configname}}|{{plugin}}|newpw" type="password" size="14"/>
</td>
</tr>
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 9f2e2ab91..aec4cafb2 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -754,7 +754,7 @@ class ServerMethods():
def get_accounts(self, refresh=False):
return self.core.accountManager.getAccountInfos(force=refresh)
- def update_account(self, plugin, account, password, options=[]):
+ def update_account(self, plugin, account, password=None, options={}):
""" create and update account """
self.core.accountManager.updateAccount(plugin, account, password, options)