lcp.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. from .arkena import ArkenaIE
  2. from .common import InfoExtractor
  3. class LcpPlayIE(ArkenaIE): # XXX: Do not subclass from concrete IE
  4. _VALID_URL = r'https?://play\.lcp\.fr/embed/(?P<id>[^/]+)/(?P<account_id>[^/]+)/[^/]+/[^/]+'
  5. _TESTS = [{
  6. 'url': 'http://play.lcp.fr/embed/327336/131064/darkmatter/0',
  7. 'md5': 'b8bd9298542929c06c1c15788b1f277a',
  8. 'info_dict': {
  9. 'id': '327336',
  10. 'ext': 'mp4',
  11. 'title': '327336',
  12. 'timestamp': 1456391602,
  13. 'upload_date': '20160225',
  14. },
  15. 'params': {
  16. 'skip_download': True,
  17. },
  18. }]
  19. class LcpIE(InfoExtractor):
  20. _VALID_URL = r'https?://(?:www\.)?lcp\.fr/(?:[^/]+/)*(?P<id>[^/]+)'
  21. _TESTS = [{
  22. # arkena embed
  23. 'url': 'http://www.lcp.fr/la-politique-en-video/schwartzenberg-prg-preconise-francois-hollande-de-participer-une-primaire',
  24. 'md5': 'b8bd9298542929c06c1c15788b1f277a',
  25. 'info_dict': {
  26. 'id': 'd56d03e9',
  27. 'ext': 'mp4',
  28. 'title': 'Schwartzenberg (PRG) préconise à François Hollande de participer à une primaire à gauche',
  29. 'description': 'md5:96ad55009548da9dea19f4120c6c16a8',
  30. 'timestamp': 1456488895,
  31. 'upload_date': '20160226',
  32. },
  33. 'params': {
  34. 'skip_download': True,
  35. },
  36. }, {
  37. # dailymotion live stream
  38. 'url': 'http://www.lcp.fr/le-direct',
  39. 'info_dict': {
  40. 'id': 'xji3qy',
  41. 'ext': 'mp4',
  42. 'title': 'La Chaine Parlementaire (LCP), Live TNT',
  43. 'description': 'md5:5c69593f2de0f38bd9a949f2c95e870b',
  44. 'uploader': 'LCP',
  45. 'uploader_id': 'xbz33d',
  46. 'timestamp': 1308923058,
  47. 'upload_date': '20110624',
  48. },
  49. 'params': {
  50. # m3u8 live stream
  51. 'skip_download': True,
  52. },
  53. }, {
  54. 'url': 'http://www.lcp.fr/emissions/277792-les-volontaires',
  55. 'only_matching': True,
  56. }]
  57. def _real_extract(self, url):
  58. display_id = self._match_id(url)
  59. webpage = self._download_webpage(url, display_id)
  60. play_url = self._search_regex(
  61. rf'<iframe[^>]+src=(["\'])(?P<url>{LcpPlayIE._VALID_URL}?(?:(?!\1).)*)\1',
  62. webpage, 'play iframe', default=None, group='url')
  63. if not play_url:
  64. return self.url_result(url, 'Generic')
  65. title = self._og_search_title(webpage, default=None) or self._html_search_meta(
  66. 'twitter:title', webpage, fatal=True)
  67. description = self._html_search_meta(
  68. ('description', 'twitter:description'), webpage)
  69. return {
  70. '_type': 'url_transparent',
  71. 'ie_key': LcpPlayIE.ie_key(),
  72. 'url': play_url,
  73. 'display_id': display_id,
  74. 'title': title,
  75. 'description': description,
  76. }