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.

66 lines
2.4 KiB

  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from .brightcove import BrightcoveIE
  6. from .discovery import DiscoveryIE
  7. from ..compat import compat_urlparse
  8. class TlcIE(DiscoveryIE):
  9. IE_NAME = 'tlc.com'
  10. _VALID_URL = r'http://www\.tlc\.com\/[a-zA-Z0-9\-]*/[a-zA-Z0-9\-]*/videos/(?P<id>[a-zA-Z0-9\-]*)(.htm)?'
  11. _TEST = {
  12. 'url': 'http://www.tlc.com/tv-shows/cake-boss/videos/too-big-to-fly.htm',
  13. 'md5': 'c4038f4a9b44d0b5d74caaa64ed2a01a',
  14. 'info_dict': {
  15. 'id': '853232',
  16. 'ext': 'mp4',
  17. 'title': 'Cake Boss: Too Big to Fly',
  18. 'description': 'Buddy has taken on a high flying task.',
  19. 'duration': 119,
  20. },
  21. }
  22. class TlcDeIE(InfoExtractor):
  23. IE_NAME = 'tlc.de'
  24. _VALID_URL = r'http://www\.tlc\.de/sendungen/[^/]+/videos/(?P<title>[^/?]+)'
  25. _TEST = {
  26. 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
  27. 'info_dict': {
  28. 'id': '3235167922001',
  29. 'ext': 'mp4',
  30. 'title': 'Breaking Amish: Die Welt da draußen',
  31. 'uploader': 'Discovery Networks - Germany',
  32. 'description': (
  33. 'Vier Amische und eine Mennonitin wagen in New York'
  34. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  35. ' ihrem spannenden Weg.'),
  36. },
  37. }
  38. def _real_extract(self, url):
  39. mobj = re.match(self._VALID_URL, url)
  40. title = mobj.group('title')
  41. webpage = self._download_webpage(url, title)
  42. iframe_url = self._search_regex(
  43. '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
  44. 'iframe url')
  45. # Otherwise we don't get the correct 'BrightcoveExperience' element,
  46. # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
  47. iframe_url = iframe_url.replace('.htm?', '.php?')
  48. url_fragment = compat_urlparse.urlparse(url).fragment
  49. if url_fragment:
  50. # Since the fragment is not send to the server, we always get the same iframe
  51. iframe_url = re.sub(r'playlist=(\d+)', 'playlist=%s' % url_fragment, iframe_url)
  52. iframe = self._download_webpage(iframe_url, title)
  53. return {
  54. '_type': 'url',
  55. 'url': BrightcoveIE._extract_brightcove_url(iframe),
  56. 'ie': BrightcoveIE.ie_key(),
  57. }