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:
parent
944439c150
commit
57bd566051
@ -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):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
@ -47,18 +56,8 @@ class YourPornIE(InfoExtractor):
|
|||||||
if '#' in title:
|
if '#' in title:
|
||||||
title = title[0:title.index('#')].strip()
|
title = title[0:title.index('#')].strip()
|
||||||
thumbnail = self._og_search_thumbnail(webpage)
|
thumbnail = self._og_search_thumbnail(webpage)
|
||||||
duration_raw = self._search_regex(r'Video Info -> duration:<b>([0-9:]+)</b>',
|
duration = self._parse_duration(self._search_regex(r'Video Info -> duration:<b>([0-9:]+)</b>',
|
||||||
webpage, 'duration')
|
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]))
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user