]>
Commit | Line | Data |
---|---|---|
1 | from .brightcove import BrightcoveNewIE | |
2 | from .common import InfoExtractor | |
3 | from ..utils import ( | |
4 | clean_html, | |
5 | get_element_by_class, | |
6 | get_element_by_id, | |
7 | ) | |
8 | ||
9 | ||
10 | class GameInformerIE(InfoExtractor): | |
11 | _VALID_URL = r'https?://(?:www\.)?gameinformer\.com/(?:[^/]+/)*(?P<id>[^.?&#]+)' | |
12 | _TESTS = [{ | |
13 | # normal Brightcove embed code extracted with BrightcoveNewIE._extract_url | |
14 | 'url': 'http://www.gameinformer.com/b/features/archive/2015/09/26/replay-animal-crossing.aspx', | |
15 | 'md5': '292f26da1ab4beb4c9099f1304d2b071', | |
16 | 'info_dict': { | |
17 | 'id': '4515472681001', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Replay - Animal Crossing', | |
20 | 'description': 'md5:2e211891b215c85d061adc7a4dd2d930', | |
21 | 'timestamp': 1443457610, | |
22 | 'upload_date': '20150928', | |
23 | 'uploader_id': '694940074001', | |
24 | }, | |
25 | }, { | |
26 | # Brightcove id inside unique element with field--name-field-brightcove-video-id class | |
27 | 'url': 'https://www.gameinformer.com/video-feature/new-gameplay-today/2019/07/09/new-gameplay-today-streets-of-rogue', | |
28 | 'info_dict': { | |
29 | 'id': '6057111913001', | |
30 | 'ext': 'mp4', | |
31 | 'title': 'New Gameplay Today – Streets Of Rogue', | |
32 | 'timestamp': 1562699001, | |
33 | 'upload_date': '20190709', | |
34 | 'uploader_id': '694940074001', | |
35 | ||
36 | }, | |
37 | }] | |
38 | BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/694940074001/default_default/index.html?videoId=%s' | |
39 | ||
40 | def _real_extract(self, url): | |
41 | display_id = self._match_id(url) | |
42 | webpage = self._download_webpage( | |
43 | url, display_id, headers=self.geo_verification_headers()) | |
44 | brightcove_id = clean_html(get_element_by_class('field--name-field-brightcove-video-id', webpage) or get_element_by_id('video-source-content', webpage)) | |
45 | brightcove_url = self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id if brightcove_id else BrightcoveNewIE._extract_url(self, webpage) | |
46 | return self.url_result(brightcove_url, 'BrightcoveNew', brightcove_id) |