[espn] Update test
[youtube-dl] / youtube_dl / extractor / espn.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class ESPNIE(InfoExtractor):
7     _VALID_URL = r'https?://espn\.go\.com/(?:[^/]+/)*(?P<id>[^/]+)'
8     _TESTS = [{
9         'url': 'http://espn.go.com/video/clip?id=10365079',
10         'info_dict': {
11             'id': 'FkYWtmazr6Ed8xmvILvKLWjd4QvYZpzG',
12             'ext': 'mp4',
13             'title': 'dm_140128_30for30Shorts___JudgingJewellv2',
14             'description': None,
15         },
16         'params': {
17             # m3u8 download
18             'skip_download': True,
19         },
20     }, {
21         'url': 'https://espn.go.com/video/iframe/twitter/?cms=espn&id=10365079',
22         'only_matching': True,
23     }, {
24         'url': 'http://espn.go.com/nba/recap?gameId=400793786',
25         'only_matching': True,
26     }, {
27         'url': 'http://espn.go.com/blog/golden-state-warriors/post/_/id/593/how-warriors-rapidly-regained-a-winning-edge',
28         'only_matching': True,
29     }, {
30         'url': 'http://espn.go.com/sports/endurance/story/_/id/12893522/dzhokhar-tsarnaev-sentenced-role-boston-marathon-bombings',
31         'only_matching': True,
32     }, {
33         'url': 'http://espn.go.com/nba/playoffs/2015/story/_/id/12887571/john-wall-washington-wizards-no-swelling-left-hand-wrist-game-5-return',
34         'only_matching': True,
35     }]
36
37     def _real_extract(self, url):
38         video_id = self._match_id(url)
39
40         webpage = self._download_webpage(url, video_id)
41
42         video_id = self._search_regex(
43             r'class="video-play-button"[^>]+data-id="(\d+)',
44             webpage, 'video id')
45
46         player = self._download_webpage(
47             'https://espn.go.com/video/iframe/twitter/?id=%s' % video_id, video_id)
48
49         pcode = self._search_regex(
50             r'["\']pcode=([^"\']+)["\']', player, 'pcode')
51
52         return self.url_result(
53             'ooyalaexternal:espn:%s:%s' % (video_id, pcode),
54             'OoyalaExternal')