|
|
@ -1,13 +1,10 @@
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
int_or_none,
|
|
|
|
ExtractorError,
|
|
|
|
parse_duration,
|
|
|
|
sanitized_Request,
|
|
|
|
qualities,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -16,9 +13,9 @@ class VeohIE(InfoExtractor):
|
|
|
|
|
|
|
|
|
|
|
|
_TESTS = [{
|
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
|
|
|
|
'url': 'http://www.veoh.com/watch/v56314296nk7Zdmz3',
|
|
|
|
'md5': '620e68e6a3cff80086df3348426c9ca3',
|
|
|
|
'md5': '9e7ecc0fd8bbee7a69fe38953aeebd30',
|
|
|
|
'info_dict': {
|
|
|
|
'info_dict': {
|
|
|
|
'id': '56314296',
|
|
|
|
'id': 'v56314296nk7Zdmz3',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'Straight Backs Are Stronger',
|
|
|
|
'title': 'Straight Backs Are Stronger',
|
|
|
|
'uploader': 'LUMOback',
|
|
|
|
'uploader': 'LUMOback',
|
|
|
@ -56,29 +53,6 @@ class VeohIE(InfoExtractor):
|
|
|
|
'only_matching': True,
|
|
|
|
'only_matching': True,
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
|
|
|
|
|
|
|
|
def _extract_formats(self, source):
|
|
|
|
|
|
|
|
formats = []
|
|
|
|
|
|
|
|
link = source.get('aowPermalink')
|
|
|
|
|
|
|
|
if link:
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'url': link,
|
|
|
|
|
|
|
|
'ext': 'mp4',
|
|
|
|
|
|
|
|
'format_id': 'aow',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
link = source.get('fullPreviewHashLowPath')
|
|
|
|
|
|
|
|
if link:
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'url': link,
|
|
|
|
|
|
|
|
'format_id': 'low',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
link = source.get('fullPreviewHashHighPath')
|
|
|
|
|
|
|
|
if link:
|
|
|
|
|
|
|
|
formats.append({
|
|
|
|
|
|
|
|
'url': link,
|
|
|
|
|
|
|
|
'format_id': 'high',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return formats
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _extract_video(self, source):
|
|
|
|
def _extract_video(self, source):
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
'id': source.get('videoId'),
|
|
|
|
'id': source.get('videoId'),
|
|
|
@ -93,38 +67,37 @@ class VeohIE(InfoExtractor):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
|
video = self._download_json(
|
|
|
|
|
|
|
|
'https://www.veoh.com/watch/getVideo/' + video_id,
|
|
|
|
if video_id.startswith('v'):
|
|
|
|
video_id)['video']
|
|
|
|
rsp = self._download_xml(
|
|
|
|
title = video['title']
|
|
|
|
r'http://www.veoh.com/api/findByPermalink?permalink=%s' % video_id, video_id, 'Downloading video XML')
|
|
|
|
|
|
|
|
stat = rsp.get('stat')
|
|
|
|
|
|
|
|
if stat == 'ok':
|
|
|
|
|
|
|
|
return self._extract_video(rsp.find('./videoList/video'))
|
|
|
|
|
|
|
|
elif stat == 'fail':
|
|
|
|
|
|
|
|
raise ExtractorError(
|
|
|
|
|
|
|
|
'%s said: %s' % (self.IE_NAME, rsp.find('./errorList/error').get('errorMessage')), expected=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
|
|
|
|
age_limit = 0
|
|
|
|
|
|
|
|
if 'class="adultwarning-container"' in webpage:
|
|
|
|
|
|
|
|
self.report_age_confirmation()
|
|
|
|
|
|
|
|
age_limit = 18
|
|
|
|
|
|
|
|
request = sanitized_Request(url)
|
|
|
|
|
|
|
|
request.add_header('Cookie', 'confirmedAdult=true')
|
|
|
|
|
|
|
|
webpage = self._download_webpage(request, video_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_youtube = re.search(r'http://www\.youtube\.com/v/(.*?)(\&|"|\?)', webpage)
|
|
|
|
thumbnail_url = None
|
|
|
|
if m_youtube is not None:
|
|
|
|
q = qualities(['HQ', 'Regular'])
|
|
|
|
youtube_id = m_youtube.group(1)
|
|
|
|
formats = []
|
|
|
|
self.to_screen('%s: detected Youtube video.' % video_id)
|
|
|
|
for f_id, f_url in video.get('src', {}).items():
|
|
|
|
return self.url_result(youtube_id, 'Youtube')
|
|
|
|
if not f_url:
|
|
|
|
|
|
|
|
continue
|
|
|
|
info = json.loads(
|
|
|
|
if f_id == 'poster':
|
|
|
|
self._search_regex(r'videoDetailsJSON = \'({.*?})\';', webpage, 'info').replace('\\\'', '\''))
|
|
|
|
thumbnail_url = f_url
|
|
|
|
|
|
|
|
else:
|
|
|
|
video = self._extract_video(info)
|
|
|
|
formats.append({
|
|
|
|
video['age_limit'] = age_limit
|
|
|
|
'format_id': f_id,
|
|
|
|
|
|
|
|
'quality': q(f_id),
|
|
|
|
|
|
|
|
'url': f_url,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
self._sort_formats(formats)
|
|
|
|
|
|
|
|
|
|
|
|
return video
|
|
|
|
return {
|
|
|
|
|
|
|
|
'id': video_id,
|
|
|
|
|
|
|
|
'title': title,
|
|
|
|
|
|
|
|
'description': video.get('description'),
|
|
|
|
|
|
|
|
'thumbnail': thumbnail_url,
|
|
|
|
|
|
|
|
'uploader': video.get('author', {}).get('nickname'),
|
|
|
|
|
|
|
|
'duration': int_or_none(video.get('lengthBySec')) or parse_duration(video.get('length')),
|
|
|
|
|
|
|
|
'view_count': int_or_none(video.get('views')),
|
|
|
|
|
|
|
|
'formats': formats,
|
|
|
|
|
|
|
|
'average_rating': int_or_none(video.get('rating')),
|
|
|
|
|
|
|
|
'comment_count': int_or_none(video.get('numOfComments')),
|
|
|
|
|
|
|
|
}
|
|
|
|