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.

55 lines
2.0 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. remove_end,
  7. )
  8. class GameStarIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?gamestar\.de/videos/.*,(?P<id>[0-9]+)\.html'
  10. _TEST = {
  11. 'url': 'http://www.gamestar.de/videos/trailer,3/hobbit-3-die-schlacht-der-fuenf-heere,76110.html',
  12. 'md5': '96974ecbb7fd8d0d20fca5a00810cea7',
  13. 'info_dict': {
  14. 'id': '76110',
  15. 'ext': 'mp4',
  16. 'title': 'Hobbit 3: Die Schlacht der Fünf Heere - Teaser-Trailer zum dritten Teil',
  17. 'description': 'Der Teaser-Trailer zu Hobbit 3: Die Schlacht der Fünf Heere zeigt einige Szenen aus dem dritten Teil der Saga und kündigt den...',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. 'timestamp': 1406542020,
  20. 'upload_date': '20140728',
  21. 'duration': 17
  22. }
  23. }
  24. def _real_extract(self, url):
  25. video_id = self._match_id(url)
  26. webpage = self._download_webpage(url, video_id)
  27. url = 'http://gamestar.de/_misc/videos/portal/getVideoUrl.cfm?premium=0&videoId=' + video_id
  28. # TODO: there are multiple ld+json objects in the webpage,
  29. # while _search_json_ld finds only the first one
  30. json_ld = self._parse_json(self._search_regex(
  31. r'(?s)<script[^>]+type=(["\'])application/ld\+json\1[^>]*>(?P<json_ld>[^<]+VideoObject[^<]+)</script>',
  32. webpage, 'JSON-LD', group='json_ld'), video_id)
  33. info_dict = self._json_ld(json_ld, video_id)
  34. info_dict['title'] = remove_end(info_dict['title'], ' - GameStar')
  35. view_count = json_ld.get('interactionCount')
  36. comment_count = int_or_none(self._html_search_regex(
  37. r'([0-9]+) Kommentare</span>', webpage, 'comment_count',
  38. fatal=False))
  39. info_dict.update({
  40. 'id': video_id,
  41. 'url': url,
  42. 'ext': 'mp4',
  43. 'view_count': view_count,
  44. 'comment_count': comment_count
  45. })
  46. return info_dict