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.

36 lines
1.3 KiB

  1. import re
  2. import base64
  3. from .common import InfoExtractor
  4. class WimpIE(InfoExtractor):
  5. _VALID_URL = r'(?:http://)?(?:www\.)?wimp\.com/([^/]+)/'
  6. _TEST = {
  7. u'url': u'http://www.wimp.com/deerfence/',
  8. u'file': u'deerfence.flv',
  9. u'md5': u'8b215e2e0168c6081a1cf84b2846a2b5',
  10. u'info_dict': {
  11. u"title": u"Watch Till End: Herd of deer jump over a fence."
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group(1)
  17. webpage = self._download_webpage(url, video_id)
  18. title = self._search_regex(r'<meta name="description" content="(.+?)" />',webpage, 'video title')
  19. thumbnail_url = self._search_regex(r'<meta property="og\:image" content="(.+?)" />', webpage,'video thumbnail')
  20. googleString = self._search_regex("googleCode = '(.*?)'", webpage, 'file url')
  21. googleString = base64.b64decode(googleString).decode('ascii')
  22. final_url = self._search_regex('","(.*?)"', googleString,'final video url')
  23. ext = final_url.rpartition(u'.')[2]
  24. return [{
  25. 'id': video_id,
  26. 'url': final_url,
  27. 'ext': ext,
  28. 'title': title,
  29. 'thumbnail': thumbnail_url,
  30. }]