2 from __future__
import unicode_literals
5 from .theplatform
import ThePlatformFeedIE
14 class CorusIE(ThePlatformFeedIE
):
34 disney(?:channel|lachaine)
40 videos?/(?:[^/]+/)*(?:[a-z0-9-]+-)?
43 [\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}|
44 (?:[A-Z]{4})?\d{12,20}
48 'url': 'http://www.hgtv.ca/shows/bryan-inc/videos/movie-night-popcorn-with-bryan-870923331648/',
52 'title': 'Movie Night Popcorn with Bryan',
53 'description': 'Bryan whips up homemade popcorn, the old fashion way for Jojo and Lincoln.',
54 'upload_date': '20170206',
55 'timestamp': 1486392197,
58 'format': 'bestvideo',
59 'skip_download': True,
61 'expected_warnings': ['Failed to parse JSON'],
63 'url': 'http://www.foodnetwork.ca/shows/chopped/video/episode/chocolate-obsession/video.html?v=872683587753',
64 'only_matching': True,
66 'url': 'http://etcanada.com/video/873675331955/meet-the-survivor-game-changers-castaways-part-2/',
67 'only_matching': True,
69 'url': 'http://www.history.ca/the-world-without-canada/video/full-episodes/natural-resources/video.html?v=955054659646#video',
70 'only_matching': True,
72 'url': 'http://www.showcase.ca/eyewitness/video/eyewitness++106/video.html?v=955070531919&p=1&s=da#video',
73 'only_matching': True,
75 'url': 'http://www.bigbrothercanada.ca/video/1457812035894/',
78 'url': 'https://www.bigbrothercanada.ca/video/big-brother-canada-704/1457812035894/',
81 'url': 'https://www.seriesplus.com/emissions/dre-mary-mort-sur-ordonnance/videos/deux-coeurs-battant/SERP0055626330000200/',
84 'url': 'https://www.disneychannel.ca/shows/gabby-duran-the-unsittables/video/crybaby-duran-clip/2f557eec-0588-11ea-ae2b-e2c6776b770e/',
91 'foodnetwork': 'food',
92 'bigbrothercanada': 'series',
93 'disneychannel': 'disneyen',
94 'disneylachaine': 'disneyfr',
97 def _real_extract(self
, url
):
98 domain
, video_id
= self
._match
_valid
_url
(url
).groups()
99 site
= domain
.split('.')[0]
100 path
= self
._SITE
_MAP
.get(site
, site
)
102 path
= 'migration/' + path
103 video
= self
._download
_json
(
104 'https://globalcontent.corusappservices.com/templates/%s/playlist/' % path
,
105 video_id
, query
={'byId': video_id}
,
106 headers
={'Accept': 'application/json'}
)[0]
107 title
= video
['title']
110 for source
in video
.get('sources', []):
111 smil_url
= source
.get('file')
114 source_type
= source
.get('type')
115 note
= 'Downloading%s smil file' % (' ' + source_type
if source_type
else '')
116 resp
= self
._download
_webpage
(
117 smil_url
, video_id
, note
, fatal
=False,
118 headers
=self
.geo_verification_headers())
121 error
= self
._parse
_json
(resp
, video_id
, fatal
=False)
123 if error
.get('exception') == 'GeoLocationBlocked':
124 self
.raise_geo_restricted(countries
=['CA'])
125 raise ExtractorError(error
['description'])
126 smil
= self
._parse
_xml
(resp
, video_id
, fatal
=False)
129 namespace
= self
._parse
_smil
_namespace
(smil
)
130 formats
.extend(self
._parse
_smil
_formats
(
131 smil
, smil_url
, video_id
, namespace
))
132 if not formats
and video
.get('drm'):
133 self
.raise_no_formats('This video is DRM protected.', expected
=True)
134 self
._sort
_formats
(formats
)
137 for track
in video
.get('tracks', []):
138 track_url
= track
.get('file')
141 lang
= 'fr' if site
in ('disneylachaine', 'seriesplus') else 'en'
142 subtitles
.setdefault(lang
, []).append({'url': track_url}
)
144 metadata
= video
.get('metadata') or {}
145 get_number
= lambda x
: int_or_none(video
.get('pl1$' + x
) or metadata
.get(x
+ 'Number'))
151 'thumbnail': dict_get(video
, ('defaultThumbnailUrl', 'thumbnail', 'image')),
152 'description': video
.get('description'),
153 'timestamp': int_or_none(video
.get('availableDate'), 1000),
154 'subtitles': subtitles
,
155 'duration': float_or_none(metadata
.get('duration')),
156 'series': dict_get(video
, ('show', 'pl1$show')),
157 'season_number': get_number('season'),
158 'episode_number': get_number('episode'),