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.1 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. js_to_json,
  6. parse_duration,
  7. remove_start,
  8. )
  9. class GamersydeIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?gamersyde\.com/hqstream_(?P<display_id>[\da-z_]+)-(?P<id>\d+)_[a-z]{2}\.html'
  11. _TEST = {
  12. 'url': 'http://www.gamersyde.com/hqstream_bloodborne_birth_of_a_hero-34371_en.html',
  13. 'md5': 'f38d400d32f19724570040d5ce3a505f',
  14. 'info_dict': {
  15. 'id': '34371',
  16. 'ext': 'mp4',
  17. 'duration': 372,
  18. 'title': 'Bloodborne - Birth of a hero',
  19. 'thumbnail': 're:^https?://.*\.jpg$',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. display_id = mobj.group('display_id')
  26. webpage = self._download_webpage(url, display_id)
  27. playlist = self._parse_json(
  28. self._search_regex(
  29. r'(?s)playlist: \[({.+?})\]\s*}\);', webpage, 'files'),
  30. display_id, transform_source=js_to_json)
  31. formats = []
  32. for source in playlist['sources']:
  33. video_url = source.get('file')
  34. if not video_url:
  35. continue
  36. format_id = source.get('label')
  37. f = {
  38. 'url': video_url,
  39. 'format_id': format_id,
  40. }
  41. m = re.search(r'^(?P<height>\d+)[pP](?P<fps>\d+)fps', format_id)
  42. if m:
  43. f.update({
  44. 'height': int(m.group('height')),
  45. 'fps': int(m.group('fps')),
  46. })
  47. formats.append(f)
  48. self._sort_formats(formats)
  49. title = remove_start(playlist['title'], '%s - ' % video_id)
  50. thumbnail = playlist.get('image')
  51. duration = parse_duration(self._search_regex(
  52. r'Length:</label>([^<]+)<', webpage, 'duration', fatal=False))
  53. return {
  54. 'id': video_id,
  55. 'display_id': display_id,
  56. 'title': title,
  57. 'thumbnail': thumbnail,
  58. 'duration': duration,
  59. 'formats': formats,
  60. }