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.

134 lines
4.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. xpath_with_ns,
  7. parse_iso8601,
  8. float_or_none,
  9. int_or_none,
  10. )
  11. NAMESPACE_MAP = {
  12. 'media': 'http://search.yahoo.com/mrss/',
  13. }
  14. # URL prefix to download the mp4 files directly instead of streaming via rtmp
  15. # Credits go to XBox-Maniac
  16. # http://board.jdownloader.org/showpost.php?p=185835&postcount=31
  17. RAW_MP4_URL = 'http://cdn.riptide-mtvn.com/'
  18. class GameOneIE(InfoExtractor):
  19. _VALID_URL = r'https?://(?:www\.)?gameone\.de/tv/(?P<id>\d+)'
  20. _TESTS = [
  21. {
  22. 'url': 'http://www.gameone.de/tv/288',
  23. 'md5': '136656b7fb4c9cb4a8e2d500651c499b',
  24. 'info_dict': {
  25. 'id': '288',
  26. 'ext': 'mp4',
  27. 'title': 'Game One - Folge 288',
  28. 'duration': 1238,
  29. 'thumbnail': 'http://s3.gameone.de/gameone/assets/video_metas/teaser_images/000/643/636/big/640x360.jpg',
  30. 'description': 'FIFA-Pressepokal 2014, Star Citizen, Kingdom Come: Deliverance, Project Cars, Schöner Trants Nerdquiz Folge 2 Runde 1',
  31. 'age_limit': 16,
  32. 'upload_date': '20140513',
  33. 'timestamp': 1399980122,
  34. }
  35. },
  36. {
  37. 'url': 'http://gameone.de/tv/220',
  38. 'md5': '5227ca74c4ae6b5f74c0510a7c48839e',
  39. 'info_dict': {
  40. 'id': '220',
  41. 'ext': 'mp4',
  42. 'upload_date': '20120918',
  43. 'description': 'Jet Set Radio HD, Tekken Tag Tournament 2, Source Filmmaker',
  44. 'timestamp': 1347971451,
  45. 'title': 'Game One - Folge 220',
  46. 'duration': 896.62,
  47. 'age_limit': 16,
  48. }
  49. }
  50. ]
  51. def _real_extract(self, url):
  52. video_id = self._match_id(url)
  53. webpage = self._download_webpage(url, video_id)
  54. og_video = self._og_search_video_url(webpage, secure=False)
  55. description = self._html_search_meta('description', webpage)
  56. age_limit = int(
  57. self._search_regex(
  58. r'age=(\d+)',
  59. self._html_search_meta(
  60. 'age-de-meta-label',
  61. webpage),
  62. 'age_limit',
  63. '0'))
  64. mrss_url = self._search_regex(r'mrss=([^&]+)', og_video, 'mrss')
  65. mrss = self._download_xml(mrss_url, video_id, 'Downloading mrss')
  66. title = mrss.find('.//item/title').text
  67. thumbnail = mrss.find('.//item/image').get('url')
  68. timestamp = parse_iso8601(mrss.find('.//pubDate').text, delimiter=' ')
  69. content = mrss.find(xpath_with_ns('.//media:content', NAMESPACE_MAP))
  70. content_url = content.get('url')
  71. content = self._download_xml(
  72. content_url,
  73. video_id,
  74. 'Downloading media:content')
  75. rendition_items = content.findall('.//rendition')
  76. duration = float_or_none(rendition_items[0].get('duration'))
  77. formats = [
  78. {
  79. 'url': re.sub(r'.*/(r2)', RAW_MP4_URL + r'\1', r.find('./src').text),
  80. 'width': int_or_none(r.get('width')),
  81. 'height': int_or_none(r.get('height')),
  82. 'tbr': int_or_none(r.get('bitrate')),
  83. }
  84. for r in rendition_items
  85. ]
  86. self._sort_formats(formats)
  87. return {
  88. 'id': video_id,
  89. 'title': title,
  90. 'thumbnail': thumbnail,
  91. 'duration': duration,
  92. 'formats': formats,
  93. 'description': description,
  94. 'age_limit': age_limit,
  95. 'timestamp': timestamp,
  96. }
  97. class GameOnePlaylistIE(InfoExtractor):
  98. _VALID_URL = r'https?://(?:www\.)?gameone\.de(?:/tv)?/?$'
  99. IE_NAME = 'gameone:playlist'
  100. _TEST = {
  101. 'url': 'http://www.gameone.de/tv',
  102. 'info_dict': {
  103. 'title': 'GameOne',
  104. },
  105. 'playlist_mincount': 294,
  106. }
  107. def _real_extract(self, url):
  108. webpage = self._download_webpage('http://www.gameone.de/tv', 'TV')
  109. max_id = max(map(int, re.findall(r'<a href="/tv/(\d+)"', webpage)))
  110. entries = [
  111. self.url_result('http://www.gameone.de/tv/%d' %
  112. video_id, 'GameOne')
  113. for video_id in range(max_id, 0, -1)]
  114. return {
  115. '_type': 'playlist',
  116. 'title': 'GameOne',
  117. 'entries': entries,
  118. }