[ctv] add support for (tsn,bnn,thecomedynetwork).ca websites(#10016)
[youtube-dl] / youtube_dl / extractor / ctv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class CTVIE(InfoExtractor):
10     _VALID_URL = r'https?://(?:www\.)?(?P<domain>ctv|tsn|bnn|thecomedynetwork)\.ca/.*?(?:\bvid=|-vid|~|%7E)(?P<id>[0-9.]+)'
11     _TESTS = [{
12         'url': 'http://www.ctv.ca/video/player?vid=706966',
13         'md5': 'ff2ebbeae0aa2dcc32a830c3fd69b7b0',
14         'info_dict': {
15             'id': '706966',
16             'ext': 'mp4',
17             'title': 'Larry Day and Richard Jutras on the TIFF red carpet of \'Stonewall\'',
18             'description': 'etalk catches up with Larry Day and Richard Jutras on the TIFF red carpet of "Stonewall”.',
19             'upload_date': '20150919',
20             'timestamp': 1442624700,
21         },
22         'expected_warnings': ['HTTP Error 404'],
23     }, {
24         'url': 'http://www.thecomedynetwork.ca/video/player?vid=923582',
25         'only_matching': True,
26     }, {
27         'url': 'http://www.tsn.ca/video/expectations-high-for-milos-raonic-at-us-open~939549',
28         'only_matching': True,
29     }, {
30         'url': 'http://www.bnn.ca/video/berman-s-call-part-two-viewer-questions~939654',
31         'only_matching': True,
32     }, {
33         'url': 'http://www.ctv.ca/YourMorning/Video/S1E6-Monday-August-29-2016-vid938009',
34         'only_matching': True,
35     }]
36
37     def _real_extract(self, url):
38         domain, video_id = re.match(self._VALID_URL, url).groups()
39         if domain == 'thecomedynetwork':
40             domain = 'comedy'
41         return {
42             '_type': 'url_transparent',
43             'id': video_id,
44             'url': '9c9media:%s_web:%s' % (domain, video_id),
45             'ie_key': 'NineCNineMedia',
46         }