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.

49 lines
1.6 KiB

11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from .youtube import YoutubeIE
  4. class WimpIE(InfoExtractor):
  5. _VALID_URL = r'http://(?:www\.)?wimp\.com/(?P<id>[^/]+)/'
  6. _TESTS = [{
  7. 'url': 'http://www.wimp.com/maruexhausted/',
  8. 'md5': 'ee21217ffd66d058e8b16be340b74883',
  9. 'info_dict': {
  10. 'id': 'maruexhausted',
  11. 'ext': 'mp4',
  12. 'title': 'Maru is exhausted.',
  13. 'description': 'md5:57e099e857c0a4ea312542b684a869b8',
  14. }
  15. }, {
  16. 'url': 'http://www.wimp.com/clowncar/',
  17. 'md5': '4e2986c793694b55b37cf92521d12bb4',
  18. 'info_dict': {
  19. 'id': 'clowncar',
  20. 'ext': 'mp4',
  21. 'title': 'It\'s like a clown car.',
  22. 'description': 'md5:0e56db1370a6e49c5c1d19124c0d2fb2',
  23. },
  24. }]
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. webpage = self._download_webpage(url, video_id)
  28. video_url = self._search_regex(
  29. [r"[\"']file[\"']\s*[:,]\s*[\"'](.+?)[\"']", r"videoId\s*:\s*[\"']([^\"']+)[\"']"],
  30. webpage, 'video URL')
  31. if YoutubeIE.suitable(video_url):
  32. self.to_screen('Found YouTube video')
  33. return {
  34. '_type': 'url',
  35. 'url': video_url,
  36. 'ie_key': YoutubeIE.ie_key(),
  37. }
  38. return {
  39. 'id': video_id,
  40. 'url': video_url,
  41. 'title': self._og_search_title(webpage),
  42. 'thumbnail': self._og_search_thumbnail(webpage),
  43. 'description': self._og_search_description(webpage),
  44. }