]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/corus.py
Update upstream source from tag 'upstream/2019.09.28'
[youtubedl] / youtube_dl / extractor / corus.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .theplatform import ThePlatformFeedIE
7 from ..utils import int_or_none
8
9
10 class CorusIE(ThePlatformFeedIE):
11 _VALID_URL = r'''(?x)
12 https?://
13 (?:www\.)?
14 (?P<domain>
15 (?:globaltv|etcanada)\.com|
16 (?:hgtv|foodnetwork|slice|history|showcase|bigbrothercanada)\.ca
17 )
18 /(?:video/(?:[^/]+/)?|(?:[^/]+/)+(?:videos/[a-z0-9-]+-|video\.html\?.*?\bv=))
19 (?P<id>\d+)
20 '''
21 _TESTS = [{
22 'url': 'http://www.hgtv.ca/shows/bryan-inc/videos/movie-night-popcorn-with-bryan-870923331648/',
23 'md5': '05dcbca777bf1e58c2acbb57168ad3a6',
24 'info_dict': {
25 'id': '870923331648',
26 'ext': 'mp4',
27 'title': 'Movie Night Popcorn with Bryan',
28 'description': 'Bryan whips up homemade popcorn, the old fashion way for Jojo and Lincoln.',
29 'uploader': 'SHWM-NEW',
30 'upload_date': '20170206',
31 'timestamp': 1486392197,
32 },
33 }, {
34 'url': 'http://www.foodnetwork.ca/shows/chopped/video/episode/chocolate-obsession/video.html?v=872683587753',
35 'only_matching': True,
36 }, {
37 'url': 'http://etcanada.com/video/873675331955/meet-the-survivor-game-changers-castaways-part-2/',
38 'only_matching': True,
39 }, {
40 'url': 'http://www.history.ca/the-world-without-canada/video/full-episodes/natural-resources/video.html?v=955054659646#video',
41 'only_matching': True,
42 }, {
43 'url': 'http://www.showcase.ca/eyewitness/video/eyewitness++106/video.html?v=955070531919&p=1&s=da#video',
44 'only_matching': True,
45 }, {
46 'url': 'http://www.bigbrothercanada.ca/video/1457812035894/',
47 'only_matching': True
48 }, {
49 'url': 'https://www.bigbrothercanada.ca/video/big-brother-canada-704/1457812035894/',
50 'only_matching': True
51 }]
52
53 _TP_FEEDS = {
54 'globaltv': {
55 'feed_id': 'ChQqrem0lNUp',
56 'account_id': 2269680845,
57 },
58 'etcanada': {
59 'feed_id': 'ChQqrem0lNUp',
60 'account_id': 2269680845,
61 },
62 'hgtv': {
63 'feed_id': 'L0BMHXi2no43',
64 'account_id': 2414428465,
65 },
66 'foodnetwork': {
67 'feed_id': 'ukK8o58zbRmJ',
68 'account_id': 2414429569,
69 },
70 'slice': {
71 'feed_id': '5tUJLgV2YNJ5',
72 'account_id': 2414427935,
73 },
74 'history': {
75 'feed_id': 'tQFx_TyyEq4J',
76 'account_id': 2369613659,
77 },
78 'showcase': {
79 'feed_id': '9H6qyshBZU3E',
80 'account_id': 2414426607,
81 },
82 'bigbrothercanada': {
83 'feed_id': 'ChQqrem0lNUp',
84 'account_id': 2269680845,
85 },
86 }
87
88 def _real_extract(self, url):
89 domain, video_id = re.match(self._VALID_URL, url).groups()
90 feed_info = self._TP_FEEDS[domain.split('.')[0]]
91 return self._extract_feed_info('dtjsEC', feed_info['feed_id'], 'byId=' + video_id, video_id, lambda e: {
92 'episode_number': int_or_none(e.get('pl1$episode')),
93 'season_number': int_or_none(e.get('pl1$season')),
94 'series': e.get('pl1$show'),
95 }, {
96 'HLS': {
97 'manifest': 'm3u',
98 },
99 'DesktopHLS Default': {
100 'manifest': 'm3u',
101 },
102 'MP4 MBR': {
103 'manifest': 'm3u',
104 },
105 }, feed_info['account_id'])