[weboob] [PATCH 2/2] Really fix date parsing

Benjamin Drieu bdrieu at april.org
Fri May 4 10:52:28 CEST 2012


Signed-off-by: Benjamin Drieu <bdrieu at april.org>
---
 modules/trictractv/pages.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/trictractv/pages.py b/modules/trictractv/pages.py
index 742c2ec..f7e4155 100644
--- a/modules/trictractv/pages.py
+++ b/modules/trictractv/pages.py
@@ -96,11 +96,12 @@ class VideoPage(BasePage):
             return None
         else:
             duration = details[2]
-            hours, minutes, seconds = duration.text [ duration.text.find(':') + 1 : ] . split(':')
-            if len(hours) > 0:
-                return datetime.timedelta(hours=int(hours), minutes=int(minutes), seconds=int(seconds))
+            duration_string = duration.text [ duration.text.rfind ( ' ' ) + 1 : ]
+            tokens = duration_string.split(':')
+            if len(tokens) > 2:
+                return datetime.timedelta(hours=int(tokens[0]), minutes=int(tokens[1]), seconds=int(tokens[2]))
             else:
-                return datetime.timedelta(minutes=int(minutes), seconds=int(seconds))
+                return datetime.timedelta(minutes=int(tokens[0]), seconds=int(tokens[1]))
 
     def get_date(self):
         try:
-- 
1.7.9.5




More information about the weboob mailing list