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.

48 lines
1.8 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/(.*)'
  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. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. prog_name = mobj.group(1)
  23. webpage = self._download_webpage(url, prog_name)
  24. video_id = self._search_regex(r'programid=(.*?)&', webpage, 'video id')
  25. title = self._html_search_regex(
  26. r'<!-- title -->\n\s*<h1[^>]*>(.*?)</h1>', webpage, 'title')
  27. description = self._og_search_description(webpage)
  28. info_url = 'http://c-spanvideo.org/videoLibrary/assets/player/ajax-player.php?os=android&html5=program&id=' + video_id
  29. data_json = self._download_webpage(
  30. info_url, video_id, 'Downloading video info')
  31. data = json.loads(data_json)
  32. url = unescapeHTML(data['video']['files'][0]['path']['#text'])
  33. return {
  34. 'id': video_id,
  35. 'title': title,
  36. 'url': url,
  37. 'description': description,
  38. 'thumbnail': self._og_search_thumbnail(webpage),
  39. }