]>
Commit | Line | Data |
---|---|---|
7e760fc1 S |
1 | from __future__ import unicode_literals |
2 | ||
3 | from .common import InfoExtractor | |
69f85952 | 4 | from ..utils import remove_end |
7e760fc1 S |
5 | |
6 | ||
7 | class ESPNIE(InfoExtractor): | |
8 | _VALID_URL = r'https?://espn\.go\.com/(?:[^/]+/)*(?P<id>[^/]+)' | |
7e760fc1 S |
9 | _TESTS = [{ |
10 | 'url': 'http://espn.go.com/video/clip?id=10365079', | |
277c7465 | 11 | 'md5': '60e5d097a523e767d06479335d1bdc58', |
7e760fc1 S |
12 | 'info_dict': { |
13 | 'id': 'FkYWtmazr6Ed8xmvILvKLWjd4QvYZpzG', | |
14 | 'ext': 'mp4', | |
69f85952 | 15 | 'title': '30 for 30 Shorts: Judging Jewell', |
9f9f7664 | 16 | 'description': None, |
7e760fc1 | 17 | }, |
688c634b | 18 | 'params': { |
19 | 'skip_download': True, | |
20 | }, | |
277c7465 | 21 | 'add_ie': ['OoyalaExternal'], |
930087f2 JMF |
22 | }, { |
23 | # intl video, from http://www.espnfc.us/video/mls-highlights/150/video/2743663/must-see-moments-best-of-the-mls-season | |
24 | 'url': 'http://espn.go.com/video/clip?id=2743663', | |
277c7465 | 25 | 'md5': 'f4ac89b59afc7e2d7dbb049523df6768', |
930087f2 JMF |
26 | 'info_dict': { |
27 | 'id': '50NDFkeTqRHB0nXBOK-RGdSG5YQPuxHg', | |
28 | 'ext': 'mp4', | |
69f85952 | 29 | 'title': 'Must-See Moments: Best of the MLS season', |
930087f2 | 30 | }, |
688c634b | 31 | 'params': { |
32 | 'skip_download': True, | |
33 | }, | |
277c7465 | 34 | 'add_ie': ['OoyalaExternal'], |
7e760fc1 S |
35 | }, { |
36 | 'url': 'https://espn.go.com/video/iframe/twitter/?cms=espn&id=10365079', | |
37 | 'only_matching': True, | |
38 | }, { | |
39 | 'url': 'http://espn.go.com/nba/recap?gameId=400793786', | |
40 | 'only_matching': True, | |
41 | }, { | |
42 | 'url': 'http://espn.go.com/blog/golden-state-warriors/post/_/id/593/how-warriors-rapidly-regained-a-winning-edge', | |
43 | 'only_matching': True, | |
44 | }, { | |
45 | 'url': 'http://espn.go.com/sports/endurance/story/_/id/12893522/dzhokhar-tsarnaev-sentenced-role-boston-marathon-bombings', | |
46 | 'only_matching': True, | |
47 | }, { | |
48 | 'url': 'http://espn.go.com/nba/playoffs/2015/story/_/id/12887571/john-wall-washington-wizards-no-swelling-left-hand-wrist-game-5-return', | |
49 | 'only_matching': True, | |
50 | }] | |
51 | ||
52 | def _real_extract(self, url): | |
53 | video_id = self._match_id(url) | |
54 | ||
55 | webpage = self._download_webpage(url, video_id) | |
56 | ||
57 | video_id = self._search_regex( | |
83ab8a79 S |
58 | r'class=(["\']).*?video-play-button.*?\1[^>]+data-id=["\'](?P<id>\d+)', |
59 | webpage, 'video id', group='id') | |
7e760fc1 | 60 | |
930087f2 JMF |
61 | cms = 'espn' |
62 | if 'data-source="intl"' in webpage: | |
63 | cms = 'intl' | |
64 | player_url = 'https://espn.go.com/video/iframe/twitter/?id=%s&cms=%s' % (video_id, cms) | |
7e760fc1 | 65 | player = self._download_webpage( |
930087f2 | 66 | player_url, video_id) |
7e760fc1 S |
67 | |
68 | pcode = self._search_regex( | |
69 | r'["\']pcode=([^"\']+)["\']', player, 'pcode') | |
70 | ||
69f85952 JMF |
71 | title = remove_end( |
72 | self._og_search_title(webpage), | |
73 | '- ESPN Video').strip() | |
74 | ||
75 | return { | |
76 | '_type': 'url_transparent', | |
77 | 'url': 'ooyalaexternal:%s:%s:%s' % (cms, video_id, pcode), | |
78 | 'ie_key': 'OoyalaExternal', | |
79 | 'title': title, | |
80 | } |