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_span = self.parser.select(span, 'span.thumbtime span', 1)
|
||||||
time_txt = time_span.text.strip().replace(';', ':')
|
time_txt = time_span.text.strip().replace(';', ':')
|
||||||
if time_txt == 'N/A':
|
hours, minutes, seconds = 0, 0, 0
|
||||||
minutes, seconds = 0, 0
|
if ':' in time_txt:
|
||||||
elif ':' in time_txt:
|
t = time_txt.split(':')
|
||||||
minutes, seconds = (int(v) for v in time_txt.split(':'))
|
t.reverse()
|
||||||
else:
|
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)
|
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
|
yield video
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue