normalboots.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. ExtractorError,
  5. unified_strdate,
  6. )
  7. class NormalbootsIE(InfoExtractor):
  8. _VALID_URL = r'(?:http://)?(?:www\.)?normalboots\.com/video/(?P<videoid>[0-9a-z-]*)/?$'
  9. def _real_extract(self, url):
  10. mobj = re.match(self._VALID_URL, url)
  11. if mobj is None:
  12. raise ExtractorError(u'Invalid URL: %s' % url)
  13. video_id = mobj.group('videoid')
  14. info = {
  15. 'id': video_id,
  16. 'uploader': None,
  17. 'upload_date': None,
  18. }
  19. if url[:4] != 'http':
  20. url = 'http://' + url
  21. webpage = self._download_webpage(url, video_id)
  22. video_title = self._og_search_title(webpage)
  23. video_description = self._og_search_description(webpage)
  24. video_thumbnail = self._og_search_thumbnail(webpage)
  25. video_uploader = self._html_search_regex(r'Posted\sby\s<a\shref="[A-Za-z0-9/]*">(?P<uploader>[A-Za-z]*)\s</a>',
  26. webpage, 'uploader')
  27. raw_upload_date = self._html_search_regex('<span style="text-transform:uppercase; font-size:inherit;">[A-Za-z]+, (?P<date>.*)</span>',
  28. webpage, 'date')
  29. video_upload_date = unified_strdate(raw_upload_date)
  30. video_upload_date = unified_strdate(raw_upload_date)
  31. player_url = self._html_search_regex(r'<iframe\swidth="[0-9]+"\sheight="[0-9]+"\ssrc="(?P<url>[\S]+)"', webpage, 'url')
  32. player_page = self._download_webpage(player_url, video_id)
  33. video_url = u'http://player.screenwavemedia.com/' + self._html_search_regex(r"'file':\s'(?P<file>[0-9A-Za-z-_\.]+)'", player_page, 'file')
  34. info['url'] = video_url
  35. info['title'] = video_title
  36. info['description'] = video_description
  37. info['thumbnail'] = video_thumbnail
  38. info['uploader'] = video_uploader
  39. info['upload_date'] = video_upload_date
  40. return info