Fixed Extractor and added duration

Fixed extractor to return the correct video url
Extractor now pulls duration
This commit is contained in:
JChris246 2019-01-24 21:55:45 -04:00 committed by GitHub
parent 1602a240a7
commit ea755fa9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ from ..utils import urljoin
class YourPornIE(InfoExtractor): class YourPornIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?yourporn\.sexy/post/(?P<id>[^/?#&.]+)' _VALID_URL = r'https?://(?:www\.)?yourporn\.sexy/post/(?P<id>[^/?#&.]+)'
_TEST = { _TESTS = [{
'url': 'https://yourporn.sexy/post/57ffcb2e1179b.html', 'url': 'https://yourporn.sexy/post/57ffcb2e1179b.html',
'md5': '6f8682b6464033d87acaa7a8ff0c092e', 'md5': '6f8682b6464033d87acaa7a8ff0c092e',
'info_dict': { 'info_dict': {
@ -16,7 +16,28 @@ class YourPornIE(InfoExtractor):
'thumbnail': r're:^https?://.*\.jpg$', 'thumbnail': r're:^https?://.*\.jpg$',
'age_limit': 18 'age_limit': 18
}, },
}, {
'url': 'https://yourporn.sexy/post/5c2d2fde03bc5.html',
'md5': '3b2323fb429d3f559a11b3f22f4754af',
'info_dict': {
'id': '5c2d2fde03bc5',
'ext': 'mp4',
'title': 'Busty 7 - Nubile Films (2018) - Chanel Preston, '
'Crystal Swift, Jennifer Amton, Shay Evan',
'thumbnail': r're:^https?://.*\.jpg$',
'age_limit': 18,
'duration': 5403
} }
}]
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)
@ -27,17 +48,25 @@ class YourPornIE(InfoExtractor):
self._search_regex( self._search_regex(
r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info', r'data-vnfo=(["\'])(?P<data>{.+?})\1', webpage, 'data info',
group='data'), group='data'),
video_id)[video_id]).replace('/cdn/', '/cdn3/') video_id)[video_id]).replace('/cdn/', '/cdn4/')
title = (self._search_regex( title = (self._search_regex(
r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title', r'<[^>]+\bclass=["\']PostEditTA[^>]+>([^<]+)', webpage, 'title',
default=None) or self._og_search_description(webpage)).strip() default=None) or self._og_search_description(webpage)).strip()
if '#' in title:
title = title[0:title.index('#')].strip()
thumbnail = self._og_search_thumbnail(webpage) thumbnail = self._og_search_thumbnail(webpage)
duration = self._parse_duration(self._search_regex(
r'Video Info -> duration:<b>([0-9:]+)</b>',
webpage, 'duration'))
return { return {
'id': video_id, 'id': video_id,
'url': video_url, 'url': video_url,
'title': title, 'title': title,
'duration': duration,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
'age_limit': 18 'age_limit': 18
} }