added more options for title extraction and added uploader and age limit fields

This commit is contained in:
Sarbajit Saha 2017-05-08 16:36:20 +05:30
parent e591fa4b33
commit d0ee170763

View File

@ -2,12 +2,11 @@
from __future__ import unicode_literals from __future__ import unicode_literals
from .common import InfoExtractor from .common import InfoExtractor
import re import re
class NonkTubeIE(InfoExtractor): class NonkTubeIE(InfoExtractor):
_VALID_URL = r'https?:\/\/(?:www\.)?nonktube\.com\/video\/(?P<id>[0-9]+)\/[0-9a-zA-Z\-]*' _VALID_URL = r'https?://(?:www\.)?nonktube\.com\/video/(?P<id>[0-9]+)/[0-9a-zA-Z\-]*'
_TESTS = [{ _TESTS = [{
'url': 'https://www.nonktube.com/video/118636/sensual-wife-uncensored-fucked-in-hairy-pussy-and-facialized', 'url': 'https://www.nonktube.com/video/118636/sensual-wife-uncensored-fucked-in-hairy-pussy-and-facialized',
'md5': 'ccd2df2aef9f44e51773c8ea59de6fd1', 'md5': 'ccd2df2aef9f44e51773c8ea59de6fd1',
@ -16,6 +15,8 @@ class NonkTubeIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Sensual Wife Uncensored Fucked In Hairy Pussy And Facialized', 'title': 'Sensual Wife Uncensored Fucked In Hairy Pussy And Facialized',
'thumbnail': 'https://www.nonktube.com/media/videos/tmb_2/118636/default.jpg', 'thumbnail': 'https://www.nonktube.com/media/videos/tmb_2/118636/default.jpg',
'uploader': 'https://www.nonktube.com/user/cumdrinkingwife',
'age_limit': 18
} }
}, { }, {
'url': 'https://www.nonktube.com/video/118698/2-japanese-girls-sharing-one-dick-uncesnored', 'url': 'https://www.nonktube.com/video/118698/2-japanese-girls-sharing-one-dick-uncesnored',
@ -25,29 +26,43 @@ class NonkTubeIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': '2 Japanese Girls Sharing One Dick Uncesnored', 'title': '2 Japanese Girls Sharing One Dick Uncesnored',
'thumbnail': 'https://www.nonktube.com/media/videos/tmb_2/118698/default.jpg', 'thumbnail': 'https://www.nonktube.com/media/videos/tmb_2/118698/default.jpg',
'uploader': 'https://www.nonktube.com/user/cumdrinkingwife',
'age_limit': 18
} }
}] }]
DOWNLOAD_URL_TEMPLATE = 'https://cdn.nonktube.com/%s.mp4'
UPLOADER_URL_TEMPLATE = 'https://www.nonktube.com/user/%s'
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
video_url = self.DOWNLOAD_URL_TEMPLATE % str(video_id)
title = self._html_search_regex( title = self._html_search_regex(
[r'<title>(.+?)(?: - NonkTube.com)</title>'], [r'<title>(?P<title>.+?) - NonkTube.com</title>',
webpage, 'title') r'<h1 class=.*>(?P<title>.+?)</h1>'], webpage, 'title', group='title')
thumbnail = self._html_search_regex( thumbnail = self._html_search_regex(
[r'<img src="(.+?)(?:" title="' + re.escape(title) + r'" alt="' + re.escape(title) + r'" width="160" height="120" />)'], [r'<img src="(?P<thumbnail>.+?)" title="' + re.escape(title) + r'" alt="' + re.escape(title) + r'" width="[0-9]*" height="[0-9]*" />'],
webpage, 'thumbnail', fatal=False) webpage, 'thumbnail', fatal=False, group='thumbnail')
video_download_url = "https://cdn.nonktube.com/" + video_id + ".mp4" # only one link of format /user/ is present in every video which gives the uploader username
uploader = self._html_search_regex(
[r'<a href="/user/(?P<uploader_id>[0-9A-Za-z]+?)">'],
webpage, 'uploader', fatal=False, group='uploader_id')
if uploader is not None:
uploader = self.UPLOADER_URL_TEMPLATE % uploader
age_limit = 18
return { return {
'id': video_id, 'id': video_id,
'title': title, 'title': title,
'uploader': uploader,
'thumbnail': thumbnail, 'thumbnail': thumbnail,
'url': video_download_url, 'url': video_url,
'age_limit': age_limit,
'ext': 'mp4', 'ext': 'mp4',
} }