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.

70 lines
2.6 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. parse_duration,
  7. str_to_int,
  8. unified_strdate,
  9. )
  10. class GameStarIE(InfoExtractor):
  11. _VALID_URL = r'http://www\.gamestar\.de/videos/.*,(?P<id>[0-9]+)\.html'
  12. _TEST = {
  13. 'url': 'http://www.gamestar.de/videos/trailer,3/hobbit-3-die-schlacht-der-fuenf-heere,76110.html',
  14. 'md5': '96974ecbb7fd8d0d20fca5a00810cea7',
  15. 'info_dict': {
  16. 'id': '76110',
  17. 'ext': 'mp4',
  18. 'title': 'Hobbit 3: Die Schlacht der Fünf Heere - Teaser-Trailer zum dritten Teil',
  19. '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 vollständigen Trailer an.',
  20. 'thumbnail': 'http://images.gamestar.de/images/idgwpgsgp/bdb/2494525/600x.jpg',
  21. 'upload_date': '20140728',
  22. 'duration': 17
  23. }
  24. }
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. og_title = self._og_search_title(webpage)
  29. title = og_title.replace(' - Video bei GameStar.de', '').strip()
  30. url = 'http://gamestar.de/_misc/videos/portal/getVideoUrl.cfm?premium=0&videoId=' + video_id
  31. description = self._og_search_description(webpage).strip()
  32. thumbnail = self._proto_relative_url(
  33. self._og_search_thumbnail(webpage), scheme='http:')
  34. upload_date = unified_strdate(self._html_search_regex(
  35. r'<span style="float:left;font-size:11px;">Datum: ([0-9]+\.[0-9]+\.[0-9]+)&nbsp;&nbsp;',
  36. webpage, 'upload_date', fatal=False))
  37. duration = parse_duration(self._html_search_regex(
  38. r'&nbsp;&nbsp;Länge: ([0-9]+:[0-9]+)</span>', webpage, 'duration',
  39. fatal=False))
  40. view_count = str_to_int(self._html_search_regex(
  41. r'&nbsp;&nbsp;Zuschauer: ([0-9\.]+)&nbsp;&nbsp;', webpage,
  42. 'view_count', fatal=False))
  43. comment_count = int_or_none(self._html_search_regex(
  44. r'>Kommentieren \(([0-9]+)\)</a>', webpage, 'comment_count',
  45. fatal=False))
  46. return {
  47. 'id': video_id,
  48. 'title': title,
  49. 'url': url,
  50. 'ext': 'mp4',
  51. 'thumbnail': thumbnail,
  52. 'description': description,
  53. 'upload_date': upload_date,
  54. 'duration': duration,
  55. 'view_count': view_count,
  56. 'comment_count': comment_count
  57. }