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.

54 lines
1.7 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. youtube_id = self._search_regex(
  29. r"videoId\s*:\s*[\"']([0-9A-Za-z_-]{11})[\"']",
  30. webpage, 'video URL', default=None)
  31. if youtube_id:
  32. return {
  33. '_type': 'url',
  34. 'url': youtube_id,
  35. 'ie_key': YoutubeIE.ie_key(),
  36. }
  37. video_url = self._search_regex(
  38. r'<video[^>]+>\s*<source[^>]+src=(["\'])(?P<url>.+?)\1',
  39. webpage, 'video URL', group='url')
  40. return {
  41. 'id': video_id,
  42. 'url': video_url,
  43. 'title': self._og_search_title(webpage),
  44. 'thumbnail': self._og_search_thumbnail(webpage),
  45. 'description': self._og_search_description(webpage),
  46. }