From bda4203af64ea611aabc0968cb0ec2461bba6347 Mon Sep 17 00:00:00 2001 From: Adrien Kunysz Date: Fri, 14 Feb 2014 19:13:32 +0000 Subject: [PATCH] youjizz: handle videos longer than 59 minutes. Signed-off-by: Romain Bignon --- modules/youjizz/pages/index.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/youjizz/pages/index.py b/modules/youjizz/pages/index.py index a2bea4a4..95800c3a 100644 --- a/modules/youjizz/pages/index.py +++ b/modules/youjizz/pages/index.py @@ -49,13 +49,17 @@ class IndexPage(BasePage): time_span = self.parser.select(span, 'span.thumbtime span', 1) time_txt = time_span.text.strip().replace(';', ':') - if time_txt == 'N/A': - minutes, seconds = 0, 0 - elif ':' in time_txt: - minutes, seconds = (int(v) for v in time_txt.split(':')) - else: + hours, minutes, seconds = 0, 0, 0 + if ':' in time_txt: + t = time_txt.split(':') + t.reverse() + seconds = int(t[0]) + minutes = int(t[1]) + if len(t) == 3: + hours = int(t[2]) + elif time_txt != 'N/A': raise BrokenPageError('Unable to parse the video duration: %s' % time_txt) - video.duration = datetime.timedelta(minutes=minutes, seconds=seconds) + video.duration = datetime.timedelta(hours=hours, minutes=minutes, seconds=seconds) yield video