]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/disney.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class DisneyIE(InfoExtractor
):
17 https?://(?P<domain>(?:[^/]+\.)?(?:disney\.[a-z]{2,3}(?:\.[a-z]{2})?|disney(?:(?:me|latino)\.com|turkiye\.com\.tr)|starwars\.com))/(?:embed/|(?:[^/]+/)+[\w-]+-)(?P<id>[a-z0-9]{24})'''
19 'url': 'http://video.disney.com/watch/moana-trailer-545ed1857afee5a0ec239977',
21 'id': '545ed1857afee5a0ec239977',
23 'title': 'Moana - Trailer',
24 'description': 'A fun adventure for the entire Family! Bring home Moana on Digital HD Feb 21 & Blu-ray March 7',
25 'upload_date': '20170112',
29 'skip_download': True,
32 'url': 'http://videos.disneylatino.com/ver/spider-man-de-regreso-a-casa-primer-adelanto-543a33a1850bdcfcca13bae2',
33 'only_matching': True,
35 'url': 'http://video.en.disneyme.com/watch/future-worm/robo-carp-2001-544b66002aa7353cdd3f5114',
36 'only_matching': True,
38 'url': 'http://video.disneyturkiye.com.tr/izle/7c-7-cuceler/kimin-sesi-zaten-5456f3d015f6b36c8afdd0e2',
39 'only_matching': True,
41 'url': 'http://disneyjunior.disney.com/embed/546a4798ddba3d1612e4005d',
42 'only_matching': True,
44 'url': 'http://www.starwars.com/embed/54690d1e6c42e5f09a0fb097',
45 'only_matching': True,
48 def _real_extract(self
, url
):
49 domain
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
50 webpage
= self
._download
_webpage
(
51 'http://%s/embed/%s' % (domain
, video_id
), video_id
)
52 video_data
= self
._parse
_json
(self
._search
_regex
(
53 r
'Disney\.EmbedVideo=({.+});', webpage
, 'embed data'), video_id
)['video']
55 for external
in video_data
.get('externals', []):
56 if external
.get('source') == 'vevo':
57 return self
.url_result('vevo:' + external
['data_id'], 'Vevo')
59 title
= video_data
['title']
62 for flavor
in video_data
.get('flavors', []):
63 flavor_format
= flavor
.get('format')
64 flavor_url
= flavor
.get('url')
65 if not flavor_url
or not re
.match(r
'https?://', flavor_url
):
67 tbr
= int_or_none(flavor
.get('bitrate'))
69 formats
.extend(self
._extract
_m
3u8_formats
(
70 flavor_url
, video_id
, 'mp4', m3u8_id
=flavor_format
, fatal
=False))
74 format_id
.append(flavor_format
)
76 format_id
.append(compat_str(tbr
))
77 ext
= determine_ext(flavor_url
)
78 if flavor_format
== 'applehttp' or ext
== 'm3u8':
80 width
= int_or_none(flavor
.get('width'))
81 height
= int_or_none(flavor
.get('height'))
83 'format_id': '-'.join(format_id
),
89 'vcodec': 'none' if (width
== 0 and height
== 0) else None,
91 self
._sort
_formats
(formats
)
94 for caption
in video_data
.get('captions', []):
95 caption_url
= caption
.get('url')
96 caption_format
= caption
.get('format')
97 if not caption_url
or caption_format
.startswith('unknown'):
99 subtitles
.setdefault(caption
.get('language', 'en'), []).append({
103 }.get(caption_format
, caption_format
),
109 'description': video_data
.get('description') or video_data
.get('short_desc'),
110 'thumbnail': video_data
.get('thumb') or video_data
.get('thumb_secure'),
111 'duration': int_or_none(video_data
.get('duration_sec')),
112 'upload_date': unified_strdate(video_data
.get('publish_date')),
114 'subtitles': subtitles
,