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.

69 lines
2.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  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\.tv/videos/(?P<name>[0-9a-z\-]+)'
  10. _TESTS = [
  11. {
  12. 'url': 'http://www.gamekings.tv/videos/phoenix-wright-ace-attorney-dual-destinies-review/',
  13. # MD5 is flaky, seems to change regularly
  14. # 'md5': '2f32b1f7b80fdc5cb616efb4f387f8a3',
  15. 'info_dict': {
  16. 'id': '20130811',
  17. 'ext': 'mp4',
  18. 'title': 'Phoenix Wright: Ace Attorney \u2013 Dual Destinies Review',
  19. 'description': 'md5:36fd701e57e8c15ac8682a2374c99731',
  20. }
  21. },
  22. {
  23. 'url': 'http://www.gamekings.tv/videos/the-legend-of-zelda-majoras-mask/',
  24. 'info_dict': {
  25. 'id': '118933752',
  26. 'ext': 'mp4',
  27. 'title': 'The Legend of Zelda: Majora’s Mask',
  28. 'description': 'md5:9917825fe0e9f4057601fe1e38860de3'
  29. }
  30. }
  31. ]
  32. def _real_extract(self, url):
  33. mobj = re.match(self._VALID_URL, url)
  34. name = mobj.group('name')
  35. webpage = self._download_webpage(url, name)
  36. playlist_id = re.search(r'(?:gogoVideo)\(\d+,"?(?P<playlist_id>.*)"', webpage, re.MULTILINE).group('playlist_id')
  37. playlist_url = 'http://www.gamekings.tv/wp-content/themes/gk2010/rss_playlist.php?id=' + playlist_id
  38. playlist_rss = self._download_xml(playlist_url, playlist_id)
  39. NS_MAP = {
  40. 'jwplayer': 'http://rss.jwpcdn.com/'
  41. }
  42. item = playlist_rss.find('./channel/item')
  43. image = xpath_text(item, xpath_with_ns('./jwplayer:image', NS_MAP), 'image')
  44. file_node = item.find(xpath_with_ns('./jwplayer:source', NS_MAP))
  45. video_url = file_node.get('file')
  46. video = re.search(r'[0-9]+', video_url)
  47. video_id = video.group(0)
  48. # Todo: Add medium format
  49. return {
  50. 'id': video_id,
  51. 'ext': 'mp4',
  52. 'url': video_url,
  53. 'title': self._og_search_title(webpage),
  54. 'description': self._og_search_description(webpage),
  55. }