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.

48 lines
1.9 KiB

  1. # encoding: 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 compat_urlparse
  7. class TlcDeIE(InfoExtractor):
  8. IE_NAME = 'tlc.de'
  9. _VALID_URL = r'http://www\.tlc\.de/sendungen/[^/]+/videos/(?P<title>[^/?]+)'
  10. _TEST = {
  11. 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
  12. 'info_dict': {
  13. 'id': '3235167922001',
  14. 'ext': 'mp4',
  15. 'title': 'Breaking Amish: Die Welt da draußen',
  16. 'uploader': 'Discovery Networks - Germany',
  17. 'description': (
  18. 'Vier Amische und eine Mennonitin wagen in New York'
  19. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  20. ' ihrem spannenden Weg.'),
  21. },
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. title = mobj.group('title')
  26. webpage = self._download_webpage(url, title)
  27. iframe_url = self._search_regex(
  28. '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
  29. 'iframe url')
  30. # Otherwise we don't get the correct 'BrightcoveExperience' element,
  31. # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
  32. iframe_url = iframe_url.replace('.htm?', '.php?')
  33. url_fragment = compat_urlparse.urlparse(url).fragment
  34. if url_fragment:
  35. # Since the fragment is not send to the server, we always get the same iframe
  36. iframe_url = re.sub(r'playlist=(\d+)', 'playlist=%s' % url_fragment, iframe_url)
  37. iframe = self._download_webpage(iframe_url, title)
  38. return {
  39. '_type': 'url',
  40. 'url': BrightcoveLegacyIE._extract_brightcove_url(iframe),
  41. 'ie': BrightcoveLegacyIE.ie_key(),
  42. }