logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

tvnoe.py (1612B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. clean_html,
  6. get_element_by_class,
  7. js_to_json,
  8. )
  9. class TVNoeIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?tvnoe\.cz/video/(?P<id>[0-9]+)'
  11. _TEST = {
  12. 'url': 'http://www.tvnoe.cz/video/10362',
  13. 'md5': 'aee983f279aab96ec45ab6e2abb3c2ca',
  14. 'info_dict': {
  15. 'id': '10362',
  16. 'ext': 'mp4',
  17. 'series': 'Noční univerzita',
  18. 'title': 'prof. Tomáš Halík, Th.D. - Návrat náboženství a střet civilizací',
  19. 'description': 'md5:f337bae384e1a531a52c55ebc50fff41',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. iframe_url = self._search_regex(
  26. r'<iframe[^>]+src="([^"]+)"', webpage, 'iframe URL')
  27. ifs_page = self._download_webpage(iframe_url, video_id)
  28. jwplayer_data = self._find_jwplayer_data(
  29. ifs_page, video_id, transform_source=js_to_json)
  30. info_dict = self._parse_jwplayer_data(
  31. jwplayer_data, video_id, require_title=False, base_url=iframe_url)
  32. info_dict.update({
  33. 'id': video_id,
  34. 'title': clean_html(get_element_by_class(
  35. 'field-name-field-podnazev', webpage)),
  36. 'description': clean_html(get_element_by_class(
  37. 'field-name-body', webpage)),
  38. 'series': clean_html(get_element_by_class('title', webpage))
  39. })
  40. return info_dict