]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/discoverynetworks.py
New upstream version 2018.04.25
[youtubedl] / youtube_dl / extractor / discoverynetworks.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from .brightcove import BrightcoveLegacyIE
8 from ..compat import (
9 compat_parse_qs,
10 compat_urlparse,
11 )
12 from ..utils import smuggle_url
13
14
15 class DiscoveryNetworksDeIE(InfoExtractor):
16 _VALID_URL = r'https?://(?:www\.)?(?:discovery|tlc|animalplanet|dmax)\.de/(?:.*#(?P<id>\d+)|(?:[^/]+/)*videos/(?P<title>[^/?#]+))'
17
18 _TESTS = [{
19 'url': 'http://www.tlc.de/sendungen/breaking-amish/videos/#3235167922001',
20 'info_dict': {
21 'id': '3235167922001',
22 'ext': 'mp4',
23 'title': 'Breaking Amish: Die Welt da draußen',
24 'description': (
25 'Vier Amische und eine Mennonitin wagen in New York'
26 ' den Sprung in ein komplett anderes Leben. Begleitet sie auf'
27 ' ihrem spannenden Weg.'),
28 'timestamp': 1396598084,
29 'upload_date': '20140404',
30 'uploader_id': '1659832546',
31 },
32 }, {
33 'url': 'http://www.dmax.de/programme/storage-hunters-uk/videos/storage-hunters-uk-episode-6/',
34 'only_matching': True,
35 }, {
36 'url': 'http://www.discovery.de/#5332316765001',
37 'only_matching': True,
38 }]
39 BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/1659832546/default_default/index.html?videoId=%s'
40
41 def _real_extract(self, url):
42 mobj = re.match(self._VALID_URL, url)
43 brightcove_id = mobj.group('id')
44 if not brightcove_id:
45 title = mobj.group('title')
46 webpage = self._download_webpage(url, title)
47 brightcove_legacy_url = BrightcoveLegacyIE._extract_brightcove_url(webpage)
48 brightcove_id = compat_parse_qs(compat_urlparse.urlparse(
49 brightcove_legacy_url).query)['@videoPlayer'][0]
50 return self.url_result(smuggle_url(
51 self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id, {'geo_countries': ['DE']}),
52 'BrightcoveNew', brightcove_id)