pear.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class PearIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?pearvideo\.com/video_(?P<id>[0-9]+)'
  6. _TEST = {
  7. 'url': 'http://www.pearvideo.com/video_1076290',
  8. 'info_dict': {
  9. 'id': '1076290',
  10. 'ext': 'mp4',
  11. 'title': '小浣熊在主人家玻璃上滚石头:没砸',
  12. 'description': '小浣熊找到一个小石头,仿佛发现了一个宝贝。它不停地用石头按在玻璃上,滚来滚去,吸引主人注意。',
  13. 'url': 'http://video.pearvideo.com/mp4/short/20170508/cont-1076290-10438018-hd.mp4'
  14. }
  15. }
  16. def _real_extract(self, url):
  17. video_id = self._match_id(url)
  18. webpage = self._download_webpage(url, video_id)
  19. title = self._html_search_regex(r'<h1[^>]+class="video-tt">(.+)</h1>', webpage, 'title', fatal=False)
  20. description = self._html_search_regex(r'<div[^>]+class="summary"[^>]*>([^<]+)<', webpage, 'description', fatal=False)
  21. url = self._html_search_regex(r'hdUrl="(.*?)"', webpage, 'url', fatal=False)
  22. return {
  23. 'id': video_id,
  24. 'ext': 'mp4',
  25. 'title': title,
  26. 'description': description,
  27. 'url': url
  28. }