From 57bd5660511e186b186addf82c50c5bf8e459a8d Mon Sep 17 00:00:00 2001
From: JChris246 <43832407+JChris246@users.noreply.github.com>
Date: Wed, 23 Jan 2019 17:58:05 -0400
Subject: [PATCH] separated duration parse to new function
---
youtube_dl/extractor/yourporn.py | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/youtube_dl/extractor/yourporn.py b/youtube_dl/extractor/yourporn.py
index 466124d6e..a32c32b95 100644
--- a/youtube_dl/extractor/yourporn.py
+++ b/youtube_dl/extractor/yourporn.py
@@ -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:([0-9:]+)',
- 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:([0-9:]+)',
+ webpage, 'duration'))
return {
'id': video_id,
'url': video_url,