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