youjizz: handle videos longer than 59 minutes.
Signed-off-by: Romain Bignon <romain@symlink.me>
This commit is contained in:
parent
da3dbcc6fc
commit
bda4203af6
1 changed files with 10 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue