rmcdecouverte.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import urllib.parse
  2. from .brightcove import BrightcoveLegacyIE
  3. from .common import InfoExtractor
  4. from ..utils import smuggle_url
  5. class RMCDecouverteIE(InfoExtractor):
  6. _VALID_URL = r'https?://rmcdecouverte\.bfmtv\.com/(?:[^?#]*_(?P<id>\d+)|mediaplayer-direct)/?(?:[#?]|$)'
  7. _TESTS = [{
  8. 'url': 'https://rmcdecouverte.bfmtv.com/vestiges-de-guerre_22240/les-bunkers-secrets-domaha-beach_25303/',
  9. 'info_dict': {
  10. 'id': '6250879771001',
  11. 'ext': 'mp4',
  12. 'title': 'LES BUNKERS SECRETS D´OMAHA BEACH',
  13. 'uploader_id': '1969646226001',
  14. 'description': 'md5:aed573ca24abde62a148e0eba909657d',
  15. 'timestamp': 1619622984,
  16. 'upload_date': '20210428',
  17. },
  18. 'params': {
  19. 'skip_download': True,
  20. },
  21. }, {
  22. 'url': 'https://rmcdecouverte.bfmtv.com/wheeler-dealers-occasions-a-saisir/program_2566/',
  23. 'info_dict': {
  24. 'id': '5983675500001',
  25. 'ext': 'mp4',
  26. 'title': 'CORVETTE',
  27. 'description': 'md5:c1e8295521e45ffebf635d6a7658f506',
  28. 'uploader_id': '1969646226001',
  29. 'upload_date': '20181226',
  30. 'timestamp': 1545861635,
  31. },
  32. 'params': {
  33. 'skip_download': True,
  34. },
  35. 'skip': 'only available for a week',
  36. }, {
  37. 'url': 'https://rmcdecouverte.bfmtv.com/avions-furtifs-la-technologie-de-lextreme_10598',
  38. 'only_matching': True,
  39. }, {
  40. # The website accepts any URL as long as it has _\d+ at the end
  41. 'url': 'https://rmcdecouverte.bfmtv.com/any/thing/can/go/here/_10598',
  42. 'only_matching': True,
  43. }, {
  44. # live, geo restricted, bypassable
  45. 'url': 'https://rmcdecouverte.bfmtv.com/mediaplayer-direct/',
  46. 'only_matching': True,
  47. }]
  48. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1969646226001/default_default/index.html?videoId=%s'
  49. def _real_extract(self, url):
  50. mobj = self._match_valid_url(url)
  51. display_id = mobj.group('id') or 'direct'
  52. webpage = self._download_webpage(url, display_id)
  53. brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
  54. if brightcove_legacy_url:
  55. brightcove_id = urllib.parse.parse_qs(urllib.parse.urlparse(
  56. brightcove_legacy_url).query)['@videoPlayer'][0]
  57. else:
  58. brightcove_id = self._search_regex(
  59. r'data-video-id=["\'](\d+)', webpage, 'brightcove id')
  60. return self.url_result(
  61. smuggle_url(
  62. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id,
  63. {'geo_countries': ['FR']}),
  64. 'BrightcoveNew', brightcove_id)