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