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.

61 lines
2.7 KiB

  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. _TEST = {
  10. u'url': u'http://normalboots.com/video/home-alone-games-jontron/',
  11. u'file': u'home-alone-games-jontron.mp4',
  12. u'md5': u'8bf6de238915dd501105b44ef5f1e0f6',
  13. u'info_dict': {
  14. u'title': u'Home Alone Games - JonTron - NormalBoots',
  15. u'description': u'Jon is late for Christmas. Typical. Thanks to: Paul Ritchey for Co-Writing/Filming: http://www.youtube.com/user/ContinueShow Michael Azzi for Christmas Intro Animation: http://michafrar.tumblr.com/ Jerrod Waters for Christmas Intro Music: http://www.youtube.com/user/xXJerryTerryXx Casey Ormond for \u2018Tense Battle Theme\u2019:\xa0http://www.youtube.com/Kiamet/',
  16. u'uploader': u'JonTron',
  17. u'upload_date': u'20140125',
  18. }
  19. }
  20. def _real_extract(self, url):
  21. mobj = re.match(self._VALID_URL, url)
  22. if mobj is None:
  23. raise ExtractorError(u'Invalid URL: %s' % url)
  24. video_id = mobj.group('videoid')
  25. info = {
  26. 'id': video_id,
  27. 'uploader': None,
  28. 'upload_date': None,
  29. }
  30. if url[:4] != 'http':
  31. url = 'http://' + url
  32. webpage = self._download_webpage(url, video_id)
  33. video_title = self._og_search_title(webpage)
  34. video_description = self._og_search_description(webpage)
  35. video_thumbnail = self._og_search_thumbnail(webpage)
  36. video_uploader = self._html_search_regex(r'Posted\sby\s<a\shref="[A-Za-z0-9/]*">(?P<uploader>[A-Za-z]*)\s</a>',
  37. webpage, 'uploader')
  38. raw_upload_date = self._html_search_regex('<span style="text-transform:uppercase; font-size:inherit;">[A-Za-z]+, (?P<date>.*)</span>',
  39. webpage, 'date')
  40. video_upload_date = unified_strdate(raw_upload_date)
  41. video_upload_date = unified_strdate(raw_upload_date)
  42. player_url = self._html_search_regex(r'<iframe\swidth="[0-9]+"\sheight="[0-9]+"\ssrc="(?P<url>[\S]+)"', webpage, 'url')
  43. player_page = self._download_webpage(player_url, video_id)
  44. video_url = u'http://player.screenwavemedia.com/' + self._html_search_regex(r"'file':\s'(?P<file>[0-9A-Za-z-_\.]+)'", player_page, 'file')
  45. info['url'] = video_url
  46. info['title'] = video_title
  47. info['description'] = video_description
  48. info['thumbnail'] = video_thumbnail
  49. info['uploader'] = video_uploader
  50. info['upload_date'] = video_upload_date
  51. return info