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.

49 lines
1.9 KiB

  1. from __future__ import unicode_literals
  2. import json
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. unescapeHTML,
  7. )
  8. class CSpanIE(InfoExtractor):
  9. _VALID_URL = r'http://(?:www\.)?c-spanvideo\.org/program/(?P<name>.*)'
  10. IE_DESC = 'C-SPAN'
  11. _TEST = {
  12. 'url': 'http://www.c-spanvideo.org/program/HolderonV',
  13. 'file': '315139.mp4',
  14. 'md5': '8e44ce11f0f725527daccc453f553eb0',
  15. 'info_dict': {
  16. 'title': 'Attorney General Eric Holder on Voting Rights Act Decision',
  17. 'description': 'Attorney General Eric Holder spoke to reporters following the Supreme Court decision in [Shelby County v. Holder] in which the court ruled that the preclearance provisions of the Voting Rights Act could not be enforced until Congress established new guidelines for review.',
  18. },
  19. 'skip': 'Regularly fails on travis, for unknown reasons',
  20. }
  21. def _real_extract(self, url):
  22. mobj = re.match(self._VALID_URL, url)
  23. prog_name = mobj.group('name')
  24. webpage = self._download_webpage(url, prog_name)
  25. video_id = self._search_regex(r'prog(?:ram)?id=(.*?)&', webpage, 'video id')
  26. title = self._html_search_regex(
  27. r'<!-- title -->\n\s*<h1[^>]*>(.*?)</h1>', webpage, 'title')
  28. description = self._og_search_description(webpage)
  29. info_url = 'http://c-spanvideo.org/videoLibrary/assets/player/ajax-player.php?os=android&html5=program&id=' + video_id
  30. data_json = self._download_webpage(
  31. info_url, video_id, 'Downloading video info')
  32. data = json.loads(data_json)
  33. url = unescapeHTML(data['video']['files'][0]['path']['#text'])
  34. return {
  35. 'id': video_id,
  36. 'title': title,
  37. 'url': url,
  38. 'description': description,
  39. 'thumbnail': self._og_search_thumbnail(webpage),
  40. }