volejtv.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from .common import InfoExtractor
  2. class VolejTVIE(InfoExtractor):
  3. _VALID_URL = r'https?://volej\.tv/video/(?P<id>\d+)'
  4. _TESTS = [{
  5. 'url': 'https://volej.tv/video/725742/',
  6. 'info_dict': {
  7. 'id': '725742',
  8. 'ext': 'mp4',
  9. 'description': 'Zápas VK Královo Pole vs VK Prostějov 10.12.2022 v 19:00 na Volej.TV',
  10. 'thumbnail': 'https://volej.tv/images/og/16/17186/og.png',
  11. 'title': 'VK Královo Pole vs VK Prostějov',
  12. },
  13. }, {
  14. 'url': 'https://volej.tv/video/725605/',
  15. 'info_dict': {
  16. 'id': '725605',
  17. 'ext': 'mp4',
  18. 'thumbnail': 'https://volej.tv/images/og/15/17185/og.png',
  19. 'title': 'VK Lvi Praha vs VK Euro Sitex Příbram',
  20. 'description': 'Zápas VK Lvi Praha vs VK Euro Sitex Příbram 11.12.2022 v 19:00 na Volej.TV',
  21. },
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. json_data = self._search_json(
  27. r'<\s*!\[CDATA[^=]+=', webpage, 'CDATA', video_id)
  28. formats, subtitle = self._extract_m3u8_formats_and_subtitles(
  29. json_data['urls']['hls'], video_id)
  30. return {
  31. 'id': video_id,
  32. 'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
  33. 'thumbnail': self._html_search_meta(['og:image', 'twitter:image'], webpage),
  34. 'description': self._html_search_meta(['description', 'og:description', 'twitter:description'], webpage),
  35. 'formats': formats,
  36. 'subtitles': subtitle,
  37. }