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