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.

53 lines
1.8 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import int_or_none
  6. class PlaysTVIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?plays\.tv/(?:video|embeds)/(?P<id>[0-9a-f]{18})'
  8. _TESTS = [{
  9. 'url': 'https://plays.tv/video/56af17f56c95335490/when-you-outplay-the-azir-wall',
  10. 'md5': 'dfeac1198506652b5257a62762cec7bc',
  11. 'info_dict': {
  12. 'id': '56af17f56c95335490',
  13. 'ext': 'mp4',
  14. 'title': 'Bjergsen - When you outplay the Azir wall',
  15. 'description': 'Posted by Bjergsen',
  16. }
  17. }, {
  18. 'url': 'https://plays.tv/embeds/56af17f56c95335490',
  19. 'only_matching': True,
  20. }]
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. webpage = self._download_webpage(
  24. 'https://plays.tv/video/%s' % video_id, video_id)
  25. info = self._search_json_ld(webpage, video_id,)
  26. mpd_url, sources = re.search(
  27. r'(?s)<video[^>]+data-mpd="([^"]+)"[^>]*>(.+?)</video>',
  28. webpage).groups()
  29. formats = self._extract_mpd_formats(
  30. self._proto_relative_url(mpd_url), video_id, mpd_id='DASH')
  31. for format_id, height, format_url in re.findall(r'<source\s+res="((\d+)h?)"\s+src="([^"]+)"', sources):
  32. formats.append({
  33. 'url': self._proto_relative_url(format_url),
  34. 'format_id': 'http-' + format_id,
  35. 'height': int_or_none(height),
  36. })
  37. self._sort_formats(formats)
  38. info.update({
  39. 'id': video_id,
  40. 'description': self._og_search_description(webpage),
  41. 'thumbnail': info.get('thumbnail') or self._og_search_thumbnail(webpage),
  42. 'formats': formats,
  43. })
  44. return info