diff options
| author | 2015-03-14 11:07:54 +0100 | |
|---|---|---|
| committer | 2015-03-14 11:07:54 +0100 | |
| commit | e65d19ee3a1e435bf2896ed829e5581eeef92dd2 (patch) | |
| tree | cf5bb073899205a2f00ddeca8df8b9f3944ea835 /module/plugins | |
| parent | [HotFolder] Missing exception (diff) | |
| download | pyload-e65d19ee3a1e435bf2896ed829e5581eeef92dd2.tar.xz | |
Import cleanup for datetime and time modules
Diffstat (limited to 'module/plugins')
51 files changed, 126 insertions, 148 deletions
diff --git a/module/plugins/accounts/AlldebridCom.py b/module/plugins/accounts/AlldebridCom.py index c830f0c09..f9c1f2ca6 100644 --- a/module/plugins/accounts/AlldebridCom.py +++ b/module/plugins/accounts/AlldebridCom.py @@ -1,10 +1,9 @@  # -*- coding: utf-8 -*-  import re +import time  import xml.dom.minidom as dom -from time import time -  from BeautifulSoup import BeautifulSoup  from module.plugins.Account import Account @@ -33,7 +32,7 @@ class AlldebridCom(Account):              p = re.compile('\d+')              exp_data = p.findall(time_text) -            exp_time = time() + int(exp_data[0]) * 24 * 60 * 60 + int( +            exp_time = time.time() + int(exp_data[0]) * 24 * 60 * 60 + int(                  exp_data[1]) * 60 * 60 + (int(exp_data[2]) - 1) * 60          #Get expiration date from API @@ -45,7 +44,7 @@ class AlldebridCom(Account):              self.logDebug(html)              xml = dom.parseString(html) -            exp_time = time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60 +            exp_time = time.time() + int(xml.getElementsByTagName("date")[0].childNodes[0].nodeValue) * 24 * 60 * 60          account_info = {"validuntil": exp_time, "trafficleft": -1}          return account_info diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py index ec4d706ae..bb42f443f 100644 --- a/module/plugins/accounts/CatShareNet.py +++ b/module/plugins/accounts/CatShareNet.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -36,7 +35,7 @@ class CatShareNet(Account):              expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1)              self.logDebug("Expire date: " + expiredate) -            validuntil = mktime(strptime(expiredate, "%Y-%m-%d %H:%M:%S")) +            validuntil = time.mktime(time.strptime(expiredate, "%Y-%m-%d %H:%M:%S"))          except Exception:              pass diff --git a/module/plugins/accounts/CzshareCom.py b/module/plugins/accounts/CzshareCom.py index 202a88e25..300943828 100644 --- a/module/plugins/accounts/CzshareCom.py +++ b/module/plugins/accounts/CzshareCom.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*- -from time import mktime, strptime  import re +import time  from module.plugins.Account import Account @@ -30,7 +30,7 @@ class CzshareCom(Account):          try:              m = re.search(self.CREDIT_LEFT_PATTERN, html)              trafficleft = self.parseTraffic(m.group(1).replace(' ', '').replace(',', '.')) + m.group(2) -            validuntil  = mktime(strptime(m.group(3), '%d.%m.%y %H:%M')) +            validuntil  = time.mktime(time.strptime(m.group(3), '%d.%m.%y %H:%M'))          except Exception, e:              self.logError(e) diff --git a/module/plugins/accounts/DebridItaliaCom.py b/module/plugins/accounts/DebridItaliaCom.py index 50f9aea27..3df99101a 100644 --- a/module/plugins/accounts/DebridItaliaCom.py +++ b/module/plugins/accounts/DebridItaliaCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -28,7 +27,7 @@ class DebridItaliaCom(Account):          if 'Account premium not activated' not in html:              m = re.search(self.WALID_UNTIL_PATTERN, html)              if m: -                validuntil = mktime(strptime(m.group(1), "%d/%m/%Y %H:%M")) +                validuntil = time.mktime(time.strptime(m.group(1), "%d/%m/%Y %H:%M"))                  info = {"premium": True, "validuntil": validuntil, "trafficleft": -1}              else:                  self.logError(_("Unable to retrieve account information")) diff --git a/module/plugins/accounts/DepositfilesCom.py b/module/plugins/accounts/DepositfilesCom.py index dfe430276..a0bd6a37c 100644 --- a/module/plugins/accounts/DepositfilesCom.py +++ b/module/plugins/accounts/DepositfilesCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import strptime, mktime +import time  from module.plugins.Account import Account @@ -23,7 +22,7 @@ class DepositfilesCom(Account):          html = req.load("https://dfiles.eu/de/gold/")          validuntil = re.search(r"Sie haben Gold Zugang bis: <b>(.*?)</b></div>", html).group(1) -        validuntil = mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S")) +        validuntil = time.mktime(time.strptime(validuntil, "%Y-%m-%d %H:%M:%S"))          return {"validuntil": validuntil, "trafficleft": -1} diff --git a/module/plugins/accounts/EuroshareEu.py b/module/plugins/accounts/EuroshareEu.py index f92a4e821..db4539e2e 100644 --- a/module/plugins/accounts/EuroshareEu.py +++ b/module/plugins/accounts/EuroshareEu.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*- -from time import mktime, strptime  import re +import time  from module.plugins.Account import Account @@ -25,7 +25,7 @@ class EuroshareEu(Account):              premium, validuntil = False, -1          else:              premium = True -            validuntil = mktime(strptime(m.group(1), "%d.%m.%Y %H:%M")) +            validuntil = time.mktime(time.strptime(m.group(1), "%d.%m.%Y %H:%M"))          return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} diff --git a/module/plugins/accounts/FilefactoryCom.py b/module/plugins/accounts/FilefactoryCom.py index 426d572db..f07f4895a 100644 --- a/module/plugins/accounts/FilefactoryCom.py +++ b/module/plugins/accounts/FilefactoryCom.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*-  import re -from time import mktime, strptime +import time  from pycurl import REFERER @@ -29,7 +29,7 @@ class FilefactoryCom(Account):          if m:              premium = True              validuntil = re.sub(self.VALID_UNTIL_PATTERN, '\g<D> \g<M> \g<Y>', m.group(0)) -            validuntil = mktime(strptime(validuntil, "%d %b %Y")) +            validuntil = time.mktime(time.strptime(validuntil, "%d %b %Y"))          else:              premium = False              validuntil = -1 diff --git a/module/plugins/accounts/FilejungleCom.py b/module/plugins/accounts/FilejungleCom.py index 9f7474207..b92a371a5 100644 --- a/module/plugins/accounts/FilejungleCom.py +++ b/module/plugins/accounts/FilejungleCom.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*-  import re -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -28,7 +28,7 @@ class FilejungleCom(Account):          m = re.search(self.TRAFFIC_LEFT_PATTERN, html)          if m:              premium = True -            validuntil = mktime(strptime(m.group(1), "%d %b %Y")) +            validuntil = time.mktime(time.strptime(m.group(1), "%d %b %Y"))          else:              premium = False              validuntil = -1 diff --git a/module/plugins/accounts/FileserveCom.py b/module/plugins/accounts/FileserveCom.py index 1cf2a3a3c..5eb6b844c 100644 --- a/module/plugins/accounts/FileserveCom.py +++ b/module/plugins/accounts/FileserveCom.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- -from time import mktime, strptime +import time  from module.plugins.Account import Account  from module.common.json_layer import json_loads @@ -24,7 +24,7 @@ class FileserveCom(Account):          res = json_loads(html)          if res['type'] == "premium": -            validuntil = mktime(strptime(res['expireTime'], "%Y-%m-%d %H:%M:%S")) +            validuntil = time.mktime(time.strptime(res['expireTime'], "%Y-%m-%d %H:%M:%S"))              return {"trafficleft": res['traffic'], "validuntil": validuntil}          else:              return {"premium": False, "trafficleft": None, "validuntil": None} diff --git a/module/plugins/accounts/FreakshareCom.py b/module/plugins/accounts/FreakshareCom.py index a1c7b5662..ca3602a2c 100644 --- a/module/plugins/accounts/FreakshareCom.py +++ b/module/plugins/accounts/FreakshareCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import strptime, mktime +import time  from module.plugins.Account import Account @@ -26,7 +25,7 @@ class FreakshareCom(Account):          try:              m = re.search(r'ltig bis:</td>\s*<td><b>([\d.:-]+)</b></td>', html, re.M) -            validuntil = mktime(strptime(m.group(1).strip(), "%d.%m.%Y - %H:%M")) +            validuntil = time.mktime(time.strptime(m.group(1).strip(), "%d.%m.%Y - %H:%M"))          except Exception:              pass diff --git a/module/plugins/accounts/FshareVn.py b/module/plugins/accounts/FshareVn.py index 66d912958..0c76e2824 100644 --- a/module/plugins/accounts/FshareVn.py +++ b/module/plugins/accounts/FshareVn.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -35,7 +34,7 @@ class FshareVn(Account):          m = re.search(self.VALID_UNTIL_PATTERN, html)          if m:              premium = True -            validuntil = mktime(strptime(m.group(1), '%I:%M:%S %p %d-%m-%Y')) +            validuntil = time.mktime(time.strptime(m.group(1), '%I:%M:%S %p %d-%m-%Y'))              trafficleft = self.getTrafficLeft()          else:              premium = False diff --git a/module/plugins/accounts/Keep2ShareCc.py b/module/plugins/accounts/Keep2ShareCc.py index 9f28799a2..d2ba1d237 100644 --- a/module/plugins/accounts/Keep2ShareCc.py +++ b/module/plugins/accounts/Keep2ShareCc.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import gmtime, mktime, strptime +import time  from module.plugins.Account import Account @@ -41,13 +40,13 @@ class Keep2ShareCc(Account):                  validuntil = -1              else:                  try: -                    validuntil = mktime(strptime(expiredate, "%Y.%m.%d")) +                    validuntil = time.mktime(time.strptime(expiredate, "%Y.%m.%d"))                  except Exception, e:                      self.logError(e)                  else: -                    premium = True if validuntil > mktime(gmtime()) else False +                    premium = True if validuntil > time.mktime(time.gmtime()) else False              m = re.search(self.TRAFFIC_LEFT_PATTERN, html)              if m: diff --git a/module/plugins/accounts/MegaRapidCz.py b/module/plugins/accounts/MegaRapidCz.py index b229fe47d..262d5a818 100644 --- a/module/plugins/accounts/MegaRapidCz.py +++ b/module/plugins/accounts/MegaRapidCz.py @@ -1,8 +1,8 @@  # -*- coding: utf-8 -*-  import re +import time -from time import mktime, strptime  from module.plugins.Account import Account @@ -34,7 +34,7 @@ class MegaRapidCz(Account):          m = re.search(self.VALID_UNTIL_PATTERN, htmll)          if m: -            validuntil = mktime(strptime(m.group(1), "%d.%m.%Y - %H:%M")) +            validuntil = time.mktime(time.strptime(m.group(1), "%d.%m.%Y - %H:%M"))              return {"premium": True, "trafficleft": -1, "validuntil": validuntil}          m = re.search(self.TRAFFIC_LEFT_PATTERN, htmll) diff --git a/module/plugins/accounts/MegasharesCom.py b/module/plugins/accounts/MegasharesCom.py index 127ebadc8..3d7ddbe46 100644 --- a/module/plugins/accounts/MegasharesCom.py +++ b/module/plugins/accounts/MegasharesCom.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*-  import re -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -29,7 +29,7 @@ class MegasharesCom(Account):          try:              timestr = re.search(self.VALID_UNTIL_PATTERN, html).group(1)              self.logDebug(timestr) -            validuntil = mktime(strptime(timestr, "%b %d, %Y")) +            validuntil = time.mktime(time.strptime(timestr, "%b %d, %Y"))          except Exception, e:              self.logError(e) diff --git a/module/plugins/accounts/MyfastfileCom.py b/module/plugins/accounts/MyfastfileCom.py index 4c75b27f0..9a13e2e42 100644 --- a/module/plugins/accounts/MyfastfileCom.py +++ b/module/plugins/accounts/MyfastfileCom.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- -from time import time +import time  from module.common.json_layer import json_loads  from module.plugins.Account import Account @@ -18,7 +18,7 @@ class MyfastfileCom(Account):      def loadAccountInfo(self, user, req):          if 'days_left' in self.json_data: -            validuntil = time() + self.json_data['days_left'] * 24 * 60 * 60 +            validuntil = time.time() + self.json_data['days_left'] * 24 * 60 * 60              return {"premium": True, "validuntil": validuntil, "trafficleft": -1}          else:              self.logError(_("Unable to get account information")) diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py index a36b114eb..7e3f757d3 100644 --- a/module/plugins/accounts/NoPremiumPl.py +++ b/module/plugins/accounts/NoPremiumPl.py @@ -1,10 +1,10 @@  # -*- coding: utf-8 -*- -from datetime import datetime +import datetime  import hashlib +import time  from module.plugins.Account import Account -from time import mktime  from module.common.json_layer import json_loads as loads @@ -44,7 +44,7 @@ class NoPremiumPl(Account):          if "expire" in result.keys() and result["expire"]:              premium = True -            valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) +            valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple())          traffic_left = result["balance"] * 1024          return ({ diff --git a/module/plugins/accounts/NowVideoSx.py b/module/plugins/accounts/NowVideoSx.py index f44ae3865..2f7b033bd 100644 --- a/module/plugins/accounts/NowVideoSx.py +++ b/module/plugins/accounts/NowVideoSx.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import gmtime, mktime, strptime +import time  from module.plugins.Account import Account @@ -33,13 +32,13 @@ class NowVideoSx(Account):              self.logDebug("Expire date: " + expiredate)              try: -                validuntil = mktime(strptime(expiredate, "%Y-%b-%d")) +                validuntil = time.mktime(time.strptime(expiredate, "%Y-%b-%d"))              except Exception, e:                  self.logError(e)              else: -                if validuntil > mktime(gmtime()): +                if validuntil > time.mktime(time.gmtime()):                      premium = True                  else:                      premium = False diff --git a/module/plugins/accounts/OneFichierCom.py b/module/plugins/accounts/OneFichierCom.py index 1fc8d994d..be4b5e67e 100644 --- a/module/plugins/accounts/OneFichierCom.py +++ b/module/plugins/accounts/OneFichierCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import strptime, mktime +import time  from pycurl import REFERER @@ -36,7 +35,7 @@ class OneFichierCom(Account):              self.logDebug("Expire date: " + expiredate)              try: -                validuntil = mktime(strptime(expiredate, "%d/%m/%Y")) +                validuntil = time.mktime(time.strptime(expiredate, "%d/%m/%Y"))              except Exception, e:                  self.logError(e)              else: diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 426c680a6..3e9d52fe8 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -1,10 +1,10 @@  # -*- coding: utf-8 -*- -from datetime import datetime +import datetime  import hashlib +import time  from module.plugins.Account import Account -from time import mktime  from module.common.json_layer import json_loads as loads @@ -43,7 +43,7 @@ class RapideoPl(Account):          valid_untill = -1          if "expire" in result.keys() and result["expire"]:              premium = True -            valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) +            valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple())          traffic_left = result["balance"] diff --git a/module/plugins/accounts/RapiduNet.py b/module/plugins/accounts/RapiduNet.py index 8da698c57..70f47b673 100644 --- a/module/plugins/accounts/RapiduNet.py +++ b/module/plugins/accounts/RapiduNet.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import time +import time  from module.plugins.Account import Account  from module.common.json_layer import json_loads @@ -38,7 +37,7 @@ class RapiduNet(Account):          m = re.search(self.VALID_UNTIL_PATTERN, html)          if m: -            validuntil = time() + (86400 * int(m.group(1))) +            validuntil = time.time() + (86400 * int(m.group(1)))          m = re.search(self.TRAFFIC_LEFT_PATTERN, html)          if m: diff --git a/module/plugins/accounts/SimplydebridCom.py b/module/plugins/accounts/SimplydebridCom.py index 29be2f73d..24108eb0b 100644 --- a/module/plugins/accounts/SimplydebridCom.py +++ b/module/plugins/accounts/SimplydebridCom.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -22,7 +22,7 @@ class SimplydebridCom(Account):          if str(data[0]) != "1":              return {"premium": False}          else: -            return {"trafficleft": -1, "validuntil": mktime(strptime(str(data[2]), "%d/%m/%Y"))} +            return {"trafficleft": -1, "validuntil": time.mktime(time.strptime(str(data[2]), "%d/%m/%Y"))}      def login(self, user, data, req): diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index e6c25752b..87efb89b3 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -1,9 +1,9 @@  # -*- coding: utf-8 -*-  import hashlib +import time  from beaker.crypto.pbkdf2 import PBKDF2 -from time import time  from module.common.json_layer import json_loads  from module.plugins.Account import Account @@ -36,7 +36,7 @@ class SmoozedCom(Account):                      'session'    : status["data"]["session_key"],                      'hosters'    : [hoster["name"] for hoster in status["data"]["hoster"]]} -            if info['validuntil'] < time(): +            if info['validuntil'] < time.time():                  info['premium'] = False              else:                  info['premium'] = True diff --git a/module/plugins/accounts/TurbobitNet.py b/module/plugins/accounts/TurbobitNet.py index a857649eb..010fbc270 100644 --- a/module/plugins/accounts/TurbobitNet.py +++ b/module/plugins/accounts/TurbobitNet.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*-  import re -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -22,7 +22,7 @@ class TurbobitNet(Account):          m = re.search(r'<u>Turbo Access</u> to ([\d.]+)', html)          if m:              premium = True -            validuntil = mktime(strptime(m.group(1), "%d.%m.%Y")) +            validuntil = time.mktime(time.strptime(m.group(1), "%d.%m.%Y"))          else:              premium = False              validuntil = -1 diff --git a/module/plugins/accounts/TusfilesNet.py b/module/plugins/accounts/TusfilesNet.py index 279dfd00a..d06ba0583 100644 --- a/module/plugins/accounts/TusfilesNet.py +++ b/module/plugins/accounts/TusfilesNet.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import mktime, strptime, gmtime +import time  from module.plugins.internal.XFSAccount import XFSAccount diff --git a/module/plugins/accounts/UploadedTo.py b/module/plugins/accounts/UploadedTo.py index 4e5c8035b..d1556b6db 100644 --- a/module/plugins/accounts/UploadedTo.py +++ b/module/plugins/accounts/UploadedTo.py @@ -1,7 +1,7 @@  # -*- coding: utf-8 -*-  import re -from time import time +import time  from module.plugins.Account import Account @@ -39,7 +39,7 @@ class UploadedTo(Account):              else:                  m = re.findall(r'(\d+) (week|day|hour)', expiredate)                  if m: -                    validuntil = time() +                    validuntil = time.time()                      for n, u in m:                          validuntil += float(n) * 60 * 60 * {'week': 168, 'day': 24, 'hour': 1}[u] diff --git a/module/plugins/accounts/UploadingCom.py b/module/plugins/accounts/UploadingCom.py index c70d2ec11..5d02ff3a3 100644 --- a/module/plugins/accounts/UploadingCom.py +++ b/module/plugins/accounts/UploadingCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import time, strptime, mktime +import time  from module.plugins.Account import Account  from module.plugins.internal.SimpleHoster import set_cookies @@ -37,13 +36,13 @@ class UploadingCom(Account):              self.logDebug("Expire date: " + expiredate)              try: -                validuntil = mktime(strptime(expiredate, "%b %d, %Y")) +                validuntil = time.mktime(time.strptime(expiredate, "%b %d, %Y"))              except Exception, e:                  self.logError(e)              else: -                if validuntil > mktime(gmtime()): +                if validuntil > time.mktime(time.gmtime()):                      premium = True                  else:                      premium = False @@ -59,5 +58,5 @@ class UploadingCom(Account):                       ("uploading.com", "_lang", "en")]          req.load("http://uploading.com/") -        req.load("http://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time() * 1000), +        req.load("http://uploading.com/general/login_form/?JsHttpRequest=%s-xml" % long(time.time() * 1000),                   post={'email': user, 'password': data['password'], 'remember': "on"}) diff --git a/module/plugins/accounts/WebshareCz.py b/module/plugins/accounts/WebshareCz.py index f8e3eeb73..3c5f45d34 100644 --- a/module/plugins/accounts/WebshareCz.py +++ b/module/plugins/accounts/WebshareCz.py @@ -1,10 +1,10 @@  # -*- coding: utf-8 -*-  import re +import time  from hashlib import md5, sha1  from passlib.hash import md5_crypt -from time import mktime, strptime, time  from module.plugins.Account import Account @@ -34,9 +34,9 @@ class WebshareCz(Account):          expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1)          self.logDebug("Expire date: " + expiredate) -        validuntil  = mktime(strptime(expiredate, "%Y-%m-%d %H:%M:%S")) +        validuntil  = time.mktime(time.strptime(expiredate, "%Y-%m-%d %H:%M:%S"))          trafficleft = self.parseTraffic(re.search(self.TRAFFIC_LEFT_PATTERN, html).group(1)) -        premium     = validuntil > time() +        premium     = validuntil > time.time()          return {'validuntil': validuntil, 'trafficleft': -1, 'premium': premium} diff --git a/module/plugins/accounts/ZeveraCom.py b/module/plugins/accounts/ZeveraCom.py index d1585111a..9bc6d0487 100644 --- a/module/plugins/accounts/ZeveraCom.py +++ b/module/plugins/accounts/ZeveraCom.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- -from time import mktime, strptime +import time  from module.plugins.Account import Account @@ -40,7 +40,7 @@ class ZeveraCom(Account):          api = self.api_response(req)          if "No trafic" not in api and api['endsubscriptiondate'] != "Expired!": -            validuntil  = mktime(strptime(api['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")) +            validuntil  = time.mktime(time.strptime(api['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S"))              trafficleft = float(api['availabletodaytraffic']) * 1024 if api['orondaytrafficlimit'] != '0' else -1              premium     = True diff --git a/module/plugins/crypter/DlProtectCom.py b/module/plugins/crypter/DlProtectCom.py index 4a188aa83..5c20942ff 100644 --- a/module/plugins/crypter/DlProtectCom.py +++ b/module/plugins/crypter/DlProtectCom.py @@ -1,9 +1,9 @@  # -*- coding: utf-8 -*-  import re +import time  from base64 import urlsafe_b64encode -from time import time  from module.plugins.internal.SimpleCrypter import SimpleCrypter, create_getInfo @@ -40,7 +40,7 @@ class DlProtectCom(SimpleCrypter):              self.wait(2)          else: -            mstime  = int(round(time() * 1000)) +            mstime  = int(round(time.time() * 1000))              b64time = "_" + urlsafe_b64encode(str(mstime)).replace("=", "%3D")              post_req.update({'i'         : b64time, diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 6d42416ff..825db510b 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -3,9 +3,9 @@  from __future__ import with_statement  import re +import time  from base64 import b64encode -from time import sleep  from module.network.HTTPRequest import BadHeader  from module.network.RequestFactory import getURL @@ -134,7 +134,7 @@ class Captcha9Kw(Hook):              try:                  res = getURL(self.API_URL, post=post_data)              except BadHeader, e: -                sleep(3) +                time.sleep(3)              else:                  if res and res.isdigit():                      break @@ -156,7 +156,7 @@ class Captcha9Kw(Hook):                                   'action': "usercaptchacorrectdata"})              if not result or result == "NO DATA": -                sleep(5) +                time.sleep(5)              else:                  break          else: @@ -193,7 +193,7 @@ class Captcha9Kw(Hook):              if queue < re.search(r'queue=(\d+)', servercheck).group(1):                  break -            sleep(10) +            time.sleep(10)          else:              self.fail(_("Too many captchas in queue")) @@ -244,7 +244,7 @@ class Captcha9Kw(Hook):              if res == "OK":                  break -            sleep(5) +            time.sleep(5)          else:              self.logDebug("Could not send %s request: %s" % (type, res)) diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index 5350b4f7d..161f2805b 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -4,13 +4,13 @@ from __future__ import with_statement  import StringIO  import pycurl +import time  try:      from PIL import Image  except ImportError:      import Image -from time import sleep  from urllib import urlencode  from module.network.RequestFactory import getURL, getRequest @@ -117,7 +117,7 @@ class CaptchaBrotherhood(Hook):          ticket = res[3:]          for _i in xrange(15): -            sleep(5) +            time.sleep(5)              res = self.api_response("askCaptchaResult", ticket)              if res.startswith("OK-answered"):                  return ticket, res[12:] diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 4eefb2bff..e408dcab7 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -3,10 +3,10 @@  from __future__ import with_statement  import re +import time  from base64 import b64encode  from pycurl import FORM_FILE, HTTPHEADER -from time import sleep  from module.common.json_layer import json_loads  from module.network.HTTPRequest import BadHeader @@ -152,7 +152,7 @@ class DeathByCaptcha(Hook):          ticket = res['captcha']          for _i in xrange(24): -            sleep(5) +            time.sleep(5)              res = self.api_response("captcha/%d" % ticket, False)              if res['text'] and res['is_correct']:                  break diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index 3b7ae524c..f24faa684 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import localtime +import time  from module.plugins.Hook import Hook @@ -45,7 +44,7 @@ class DownloadScheduler(Hook):              self.logError(_("Invalid schedule"))              return -        t0 = localtime() +        t0  = time.localtime()          now = (t0.tm_hour, t0.tm_min, t0.tm_sec, "X")          schedule = sorted([(int(x[0]), int(x[1]), 0, int(x[2])) for x in schedule] + [now]) diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 1c90c0e2f..7032c6592 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -8,7 +8,6 @@ import time  from pycurl import FORM_FILE  from select import select  from threading import Thread -from time import sleep  from traceback import print_exc  from module.Api import PackageDoesNotExists, FileDoesNotExists @@ -116,7 +115,7 @@ class IRCInterface(Thread, Hook):      def main_loop(self):          readbuffer = ""          while True: -            sleep(1) +            time.sleep(1)              fdset = select([self.sock], [], [], 0)              if self.sock not in fdset[0]:                  continue diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 9093c8459..7ea3378ec 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -1,6 +1,6 @@  # -*- coding: utf-8 -*- -from time import time +import time  from module.plugins.Hook import Hook @@ -80,7 +80,7 @@ class Interface(object):      def useFor(self, pluginName, account): -        self.history[(pluginName, account)] = time() +        self.history[(pluginName, account)] = time.time()      def __repr__(self): diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 21ebbc55e..f8e4e0dbd 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import time +import time  from module.common.json_layer import json_loads  from module.plugins.internal.CaptchaService import ReCaptcha @@ -41,7 +40,7 @@ class FilepostCom(SimpleHoster):          captcha_key = m.group(1)          # Get wait time -        get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time() * 10000)) + '-xml'} +        get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time.time() * 10000)) + '-xml'}          post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']}          wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) @@ -57,7 +56,7 @@ class FilepostCom(SimpleHoster):              if password:                  self.logInfo(_("Password protected link, trying ") + file_pass) -                get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' +                get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'                  post_dict['file_pass'] = file_pass                  self.link = self.getJsonResponse(get_dict, post_dict, 'link') @@ -72,7 +71,7 @@ class FilepostCom(SimpleHoster):              recaptcha = ReCaptcha(self)              for i in xrange(5): -                get_dict['JsHttpRequest'] = str(int(time() * 10000)) + '-xml' +                get_dict['JsHttpRequest'] = str(int(time.time() * 10000)) + '-xml'                  if i:                      post_dict['recaptcha_response_field'], post_dict['recaptcha_challenge_field'] = recaptcha.challenge(                          captcha_key) diff --git a/module/plugins/hoster/FshareVn.py b/module/plugins/hoster/FshareVn.py index 9a2b0c323..77515f191 100644 --- a/module/plugins/hoster/FshareVn.py +++ b/module/plugins/hoster/FshareVn.py @@ -1,8 +1,8 @@  # -*- coding: utf-8 -*-  import re +import time -from time import strptime, mktime, gmtime  from urlparse import urljoin  from module.network.RequestFactory import getURL @@ -99,8 +99,8 @@ class FshareVn(SimpleHoster):          m = re.search(self.WAIT_PATTERN, self.html)          if m:              self.logInfo(_("Wait until %s ICT") % m.group(1)) -            wait_until = mktime(strptime(m.group(1), "%d/%m/%Y %H:%M")) -            self.wait(wait_until - mktime(gmtime()) - 7 * 60 * 60, True) +            wait_until = time.mktime.time(time.strptime.time(m.group(1), "%d/%m/%Y %H:%M")) +            self.wait(wait_until - time.mktime.time(time.gmtime.time()) - 7 * 60 * 60, True)              self.retry()          elif '<ul class="message-error">' in self.html:              msg = "Unknown error occured or wait time not parsed" diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py index bdb428143..34b75e8fd 100644 --- a/module/plugins/hoster/MegasharesCom.py +++ b/module/plugins/hoster/MegasharesCom.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import time +import time  from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -66,7 +65,7 @@ class MegasharesCom(SimpleHoster):                                       'rsargs[]': random_num,                                       'rsargs[]': passport_num,                                       'rsargs[]': "replace_sec_pprenewal", -                                     'rsrnd[]' : str(int(time() * 1000))}) +                                     'rsrnd[]' : str(int(time.time() * 1000))})                  if 'Thank you for reactivating your passport.' in res:                      self.correctCaptcha() diff --git a/module/plugins/hoster/NetloadIn.py b/module/plugins/hoster/NetloadIn.py index 16728ad43..0ff3c25d3 100644 --- a/module/plugins/hoster/NetloadIn.py +++ b/module/plugins/hoster/NetloadIn.py @@ -1,9 +1,9 @@  # -*- coding: utf-8 -*-  import re +import time  from urlparse import urljoin -from time import time  from module.network.RequestFactory import getURL  from module.plugins.Hoster import Hoster @@ -161,7 +161,7 @@ class NetloadIn(Hoster):      def final_wait(self, page): -        wait_time = self.get_wait_time(page) +        wait_time = self.get_wait_time.time(page)          self.setWait(wait_time) @@ -175,7 +175,7 @@ class NetloadIn(Hoster):      def check_free_wait(self, page):          if ">An access request has been made from IP address <" in page:              self.wantReconnect = True -            self.setWait(self.get_wait_time(page) or 30) +            self.setWait(self.get_wait_time.time(page) or 30)              self.wait()              return True          else: @@ -207,7 +207,7 @@ class NetloadIn(Hoster):          for i in xrange(5):              if not page:                  page = self.load(self.url) -                t = time() + 30 +                t = time.time() + 30              if "/share/templates/download_hddcrash.tpl" in page:                  self.logError(_("Netload HDD Crash")) @@ -281,7 +281,7 @@ class NetloadIn(Hoster):              return None -    def get_wait_time(self, page): +    def get_wait_time.time(self, page):          return int(re.search(r"countdown\((.+),'change\(\)'\)", page).group(1)) / 100 diff --git a/module/plugins/hoster/RapiduNet.py b/module/plugins/hoster/RapiduNet.py index 350572eef..b455f556f 100644 --- a/module/plugins/hoster/RapiduNet.py +++ b/module/plugins/hoster/RapiduNet.py @@ -1,9 +1,9 @@  # -*- coding: utf-8 -*-  import re +import time  from pycurl import HTTPHEADER -from time import time, altzone  from module.common.json_layer import json_loads  from module.plugins.internal.CaptchaService import ReCaptcha @@ -47,14 +47,14 @@ class RapiduNet(SimpleHoster):                                        decode=True)          if str(jsvars['timeToDownload']) is "stop": -            t = (24 * 60 * 60) - (int(time()) % (24 * 60 * 60)) + altzone +            t = (24 * 60 * 60) - (int(time.time()) % (24 * 60 * 60)) + time.altzone              self.logInfo("You've reach your daily download transfer")              self.retry(10, 10 if t < 1 else None, _("Try tomorrow again"))  #@NOTE: check t in case of not synchronised clock          else: -            self.wait(int(jsvars['timeToDownload']) - int(time())) +            self.wait(int(jsvars['timeToDownload']) - int(time.time()))          recaptcha = ReCaptcha(self) diff --git a/module/plugins/hoster/RealdebridCom.py b/module/plugins/hoster/RealdebridCom.py index ba76cfe9d..888f74cb7 100644 --- a/module/plugins/hoster/RealdebridCom.py +++ b/module/plugins/hoster/RealdebridCom.py @@ -1,10 +1,10 @@  # -*- coding: utf-8 -*-  import re +import time  from random import randrange  from urllib import unquote -from time import time  from module.common.json_layer import json_loads  from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo @@ -42,7 +42,7 @@ class RealdebridCom(MultiHoster):                                      get={'lang'    : "en",                                           'link'    : pyfile.url,                                           'password': self.getPassword(), -                                         'time'    : int(time() * 1000)})) +                                         'time'    : int(time.time() * 1000)}))          self.logDebug("Returned Data: %s" % data) diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 546cd2f42..5ed8ca793 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -1,8 +1,8 @@  # -*- coding: utf-8 -*-  import re +import time -from time import time  from urllib import unquote  from urlparse import urlparse @@ -74,7 +74,7 @@ class ShareonlineBiz(SimpleHoster):              m = re.search(r'var wait=(\d+);', self.html)              self.setWait(int(m.group(1)) if m else 30) -            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), +            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)),                              post={'dl_free'                  : "1",                                    'recaptcha_challenge_field': challenge,                                    'recaptcha_response_field' : response}) diff --git a/module/plugins/hoster/SimplyPremiumCom.py b/module/plugins/hoster/SimplyPremiumCom.py index a87e7533f..978aba11a 100644 --- a/module/plugins/hoster/SimplyPremiumCom.py +++ b/module/plugins/hoster/SimplyPremiumCom.py @@ -2,8 +2,6 @@  import re -from datetime import datetime, timedelta -  from module.plugins.internal.MultiHoster import MultiHoster, create_getInfo  from module.plugins.internal.SimpleHoster import secondsToMidnight diff --git a/module/plugins/hoster/UploadableCh.py b/module/plugins/hoster/UploadableCh.py index 46b68c5fc..cd13a1468 100644 --- a/module/plugins/hoster/UploadableCh.py +++ b/module/plugins/hoster/UploadableCh.py @@ -2,8 +2,6 @@  import re -from time import sleep -  from module.plugins.internal.CaptchaService import ReCaptcha  from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 6161863b2..5c6160c8d 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import sleep +import time  from module.network.RequestFactory import getURL  from module.plugins.internal.CaptchaService import ReCaptcha @@ -48,7 +47,7 @@ class UploadedTo(SimpleHoster):                      info['status'] = 1                  break              else: -                sleep(3) +                time.sleep(3)          return info diff --git a/module/plugins/hoster/Xdcc.py b/module/plugins/hoster/Xdcc.py index bfa62b8db..b77e7c1da 100644 --- a/module/plugins/hoster/Xdcc.py +++ b/module/plugins/hoster/Xdcc.py @@ -4,11 +4,11 @@ import re  import socket  import struct  import sys +import time  from os import makedirs  from os.path import exists, join  from select import select -from time import time  from module.plugins.Hoster import Hoster  from module.utils import save_join @@ -84,12 +84,12 @@ class Xdcc(Hoster):          #######################          # CONNECT TO IRC AND IDLE FOR REAL LINK -        dl_time = time() +        dl_time = time.time()          sock = socket.socket()          sock.connect((host, int(port)))          if nick == "pyload": -            nick = "pyload-%d" % (time() % 1000)  # last 3 digits +            nick = "pyload-%d" % (time.time() % 1000)  # last 3 digits          sock.send("NICK %s\r\n" % nick)          sock.send("USER %s %s bla :%s\r\n" % (ident, host, real)) @@ -111,13 +111,13 @@ class Xdcc(Hoster):                  break              if retry: -                if time() > retry: +                if time.time() > retry:                      retry = None -                    dl_time = time() +                    dl_time = time.time()                      sock.send("PRIVMSG %s :xdcc send #%s\r\n" % (bot, pack))              else: -                if (dl_time + self.timeout) < time():  # todo: add in config +                if (dl_time + self.timeout) < time.time():  # todo: add in config                      sock.send("QUIT :byebye\r\n")                      sock.close()                      self.fail(_("XDCC Bot did not answer")) @@ -159,7 +159,7 @@ class Xdcc(Hoster):                          sock.send("NOTICE %s :%s\r\n" % (msg['origin'], "pyLoad! IRC Interface"))                      elif msg['text'] == "\x01TIME\x01":                          self.logDebug("Sending CTCP TIME") -                        sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time())) +                        sock.send("NOTICE %s :%d\r\n" % (msg['origin'], time.time()))                      elif msg['text'] == "\x01LAG\x01":                          pass  # don't know how to answer @@ -172,7 +172,7 @@ class Xdcc(Hoster):                      print "%s: %s" % (msg['origin'], msg['text'])                  if "You already requested that pack" in msg['text']: -                    retry = time() + 300 +                    retry = time.time() + 300                  if "you must be on a known channel to request a pack" in msg['text']:                      self.fail(_("Wrong channel")) diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index d9d1db1be..f9e112aed 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -63,15 +63,15 @@ class ZippyshareCom(SimpleHoster):          def replElementById(element):              id   = element.group(1) # id might be either 'x' (a real id) or x (a variable)              attr = element.group(4)  # attr might be None -             +              varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) -             +              realid = id.strip('"\'') -            if id != realid: #id is not a variable, so look for realid.attr in the html  +            if id != realid: #id is not a variable, so look for realid.attr in the html                  initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=realid)])                  initValue  = '"%s"' % initValues[-1] if initValues else 'null'                  initScripts.add('%s = %s;' % (varName, initValue)) -                 +              return varName          # handle all getElementById diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index e69f56c32..d4369da9b 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -1,8 +1,7 @@  # -*- coding: utf-8 -*-  import re - -from time import sleep +import time  from module.plugins.Hook import Hook  from module.utils import decode, remove_chars @@ -132,7 +131,7 @@ class MultiHook(Hook):              except Exception, e:                  self.logDebug(e, "Waiting 1 minute and retry") -                sleep(60) +                time.sleep(60)          else:              self.logWarning(_("Fallback to default reload interval due plugin"))              self.interval = self.MIN_RELOAD_INTERVAL diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 114128c63..5defd028d 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -1,12 +1,12 @@  # -*- coding: utf-8 -*- +import datetime  import mimetypes  import os  import re +import time -from datetime import datetime, timedelta  from inspect import isclass -from time import time  from urllib import unquote  from urlparse import urljoin, urlparse @@ -137,7 +137,7 @@ def create_getInfo(plugin):  def timestamp(): -    return int(time() * 1000) +    return int(time.time() * 1000)  #@TODO: Move to hoster class in 0.4.10 @@ -226,18 +226,18 @@ def getFileURL(self, url, follow_location=None):  def secondsToMidnight(gmt=0): -    now = datetime.utcnow() + timedelta(hours=gmt) +    now = datetime.datetime.utcnow() + datetime.timedelta(hours=gmt)      if now.hour is 0 and now.minute < 10:          midnight = now      else: -        midnight = now + timedelta(days=1) +        midnight = now + datetime.timedelta(days=1)      td = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now      if hasattr(td, 'total_seconds'):          res = td.total_seconds() -    else:  #: work-around for python 2.5 and 2.6 missing timedelta.total_seconds +    else:  #: work-around for python 2.5 and 2.6 missing datetime.timedelta.total_seconds          res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6      return int(res) diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index 9315fb68f..31d1b7e2f 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -1,8 +1,8 @@  # -*- coding: utf-8 -*-  import re +import time -from time import gmtime, mktime, strptime  from urlparse import urljoin  from module.plugins.Account import Account @@ -80,7 +80,7 @@ class XFSAccount(Account):              self.logDebug("Expire date: " + expiredate)              try: -                validuntil = mktime(strptime(expiredate, "%d %B %Y")) +                validuntil = time.mktime(time.strptime(expiredate, "%d %B %Y"))              except Exception, e:                  self.logError(e) @@ -88,7 +88,7 @@ class XFSAccount(Account):              else:                  self.logDebug("Valid until: %s" % validuntil) -                if validuntil > mktime(gmtime()): +                if validuntil > time.mktime(time.gmtime()):                      premium     = True                      trafficleft = -1                  else: diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index 6e0b5e4ab..9e60a5aa5 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -1,9 +1,9 @@  # -*- coding: utf-8 -*-  import re +import time  from random import random -from time import sleep  from urlparse import urljoin, urlparse  from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME  | 
