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.

48 lines
1.6 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. parse_duration,
  6. int_or_none,
  7. )
  8. class GoldenMoustacheIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?goldenmoustache\.com/(?P<display_id>[\w-]+)-(?P<id>\d+)'
  10. _TEST = {
  11. 'url': 'http://www.goldenmoustache.com/suricate-le-poker-3700/',
  12. 'md5': '0f904432fa07da5054d6c8beb5efb51a',
  13. 'info_dict': {
  14. 'id': '3700',
  15. 'ext': 'mp4',
  16. 'title': 'Suricate - Le Poker',
  17. 'description': 'md5:3d1f242f44f8c8cb0a106f1fd08e5dc9',
  18. 'thumbnail': 're:^https?://.*\.jpg$',
  19. 'view_count': int,
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. video_url = self._html_search_regex(
  26. r'data-src-type="mp4" data-src="([^"]+)"', webpage, 'video URL')
  27. title = self._html_search_regex(
  28. r'<title>(.*?) - Golden Moustache</title>', webpage, 'title')
  29. thumbnail = self._og_search_thumbnail(webpage)
  30. description = self._og_search_description(webpage)
  31. view_count = int_or_none(self._html_search_regex(
  32. r'<strong>([0-9]+)</strong>\s*VUES</span>',
  33. webpage, 'view count', fatal=False))
  34. return {
  35. 'id': video_id,
  36. 'url': video_url,
  37. 'ext': 'mp4',
  38. 'title': title,
  39. 'description': description,
  40. 'thumbnail': thumbnail,
  41. 'view_count': view_count,
  42. }