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.

52 lines
2.0 KiB

  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 DiscoveryNetworksDeIE(InfoExtractor):
  12. _VALID_URL = r'https?://(?:www\.)?(?:discovery|tlc|animalplanet|dmax)\.de/(?:.*#(?P<id>\d+)|(?:[^/]+/)*videos/(?P<title>[^/?#]+))'
  13. _TESTS = [{
  14. 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
  15. 'info_dict': {
  16. 'id': '3235167922001',
  17. 'ext': 'mp4',
  18. 'title': 'Breaking Amish: Die Welt da draußen',
  19. 'description': (
  20. 'Vier Amische und eine Mennonitin wagen in New York'
  21. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  22. ' ihrem spannenden Weg.'),
  23. 'timestamp': 1396598084,
  24. 'upload_date': '20140404',
  25. 'uploader_id': '1659832546',
  26. },
  27. }, {
  28. 'url': 'http://www.dmax.de/programme/storage-hunters-uk/videos/storage-hunters-uk-episode-6/',
  29. 'only_matching': True,
  30. }, {
  31. 'url': 'http://www.discovery.de/#5332316765001',
  32. 'only_matching': True,
  33. }]
  34. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1659832546/default_default/index.html?videoId=%s'
  35. def _real_extract(self, url):
  36. mobj = re.match(self._VALID_URL, url)
  37. brightcove_id = mobj.group('id')
  38. if not brightcove_id:
  39. title = mobj.group('title')
  40. webpage = self._download_webpage(url, title)
  41. brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
  42. brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
  43. brightcove_legacy_url).query)['@videoPlayer'][0]
  44. return self.url_result(smuggle_url(
  45. self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, {'geo_countries': ['DE']}),
  46. 'BrightcoveNew', brightcove_id)