1
0
mirror of https://github.com/l1ving/youtube-dl synced 2020-11-18 19:53:54 -08:00

separated duration parse to new function

This commit is contained in:
JChris246 2019-01-23 17:58:05 -04:00 committed by GitHub
parent 944439c150
commit 57bd566051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,6 +30,15 @@ class YourPornIE(InfoExtractor):
}
}]
def _parse_duration(self, s):
duration = 0
size = len(s.split(":"))
j = size - 1
for i in range(size):
duration += int(s.split(":")[i]) * (60 ** j)
j = j - 1
return duration
def _real_extract(self, url):
video_id = self._match_id(url)
@ -47,18 +56,8 @@ class YourPornIE(InfoExtractor):
if '#' in title:
title = title[0:title.index('#')].strip()
thumbnail = self._og_search_thumbnail(webpage)
duration_raw = self._search_regex(r'Video Info -> duration:<b>([0-9:]+)</b>',
webpage, 'duration')
if len(duration_raw.split(":")) == 3:
duration = int((duration_raw.split(":")[0])) * 3600 + \
int((duration_raw.split(":")[1])) * 60 + \
int((duration_raw.split(":")[2]))
elif len(duration_raw.split(":")) == 2:
duration = int((duration_raw.split(":")[0])) * 60 + \
int((duration_raw.split(":")[1]))
else:
duration = int((duration_raw.split(":")[1]))
duration = self._parse_duration(self._search_regex(r'Video Info -> duration:<b>([0-9:]+)</b>',
webpage, 'duration'))
return {
'id': video_id,
'url': video_url,