gamekings.py 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. xpath_text,
  6. xpath_with_ns,
  7. )
  8. class GamekingsIE(InfoExtractor):
  9. _VALID_URL = r'http://www\.gamekings\.nl/(?:videos|nieuws)/(?P<id>[^/]+)'
  10. _TESTS = [{
  11. 'url': 'http://www.gamekings.nl/videos/phoenix-wright-ace-attorney-dual-destinies-review/',
  12. # MD5 is flaky, seems to change regularly
  13. # 'md5': '2f32b1f7b80fdc5cb616efb4f387f8a3',
  14. 'info_dict': {
  15. 'id': 'HkSQKetlGOU',
  16. 'ext': 'mp4',
  17. 'title': 'Phoenix Wright: Ace Attorney - Dual Destinies Review',
  18. 'description': 'md5:db88c0e7f47e9ea50df3271b9dc72e1d',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. 'uploader_id': 'UCJugRGo4STYMeFr5RoOShtQ',
  21. 'uploader': 'Gamekings Vault',
  22. 'upload_date': '20151123',
  23. },
  24. }, {
  25. # vimeo video
  26. 'url': 'http://www.gamekings.nl/videos/the-legend-of-zelda-majoras-mask/',
  27. 'md5': '12bf04dfd238e70058046937657ea68d',
  28. 'info_dict': {
  29. 'id': 'the-legend-of-zelda-majoras-mask',
  30. 'ext': 'mp4',
  31. 'title': 'The Legend of Zelda: Majora’s Mask',
  32. 'description': 'md5:9917825fe0e9f4057601fe1e38860de3',
  33. 'thumbnail': 're:^https?://.*\.jpg$',
  34. },
  35. }, {
  36. 'url': 'http://www.gamekings.nl/nieuws/gamekings-extra-shelly-en-david-bereiden-zich-voor-op-de-livestream/',
  37. 'only_matching': True,
  38. }]
  39. def _real_extract(self, url):
  40. video_id = self._match_id(url)
  41. webpage = self._download_webpage(url, video_id)
  42. playlist_id = self._search_regex(
  43. r'gogoVideo\(.*,\s*"([^"]+)', webpage, 'playlist id')
  44. # Check if a YouTube embed is used
  45. if playlist_id.find('youtube') != -1:
  46. return self.url_result(playlist_id, ie='Youtube')
  47. playlist = self._download_xml(
  48. 'http://www.gamekings.tv/wp-content/themes/gk2010/rss_playlist.php?id=%s' % playlist_id,
  49. video_id)
  50. NS_MAP = {
  51. 'jwplayer': 'http://rss.jwpcdn.com/'
  52. }
  53. item = playlist.find('./channel/item')
  54. thumbnail = xpath_text(item, xpath_with_ns('./jwplayer:image', NS_MAP), 'thumbnail')
  55. video_url = item.find(xpath_with_ns('./jwplayer:source', NS_MAP)).get('file')
  56. return {
  57. 'id': video_id,
  58. 'url': video_url,
  59. 'title': self._og_search_title(webpage),
  60. 'description': self._og_search_description(webpage),
  61. 'thumbnail': thumbnail,
  62. }