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