diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-16 14:54:12 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-16 14:54:12 +0100 |
commit | f2da6bca43b619121df3f76fd27c98fa662c49db (patch) | |
tree | aaa03cae533e74c4932eee4d5bf49d10bddf9bb8 /module/plugins/hoster | |
parent | Update plugins (2) (diff) | |
download | pyload-f2da6bca43b619121df3f76fd27c98fa662c49db.tar.xz |
[UnrestrictLi] Fix secondsToMidnight on python 2.5 & 2.6
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/UnrestrictLi.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/module/plugins/hoster/UnrestrictLi.py b/module/plugins/hoster/UnrestrictLi.py index 94ce1b845..615409dab 100644 --- a/module/plugins/hoster/UnrestrictLi.py +++ b/module/plugins/hoster/UnrestrictLi.py @@ -10,18 +10,26 @@ from module.plugins.Hoster import Hoster def secondsToMidnight(gmt=0): now = datetime.utcnow() + timedelta(hours=gmt) + if now.hour is 0 and now.minute < 10: midnight = now else: midnight = now + timedelta(days=1) - midnight = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - return int((midnight - now).total_seconds()) + + dt = midnight.replace(hour=0, minute=10, second=0, microsecond=0) - now + + if hasattr(dt, 'total_seconds'): + res = dt.total_seconds() + else: + res = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6 + + return int(res) class UnrestrictLi(Hoster): __name__ = "UnrestrictLi" __type__ = "hoster" - __version__ = "0.12" + __version__ = "0.13" __pattern__ = r'https?://(?:[^/]*\.)?(unrestrict|unr)\.li' |