From f2da6bca43b619121df3f76fd27c98fa662c49db Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Dec 2014 14:54:12 +0100 Subject: [UnrestrictLi] Fix secondsToMidnight on python 2.5 & 2.6 --- module/plugins/hoster/UnrestrictLi.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'module/plugins') 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' -- cgit v1.2.3