Add an extractor for tlc.de (fixes #2748)
[youtube-dl] / youtube_dl / extractor / tlc.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3 import re
4
5 from .common import InfoExtractor
6 from .brightcove import BrightcoveIE
7
8
9 class TlcDeIE(InfoExtractor):
10     IE_NAME = 'tlc.de'
11     _VALID_URL = r'http://www\.tlc\.de/sendungen/[^/]+/videos/(?P<title>[^/?]+)'
12
13     _TEST = {
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             'uploader': 'Discovery Networks - Germany',
20             'description': '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         },
24     }
25
26     def _real_extract(self, url):
27         mobj = re.match(self._VALID_URL, url)
28         title = mobj.group('title')
29         webpage = self._download_webpage(url, title)
30         iframe_url = self._search_regex(
31             '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
32             'iframe url')
33         # Otherwise we don't get the correct 'BrightcoveExperience' element,
34         # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
35         iframe_url = iframe_url.replace('.htm?', '.php?')
36         iframe = self._download_webpage(iframe_url, title)
37
38         return {
39             '_type': 'url',
40             'url': BrightcoveIE._extract_brightcove_url(iframe),
41             'ie': BrightcoveIE.ie_key(),
42         }