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.

90 lines
3.0 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. )
  9. NAMESPACE_MAP = {
  10. 'media': 'http://search.yahoo.com/mrss/',
  11. }
  12. # URL prefix to download the mp4 files directly instead of streaming via rtmp
  13. # Credits go to XBox-Maniac
  14. # http://board.jdownloader.org/showpost.php?p=185835&postcount=31
  15. RAW_MP4_URL = 'http://cdn.riptide-mtvn.com/'
  16. class GameOneIE(InfoExtractor):
  17. _VALID_URL = r'https?://(?:www\.)?gameone\.de/tv/(?P<id>\d+)'
  18. _TEST = {
  19. 'url': 'http://www.gameone.de/tv/288',
  20. 'md5': '136656b7fb4c9cb4a8e2d500651c499b',
  21. 'info_dict': {
  22. 'id': '288',
  23. 'ext': 'mp4',
  24. 'title': 'Game One - Folge 288',
  25. 'duration': 1238,
  26. 'thumbnail': 'http://s3.gameone.de/gameone/assets/video_metas/teaser_images/000/643/636/big/640x360.jpg',
  27. 'description': 'FIFA-Pressepokal 2014, Star Citizen, Kingdom Come: Deliverance, Project Cars, Schöner Trants Nerdquiz Folge 2 Runde 1',
  28. 'age_limit': 16,
  29. 'upload_date': '20140513',
  30. 'timestamp': 1399980122,
  31. }
  32. }
  33. def _real_extract(self, url):
  34. mobj = re.match(self._VALID_URL, url)
  35. video_id = mobj.group('id')
  36. webpage = self._download_webpage(url, video_id)
  37. og_video = self._og_search_video_url(webpage, secure=False)
  38. description = self._html_search_meta('description', webpage)
  39. age_limit = int(
  40. self._search_regex(
  41. r'age=(\d+)',
  42. self._html_search_meta(
  43. 'age-de-meta-label',
  44. webpage),
  45. 'age_limit',
  46. '0'))
  47. mrss_url = self._search_regex(r'mrss=([^&]+)', og_video, 'mrss')
  48. mrss = self._download_xml(mrss_url, video_id, 'Downloading mrss')
  49. title = mrss.find('.//item/title').text
  50. thumbnail = mrss.find('.//item/image').get('url')
  51. timestamp = parse_iso8601(mrss.find('.//pubDate').text, delimiter=' ')
  52. content = mrss.find(xpath_with_ns('.//media:content', NAMESPACE_MAP))
  53. content_url = content.get('url')
  54. content = self._download_xml(
  55. content_url,
  56. video_id,
  57. 'Downloading media:content')
  58. rendition_items = content.findall('.//rendition')
  59. duration = int(rendition_items[0].get('duration'))
  60. formats = [
  61. {
  62. 'url': re.sub(r'.*/(r2)', RAW_MP4_URL + r'\1', r.find('./src').text),
  63. 'width': int(r.get('width')),
  64. 'height': int(r.get('height')),
  65. 'tbr': int(r.get('bitrate')),
  66. }
  67. for r in rendition_items
  68. ]
  69. self._sort_formats(formats)
  70. return {
  71. 'id': video_id,
  72. 'title': title,
  73. 'thumbnail': thumbnail,
  74. 'duration': duration,
  75. 'formats': formats,
  76. 'description': description,
  77. 'age_limit': age_limit,
  78. 'timestamp': timestamp,
  79. }