[indavideo] Split in two extractors, extract all formats and fix timestamp

pull/6554/head
Sergey M․ 10 years ago
parent cb28e03386
commit 3c12a027d4

@ -242,7 +242,10 @@ from .imdb import (
) )
from .imgur import ImgurIE from .imgur import ImgurIE
from .ina import InaIE from .ina import InaIE
from .indavideo import IndavideoIE from .indavideo import (
IndavideoIE,
IndavideoEmbedIE,
)
from .infoq import InfoQIE from .infoq import InfoQIE
from .instagram import InstagramIE, InstagramUserIE from .instagram import InstagramIE, InstagramUserIE
from .internetvideoarchive import InternetVideoArchiveIE from .internetvideoarchive import InternetVideoArchiveIE

@ -3,77 +3,127 @@ from __future__ import unicode_literals
from .. import utils from .. import utils
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import (
int_or_none,
parse_age_limit,
parse_iso8601,
)
class IndavideoIE(InfoExtractor): class IndavideoEmbedIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P<id>.+)' _VALID_URL = r'https?://(?:(?:embed\.)?indavideo\.hu/player/video/|assets\.indavideo\.hu/swf/player\.swf\?.*\b(?:v(?:ID|id))=)(?P<id>[\da-f]+)'
_TESTS = [ _TESTS = [{
{ 'url': 'http://indavideo.hu/player/video/1bdc3c6d80/',
'url': 'http://indavideo.hu/video/Cicatanc', 'md5': 'f79b009c66194acacd40712a6778acfa',
'md5': 'c8a507a1c7410685f83a06eaeeaafeab', 'info_dict': {
'info_dict': { 'id': '1837039',
'id': '1837039', 'ext': 'mp4',
'title': 'Cicatánc', 'title': 'Cicatánc',
'ext': 'mp4', 'description': '',
'display_id': 'Cicatanc', 'thumbnail': 're:^https?://.*\.jpg$',
'thumbnail': 're:^https?://.*\.jpg$', 'uploader': 'cukiajanlo',
'description': '', 'uploader_id': '83729',
'uploader': 'cukiajanlo', 'timestamp': 1439193826,
'uploader_id': '83729', 'upload_date': '20150810',
'duration': 72, 'duration': 72,
'age_limit': 0, 'age_limit': 0,
'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'] 'tags': ['tánc', 'cica', 'cuki', 'cukiajanlo', 'newsroom'],
},
},
{
'url': 'http://indavideo.hu/video/Vicces_cica_1',
'md5': '8c82244ba85d2a2310275b318eb51eac',
'info_dict': {
'id': '1335611',
'title': 'Vicces cica',
'ext': 'mp4',
'display_id': 'Vicces_cica_1',
'thumbnail': 're:^https?://.*\.jpg$',
'description': 'Játszik a tablettel. :D',
'uploader': 'Jet_Pack',
'uploader_id': '491217',
'duration': 7,
'age_limit': 0,
'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'],
},
}, },
] }, {
'url': 'http://embed.indavideo.hu/player/video/1bdc3c6d80?autostart=1&hide=1',
'only_matching': True,
}, {
'url': 'http://assets.indavideo.hu/swf/player.swf?v=fe25e500&vID=1bdc3c6d80&autostart=1&hide=1&i=1',
'only_matching': True,
}]
def _real_extract(self, url): def _real_extract(self, url):
video_disp_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_disp_id)
video = self._download_json(
'http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/%s' % video_id,
video_id)['data']
video_id = video['id']
title = video['title']
embed_url = self._html_search_regex(r'<link rel="video_src" href="(.+?)"/>', webpage, 'embed_url') video_urls = video.get('video_files', [])
video_hash = embed_url.split('/')[-1] video_file = video.get('video_file')
if video:
video_urls.append(video_file)
video_urls = list(set(video_urls))
payload = self._download_json('http://amfphp.indavideo.hu/SYm0json.php/player.playerHandler.getVideoData/' + video_hash, video_disp_id) video_prefix = video_urls[0].rsplit('/', 1)[0]
video_info = payload['data']
thumbnails = video_info.get('thumbnails') for flv_file in video.get('flv_files', []):
if thumbnails: flv_url = '%s/%s' % (video_prefix, flv_file)
thumbnails = [{'url': self._proto_relative_url(x)} for x in thumbnails] if flv_url not in video_urls:
video_urls.append(flv_url)
tags = video_info.get('tags') formats = [{
if tags: 'url': video_url,
tags = [x['title'] for x in tags] 'height': self._search_regex(r'\.(\d{3,4})\.mp4$', video_url, 'height', default=None),
} for video_url in video_urls]
self._sort_formats(formats)
timestamp = video.get('date')
if timestamp:
# upload date is in CEST
timestamp = parse_iso8601(timestamp + ' +0200', ' ')
thumbnails = [{
'url': self._proto_relative_url(thumbnail)
} for thumbnail in video.get('thumbnails', [])]
tags = [tag['title'] for tag in video.get('tags', [])]
return { return {
'id': video_info.get('id'), 'id': video_id,
'title': video_info['title'], 'title': title,
'url': video_info['video_file'], 'description': video.get('description'),
'ext': 'mp4',
'display_id': video_disp_id,
'thumbnails': thumbnails, 'thumbnails': thumbnails,
'description': video_info.get('description'), 'uploader': video.get('user_name'),
'uploader': video_info.get('user_name'), 'uploader_id': video.get('user_id'),
# TODO: upload date (it's in CET/CEST) 'timestamp': timestamp,
'uploader_id': video_info.get('user_id'), 'duration': int_or_none(video.get('length')),
'duration': utils.int_or_none(video_info.get('length')), 'age_limit': parse_age_limit(video.get('age_limit')),
'age_limit': utils.int_or_none(video_info.get('age_limit')),
'tags': tags, 'tags': tags,
'formats': formats,
}
class IndavideoIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?indavideo\.hu/video/(?P<id>[^/#?]+)'
_TEST = {
'url': 'http://indavideo.hu/video/Vicces_cica_1',
'md5': '8c82244ba85d2a2310275b318eb51eac',
'info_dict': {
'id': '1335611',
'display_id': 'Vicces_cica_1',
'ext': 'mp4',
'title': 'Vicces cica',
'description': 'Játszik a tablettel. :D',
'thumbnail': 're:^https?://.*\.jpg$',
'uploader': 'Jet_Pack',
'uploader_id': '491217',
'timestamp': 1390821212,
'upload_date': '20140127',
'duration': 7,
'age_limit': 0,
'tags': ['vicces', 'macska', 'cica', 'ügyes', 'nevetés', 'játszik', 'Cukiság', 'Jet_Pack'],
},
}
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
embed_url = self._search_regex(
r'<link[^>]+rel="video_src"[^>]+href="(.+?)"', webpage, 'embed url')
return {
'_type': 'url_transparent',
'ie_key': 'IndavideoEmbed',
'url': embed_url,
'display_id': display_id,
} }

Loading…
Cancel
Save