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.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 ..utils 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': 'Vier Amische und eine Mennonitin wagen in New York'
  33. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  34. ' ihrem spannenden Weg.',
  35. },
  36. }
  37. def _real_extract(self, url):
  38. mobj = re.match(self._VALID_URL, url)
  39. title = mobj.group('title')
  40. webpage = self._download_webpage(url, title)
  41. iframe_url = self._search_regex(
  42. '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
  43. 'iframe url')
  44. # Otherwise we don't get the correct 'BrightcoveExperience' element,
  45. # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
  46. iframe_url = iframe_url.replace('.htm?', '.php?')
  47. url_fragment = compat_urlparse.urlparse(url).fragment
  48. if url_fragment:
  49. # Since the fragment is not send to the server, we always get the same iframe
  50. iframe_url = re.sub(r'playlist=(\d+)', 'playlist=%s' % url_fragment, iframe_url)
  51. iframe = self._download_webpage(iframe_url, title)
  52. return {
  53. '_type': 'url',
  54. 'url': BrightcoveIE._extract_brightcove_url(iframe),
  55. 'ie': BrightcoveIE.ie_key(),
  56. }