]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/corus.py
Prepare to release.
[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'https?://(?:www\.)?(?P<domain>(?:globaltv|etcanada)\.com|(?:hgtv|foodnetwork|slice)\.ca)/(?:video/|(?:[^/]+/)+(?:videos/[a-z0-9-]+-|video\.html\?.*?\bv=))(?P<id>\d+)'
12 _TESTS = [{
13 'url': 'http://www.hgtv.ca/shows/bryan-inc/videos/movie-night-popcorn-with-bryan-870923331648/',
14 'md5': '05dcbca777bf1e58c2acbb57168ad3a6',
15 'info_dict': {
16 'id': '870923331648',
17 'ext': 'mp4',
18 'title': 'Movie Night Popcorn with Bryan',
19 'description': 'Bryan whips up homemade popcorn, the old fashion way for Jojo and Lincoln.',
20 'uploader': 'SHWM-NEW',
21 'upload_date': '20170206',
22 'timestamp': 1486392197,
23 },
24 }, {
25 'url': 'http://www.foodnetwork.ca/shows/chopped/video/episode/chocolate-obsession/video.html?v=872683587753',
26 'only_matching': True,
27 }, {
28 'url': 'http://etcanada.com/video/873675331955/meet-the-survivor-game-changers-castaways-part-2/',
29 'only_matching': True,
30 }]
31
32 _TP_FEEDS = {
33 'globaltv': {
34 'feed_id': 'ChQqrem0lNUp',
35 'account_id': 2269680845,
36 },
37 'etcanada': {
38 'feed_id': 'ChQqrem0lNUp',
39 'account_id': 2269680845,
40 },
41 'hgtv': {
42 'feed_id': 'L0BMHXi2no43',
43 'account_id': 2414428465,
44 },
45 'foodnetwork': {
46 'feed_id': 'ukK8o58zbRmJ',
47 'account_id': 2414429569,
48 },
49 'slice': {
50 'feed_id': '5tUJLgV2YNJ5',
51 'account_id': 2414427935,
52 },
53 }
54
55 def _real_extract(self, url):
56 domain, video_id = re.match(self._VALID_URL, url).groups()
57 feed_info = self._TP_FEEDS[domain.split('.')[0]]
58 return self._extract_feed_info('dtjsEC', feed_info['feed_id'], 'byId=' + video_id, video_id, lambda e: {
59 'episode_number': int_or_none(e.get('pl1$episode')),
60 'season_number': int_or_none(e.get('pl1$season')),
61 'series': e.get('pl1$show'),
62 }, {
63 'HLS': {
64 'manifest': 'm3u',
65 },
66 'DesktopHLS Default': {
67 'manifest': 'm3u',
68 },
69 'MP4 MBR': {
70 'manifest': 'm3u',
71 },
72 }, feed_info['account_id'])