]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/roosterteeth.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
17 class RoosterTeethIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:.+?\.)?roosterteeth\.com/(?:episode|watch)/(?P<id>[^/?#&]+)'
19 _NETRC_MACHINE
= 'roosterteeth'
21 'url': 'http://roosterteeth.com/episode/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
22 'md5': 'e2bd7764732d785ef797700a2489f212',
25 'display_id': 'million-dollars-but-season-2-million-dollars-but-the-game-announcement',
27 'title': 'Million Dollars, But... The Game Announcement',
28 'description': 'md5:168a54b40e228e79f4ddb141e89fe4f5',
29 'thumbnail': r
're:^https?://.*\.png$',
30 'series': 'Million Dollars, But...',
31 'episode': 'Million Dollars, But... The Game Announcement',
34 'url': 'http://achievementhunter.roosterteeth.com/episode/off-topic-the-achievement-hunter-podcast-2016-i-didn-t-think-it-would-pass-31',
35 'only_matching': True,
37 'url': 'http://funhaus.roosterteeth.com/episode/funhaus-shorts-2016-austin-sucks-funhaus-shorts',
38 'only_matching': True,
40 'url': 'http://screwattack.roosterteeth.com/episode/death-battle-season-3-mewtwo-vs-shadow',
41 'only_matching': True,
43 'url': 'http://theknow.roosterteeth.com/episode/the-know-game-news-season-1-boring-steam-sales-are-better',
44 'only_matching': True,
46 # only available for FIRST members
47 'url': 'http://roosterteeth.com/episode/rt-docs-the-world-s-greatest-head-massage-the-world-s-greatest-head-massage-an-asmr-journey-part-one',
48 'only_matching': True,
50 'url': 'https://roosterteeth.com/watch/million-dollars-but-season-2-million-dollars-but-the-game-announcement',
51 'only_matching': True,
53 _EPISODE_BASE_URL
= 'https://svod-be.roosterteeth.com/api/v1/episodes/'
56 username
, password
= self
._get
_login
_info
()
62 'https://auth.roosterteeth.com/oauth/token',
63 None, 'Logging in', data
=urlencode_postdata({
64 'client_id': '4338d2b4bdc8db1239360f28e72f0d9ddb1fd01e7a38fbb07b4b1f4ba4564cc5',
65 'grant_type': 'password',
69 except ExtractorError
as e
:
70 msg
= 'Unable to login'
71 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
72 resp
= self
._parse
_json
(e
.cause
.read().decode(), None, fatal
=False)
74 error
= resp
.get('extra_info') or resp
.get('error_description') or resp
.get('error')
77 self
.report_warning(msg
)
79 def _real_initialize(self
):
80 if self
._get
_cookies
(self
._EPISODE
_BASE
_URL
).get('rt_access_token'):
84 def _real_extract(self
, url
):
85 display_id
= self
._match
_id
(url
)
86 api_episode_url
= self
._EPISODE
_BASE
_URL
+ display_id
89 m3u8_url
= self
._download
_json
(
90 api_episode_url
+ '/videos', display_id
,
91 'Downloading video JSON metadata')['data'][0]['attributes']['url']
92 except ExtractorError
as e
:
93 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 403:
94 if self
._parse
_json
(e
.cause
.read().decode(), display_id
).get('access') is False:
95 self
.raise_login_required(
96 '%s is only available for FIRST members' % display_id
)
99 formats
= self
._extract
_m
3u8_formats
(
100 m3u8_url
, display_id
, 'mp4', 'm3u8_native', m3u8_id
='hls')
101 self
._sort
_formats
(formats
)
103 episode
= self
._download
_json
(
104 api_episode_url
, display_id
,
105 'Downloading episode JSON metadata')['data'][0]
106 attributes
= episode
['attributes']
107 title
= attributes
.get('title') or attributes
['display_title']
108 video_id
= compat_str(episode
['id'])
111 for image
in episode
.get('included', {}).get('images', []):
112 if image
.get('type') == 'episode_image':
113 img_attributes
= image
.get('attributes') or {}
114 for k
in ('thumb', 'small', 'medium', 'large'):
115 img_url
= img_attributes
.get(k
)
124 'display_id': display_id
,
126 'description': attributes
.get('description') or attributes
.get('caption'),
127 'thumbnails': thumbnails
,
128 'series': attributes
.get('show_title'),
129 'season_number': int_or_none(attributes
.get('season_number')),
130 'season_id': attributes
.get('season_id'),
132 'episode_number': int_or_none(attributes
.get('number')),
133 'episode_id': str_or_none(episode
.get('uuid')),
135 'channel_id': attributes
.get('channel_id'),
136 'duration': int_or_none(attributes
.get('length')),