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.

55 lines
1.7 KiB

11 years ago
11 years ago
  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from .youtube import YoutubeIE
  5. class WimpIE(InfoExtractor):
  6. _VALID_URL = r'http://(?:www\.)?wimp\.com/([^/]+)/'
  7. _TESTS = [{
  8. 'url': 'http://www.wimp.com/maruexhausted/',
  9. 'md5': 'f1acced123ecb28d9bb79f2479f2b6a1',
  10. 'info_dict': {
  11. 'id': 'maruexhausted',
  12. 'ext': 'flv',
  13. 'title': 'Maru is exhausted.',
  14. 'description': 'md5:57e099e857c0a4ea312542b684a869b8',
  15. }
  16. }, {
  17. # youtube video
  18. 'url': 'http://www.wimp.com/clowncar/',
  19. 'info_dict': {
  20. 'id': 'cG4CEr2aiSg',
  21. 'ext': 'mp4',
  22. 'title': 'Basset hound clown car...incredible!',
  23. 'description': 'md5:8d228485e0719898c017203f900b3a35',
  24. 'uploader': 'Gretchen Hoey',
  25. 'uploader_id': 'gretchenandjeff1',
  26. 'upload_date': '20140303',
  27. },
  28. 'add_ie': ['Youtube'],
  29. }]
  30. def _real_extract(self, url):
  31. mobj = re.match(self._VALID_URL, url)
  32. video_id = mobj.group(1)
  33. webpage = self._download_webpage(url, video_id)
  34. video_url = self._search_regex(
  35. r"'file'\s*:\s*'([^']+)'", webpage, 'video URL')
  36. if YoutubeIE.suitable(video_url):
  37. self.to_screen('Found YouTube video')
  38. return {
  39. '_type': 'url',
  40. 'url': video_url,
  41. 'ie_key': YoutubeIE.ie_key(),
  42. }
  43. return {
  44. 'id': video_id,
  45. 'url': video_url,
  46. 'title': self._og_search_title(webpage),
  47. 'thumbnail': self._og_search_thumbnail(webpage),
  48. 'description': self._og_search_description(webpage),
  49. }