logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

rmcdecouverte.py (2017B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from .brightcove import BrightcoveLegacyIE
  6. from ..compat import (
  7. compat_parse_qs,
  8. compat_urlparse,
  9. )
  10. from ..utils import smuggle_url
  11. class RMCDecouverteIE(InfoExtractor):
  12. _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:(?:[^/]+/)*program_(?P<id>\d+)|(?P<live_id>mediaplayer-direct))'
  13. _TESTS = [{
  14. 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
  15. 'info_dict': {
  16. 'id': '5983675500001',
  17. 'ext': 'mp4',
  18. 'title': 'CORVETTE',
  19. 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
  20. 'uploader_id': '1969646226001',
  21. 'upload_date': '20181226',
  22. 'timestamp': 1545861635,
  23. },
  24. 'params': {
  25. 'skip_download': True,
  26. },
  27. 'skip': 'only available for a week',
  28. }, {
  29. # live, geo restricted, bypassable
  30. 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
  31. 'only_matching': True,
  32. }]
  33. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
  34. def _real_extract(self, url):
  35. mobj = re.match(self._VALID_URL, url)
  36. display_id = mobj.group('id') or mobj.group('live_id')
  37. webpage = self._download_webpage(url, display_id)
  38. brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
  39. if brightcove_legacy_url:
  40. brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
  41. brightcove_legacy_url).query)['@videoPlayer'][0]
  42. else:
  43. brightcove_id = self._search_regex(
  44. r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
  45. return self.url_result(
  46. smuggle_url(
  47. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  48. {'geo_countries': ['FR']}),
  49. 'BrightcoveNew', brightcove_id)