[weboob] [PATCH 1/2] Fix issues with TricTracTV module : date parsing was wrongly assuming locales setting and duration parsing was not working as expected.

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


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

diff --git a/modules/trictractv/pages.py b/modules/trictractv/pages.py
index d8681c7..742c2ec 100644
--- a/modules/trictractv/pages.py
+++ b/modules/trictractv/pages.py
@@ -96,7 +96,7 @@ class VideoPage(BasePage):
             return None
         else:
             duration = details[2]
-            hours, minutes, seconds = duration.text [ duration.text.find(':') : ] . split(':')
+            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))
             else:
@@ -109,8 +109,13 @@ class VideoPage(BasePage):
             return None
         else:
             string = date.text
-            string = string [ string.rfind('le ') : ]
-            return datetime.datetime.strptime(string, 'le %d %b %Y, %H:%M:%S')
+            string = string [ string.rfind('le ') + 3 : ]
+            months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ]
+            words = string.split ( ' ' )
+            month_no = months.index ( words [ 1 ] ) + 1
+            return datetime.datetime.strptime ( ( '%s %s %s %s' % 
+                                                  ( words [ 0 ], month_no, words [ 2 ], words [ 3 ] ) ),
+                                                '%d %m %Y, %H:%M:%S')
 
     def get_rating(self):
         try:
-- 
1.7.9.5



More information about the weboob mailing list