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.

135 lines
4.5 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. mobj = re.match(self._VALID_URL, url)
  53. video_id = mobj.group('id')
  54. webpage = self._download_webpage(url, video_id)
  55. og_video = self._og_search_video_url(webpage, secure=False)
  56. description = self._html_search_meta('description', webpage)
  57. age_limit = int(
  58. self._search_regex(
  59. r'age=(\d+)',
  60. self._html_search_meta(
  61. 'age-de-meta-label',
  62. webpage),
  63. 'age_limit',
  64. '0'))
  65. mrss_url = self._search_regex(r'mrss=([^&]+)', og_video, 'mrss')
  66. mrss = self._download_xml(mrss_url, video_id, 'Downloading mrss')
  67. title = mrss.find('.//item/title').text
  68. thumbnail = mrss.find('.//item/image').get('url')
  69. timestamp = parse_iso8601(mrss.find('.//pubDate').text, delimiter=' ')
  70. content = mrss.find(xpath_with_ns('.//media:content', NAMESPACE_MAP))
  71. content_url = content.get('url')
  72. content = self._download_xml(
  73. content_url,
  74. video_id,
  75. 'Downloading media:content')
  76. rendition_items = content.findall('.//rendition')
  77. duration = float_or_none(rendition_items[0].get('duration'))
  78. formats = [
  79. {
  80. 'url': re.sub(r'.*/(r2)', RAW_MP4_URL + r'\1', r.find('./src').text),
  81. 'width': int_or_none(r.get('width')),
  82. 'height': int_or_none(r.get('height')),
  83. 'tbr': int_or_none(r.get('bitrate')),
  84. }
  85. for r in rendition_items
  86. ]
  87. self._sort_formats(formats)
  88. return {
  89. 'id': video_id,
  90. 'title': title,
  91. 'thumbnail': thumbnail,
  92. 'duration': duration,
  93. 'formats': formats,
  94. 'description': description,
  95. 'age_limit': age_limit,
  96. 'timestamp': timestamp,
  97. }
  98. class GameOnePlaylistIE(InfoExtractor):
  99. _VALID_URL = r'https?://(?:www\.)?gameone\.de(?:/tv)?/?$'
  100. IE_NAME = 'gameone:playlist'
  101. _TEST = {
  102. 'url': 'http://www.gameone.de/tv',
  103. 'info_dict': {
  104. 'title': 'GameOne',
  105. },
  106. 'playlist_mincount': 294,
  107. }
  108. def _real_extract(self, url):
  109. webpage = self._download_webpage('http://www.gameone.de/tv', 'TV')
  110. max_id = max(map(int, re.findall(r'<a href="/tv/(\d+)"', webpage)))
  111. entries = [
  112. self.url_result('http://www.gameone.de/tv/%d' %
  113. video_id, 'GameOne')
  114. for video_id in range(max_id, 0, -1)]
  115. return {
  116. '_type': 'playlist',
  117. 'title': 'GameOne',
  118. 'entries': entries,
  119. }