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.

71 lines
2.5 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. # DiscoveryIE has _TESTS
  12. _TESTS = [{
  13. 'url': 'http://www.tlc.com/tv-shows/cake-boss/videos/too-big-to-fly.htm',
  14. 'info_dict': {
  15. 'id': '104493',
  16. 'ext': 'mp4',
  17. 'title': 'Too Big to Fly',
  18. 'description': 'Buddy has taken on a high flying task.',
  19. 'duration': 119,
  20. 'timestamp': 1393365060,
  21. 'upload_date': '20140225',
  22. },
  23. 'params': {
  24. 'skip_download': True, # requires ffmpef
  25. },
  26. }]
  27. class TlcDeIE(InfoExtractor):
  28. IE_NAME = 'tlc.de'
  29. _VALID_URL = r'http://www\.tlc\.de/sendungen/[^/]+/videos/(?P<title>[^/?]+)'
  30. _TEST = {
  31. 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
  32. 'info_dict': {
  33. 'id': '3235167922001',
  34. 'ext': 'mp4',
  35. 'title': 'Breaking Amish: Die Welt da draußen',
  36. 'uploader': 'Discovery Networks - Germany',
  37. 'description': (
  38. 'Vier Amische und eine Mennonitin wagen in New York'
  39. ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
  40. ' ihrem spannenden Weg.'),
  41. },
  42. }
  43. def _real_extract(self, url):
  44. mobj = re.match(self._VALID_URL, url)
  45. title = mobj.group('title')
  46. webpage = self._download_webpage(url, title)
  47. iframe_url = self._search_regex(
  48. '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
  49. 'iframe url')
  50. # Otherwise we don't get the correct 'BrightcoveExperience' element,
  51. # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
  52. iframe_url = iframe_url.replace('.htm?', '.php?')
  53. url_fragment = compat_urlparse.urlparse(url).fragment
  54. if url_fragment:
  55. # Since the fragment is not send to the server, we always get the same iframe
  56. iframe_url = re.sub(r'playlist=(\d+)', 'playlist=%s' % url_fragment, iframe_url)
  57. iframe = self._download_webpage(iframe_url, title)
  58. return {
  59. '_type': 'url',
  60. 'url': BrightcoveIE._extract_brightcove_url(iframe),
  61. 'ie': BrightcoveIE.ie_key(),
  62. }