You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.5 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .brightcove import BrightcoveLegacyIE
  5. from .dplay import DPlayIE
  6. from ..compat import (
  7. compat_parse_qs,
  8. compat_urlparse,
  9. )
  10. from ..utils import smuggle_url
  11. class DiscoveryNetworksDeIE(DPlayIE):
  12. _VALID_URL = r'''(?x)https?://(?:www\.)?(?P<site>discovery|tlc|animalplanet|dmax)\.de/
  13. (?:
  14. .*\#(?P<id>\d+)|
  15. (?:[^/]+/)*videos/(?P<display_id>[^/?#]+)|
  16. programme/(?P<programme>[^/]+)/video/(?P<alternate_id>[^/]+)
  17. )'''
  18. _TESTS = [{
  19. 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
  20. 'info_dict': {
  21. 'id': '3235167922001',
  22. 'ext': 'mp4',
  23. 'title': 'Breaking Amish: Die Welt da draußen',
  24. 'description': (
  25. 'Vier Amische und eine Mennonitin wagen in New York'
  26. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  27. ' ihrem spannenden Weg.'),
  28. 'timestamp': 1396598084,
  29. 'upload_date': '20140404',
  30. 'uploader_id': '1659832546',
  31. },
  32. }, {
  33. 'url': 'http://www.dmax.de/programme/storage-hunters-uk/videos/storage-hunters-uk-episode-6/',
  34. 'only_matching': True,
  35. }, {
  36. 'url': 'http://www.discovery.de/#5332316765001',
  37. 'only_matching': True,
  38. }]
  39. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1659832546/default_default/index.html?videoId=%s'
  40. def _real_extract(self, url):
  41. mobj = re.match(self._VALID_URL, url)
  42. alternate_id = mobj.group('alternate_id')
  43. if alternate_id:
  44. self._initialize_geo_bypass({
  45. 'countries': ['DE'],
  46. })
  47. return self._get_disco_api_info(
  48. url, '%s/%s' % (mobj.group('programme'), alternate_id),
  49. 'sonic-eu1-prod.disco-api.com', mobj.group('site') + 'de')
  50. brightcove_id = mobj.group('id')
  51. if not brightcove_id:
  52. title = mobj.group('title')
  53. webpage = self._download_webpage(url, title)
  54. brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
  55. brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
  56. brightcove_legacy_url).query)['@videoPlayer'][0]
  57. return self.url_result(smuggle_url(
  58. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, {'geo_countries': ['DE']}),
  59. 'BrightcoveNew', brightcove_id)