You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
2.1 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .brightcove import BrightcoveNewIE
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. clean_html,
  7. get_element_by_class,
  8. get_element_by_id,
  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. BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/694940074001/default_default/index.html?videoId=%s'
  38. def _real_extract(self, url):
  39. display_id = self._match_id(url)
  40. webpage = self._download_webpage(
  41. url, display_id, headers=self.geo_verification_headers())
  42. brightcove_id = clean_html(get_element_by_class('field--name-field-brightcove-video-id', webpage) or get_element_by_id('video-source-content', webpage))
  43. brightcove_url = self.BRIGHTCOVE_URL_TEMPLATE % brightcove_id if brightcove_id else BrightcoveNewIE._extract_url(self, webpage)
  44. return self.url_result(brightcove_url, 'BrightcoveNew', brightcove_id)