1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-18 08:16:10 +00:00
youtube-dl/youtube_dl/extractor/lcp.py

91 lines
2.9 KiB
Python
Raw Normal View History

2016-02-27 17:21:42 +00:00
# coding: utf-8
from __future__ import unicode_literals
2016-07-23 10:56:11 +00:00
2016-02-27 17:21:42 +00:00
from .common import InfoExtractor
2016-07-23 10:56:11 +00:00
from .arkena import ArkenaIE
class LcpPlayIE(ArkenaIE):
_VALID_URL = r'https?://play\.lcp\.fr/embed/(?P<id>[^/]+)/(?P<account_id>[^/]+)/[^/]+/[^/]+'
_TESTS = [{
'url': 'http://play.lcp.fr/embed/327336/131064/darkmatter/0',
'md5': 'b8bd9298542929c06c1c15788b1f277a',
'info_dict': {
'id': '327336',
'ext': 'mp4',
'title': '327336',
'timestamp': 1456391602,
'upload_date': '20160225',
},
'params': {
'skip_download': True,
},
}]
2016-02-27 17:21:42 +00:00
class LcpIE(InfoExtractor):
2016-07-23 10:56:11 +00:00
_VALID_URL = r'https?://(?:www\.)?lcp\.fr/(?:[^/]+/)*(?P<id>[^/]+)'
2016-02-27 17:21:42 +00:00
_TESTS = [{
2016-07-23 10:56:11 +00:00
# arkena embed
2016-02-27 17:21:42 +00:00
'url': 'http://www.lcp.fr/la-politique-en-video/schwartzenberg-prg-preconise-francois-hollande-de-participer-une-primaire',
2016-07-23 10:56:11 +00:00
'md5': 'b8bd9298542929c06c1c15788b1f277a',
2016-02-27 17:21:42 +00:00
'info_dict': {
'id': 'd56d03e9',
'ext': 'mp4',
2016-07-23 10:56:11 +00:00
'title': 'Schwartzenberg (PRG) préconise à François Hollande de participer à une primaire à gauche',
'description': 'md5:96ad55009548da9dea19f4120c6c16a8',
'timestamp': 1456488895,
2016-02-27 17:21:42 +00:00
'upload_date': '20160226',
2016-07-23 10:56:11 +00:00
},
'params': {
'skip_download': True,
},
2016-02-27 17:21:42 +00:00
}, {
2016-07-23 10:56:11 +00:00
# dailymotion live stream
2016-02-27 17:21:42 +00:00
'url': 'http://www.lcp.fr/le-direct',
'info_dict': {
2016-07-23 10:56:11 +00:00
'id': 'xji3qy',
'ext': 'mp4',
'title': 'La Chaine Parlementaire (LCP), Live TNT',
'description': 'md5:5c69593f2de0f38bd9a949f2c95e870b',
'uploader': 'LCP',
'uploader_id': 'xbz33d',
'timestamp': 1308923058,
'upload_date': '20110624',
},
'params': {
# m3u8 live stream
'skip_download': True,
2016-02-27 17:21:42 +00:00
},
2016-07-23 10:56:11 +00:00
}, {
'url': 'http://www.lcp.fr/emissions/277792-les-volontaires',
'only_matching': True,
2016-02-27 17:21:42 +00:00
}]
def _real_extract(self, url):
display_id = self._match_id(url)
2016-07-23 10:56:11 +00:00
2016-02-27 17:21:42 +00:00
webpage = self._download_webpage(url, display_id)
2016-07-23 10:56:11 +00:00
play_url = self._search_regex(
r'<iframe[^>]+src=(["\'])(?P<url>%s?(?:(?!\1).)*)\1' % LcpPlayIE._VALID_URL,
webpage, 'play iframe', default=None, group='url')
if not play_url:
2016-02-27 17:21:42 +00:00
return self.url_result(url, 'Generic')
2016-07-23 10:56:11 +00:00
title = self._og_search_title(webpage, default=None) or self._html_search_meta(
'twitter:title', webpage, fatal=True)
description = self._html_search_meta(
('description', 'twitter:description'), webpage)
return {
'_type': 'url_transparent',
'ie_key': LcpPlayIE.ie_key(),
'url': play_url,
'display_id': display_id,
'title': title,
'description': description,
}