]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tlc.py
debian/control: Annotate with bug numbers closed by this release.
[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 BrightcoveIE
7 from .discovery import DiscoveryIE
8
9
10 class TlcIE(DiscoveryIE):
11 IE_NAME = 'tlc.com'
12 _VALID_URL = r'http://www\.tlc\.com\/[a-zA-Z0-9\-]*/[a-zA-Z0-9\-]*/videos/(?P<id>[a-zA-Z0-9\-]*)(.htm)?'
13
14 _TEST = {
15 'url': 'http://www.tlc.com/tv-shows/cake-boss/videos/too-big-to-fly.htm',
16 'md5': 'c4038f4a9b44d0b5d74caaa64ed2a01a',
17 'info_dict': {
18 'id': '853232',
19 'ext': 'mp4',
20 'title': 'Cake Boss: Too Big to Fly',
21 'description': 'Buddy has taken on a high flying task.',
22 'duration': 119,
23 },
24 }
25
26
27 class TlcDeIE(InfoExtractor):
28 IE_NAME = 'tlc.de'
29 _VALID_URL = r'http://www\.tlc\.de/sendungen/[^/]+/videos/(?P<title>[^/?]+)'
30
31 _TEST = {
32 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
33 'info_dict': {
34 'id': '3235167922001',
35 'ext': 'mp4',
36 'title': 'Breaking Amish: Die Welt da draußen',
37 'uploader': 'Discovery Networks - Germany',
38 'description': '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
44 def _real_extract(self, url):
45 mobj = re.match(self._VALID_URL, url)
46 title = mobj.group('title')
47 webpage = self._download_webpage(url, title)
48 iframe_url = self._search_regex(
49 '<iframe src="(http://www\.tlc\.de/wp-content/.+?)"', webpage,
50 'iframe url')
51 # Otherwise we don't get the correct 'BrightcoveExperience' element,
52 # example: http://www.tlc.de/sendungen/cake-boss/videos/cake-boss-cannoli-drama/
53 iframe_url = iframe_url.replace('.htm?', '.php?')
54 iframe = self._download_webpage(iframe_url, title)
55
56 return {
57 '_type': 'url',
58 'url': BrightcoveIE._extract_brightcove_url(iframe),
59 'ie': BrightcoveIE.ie_key(),
60 }