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