plays.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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/(?P<id>[0-9a-f]{18})'
  8. _TEST = {
  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. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. content = self._search_json_ld(webpage, video_id)
  22. title = content['title']
  23. mpd_url, sources = re.search(
  24. r'(?s)<video[^>]+data-mpd="([^"]+)"[^>]*>(.+?)</video>',
  25. webpage).groups()
  26. formats = self._extract_mpd_formats(
  27. self._proto_relative_url(mpd_url), video_id, mpd_id='DASH')
  28. for format_id, height, format_url in re.findall(r'<source\s+res="((\d+)h?)"\s+src="([^"]+)"', sources):
  29. formats.append({
  30. 'url': self._proto_relative_url(format_url),
  31. 'format_id': 'http-' + format_id,
  32. 'height': int_or_none(height),
  33. })
  34. self._sort_formats(formats)
  35. return {
  36. 'id': video_id,
  37. 'title': title,
  38. 'description': self._og_search_description(webpage),
  39. 'thumbnail': self._og_search_thumbnail(webpage),
  40. 'formats': formats,
  41. }