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.

76 lines
2.6 KiB

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