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.

57 lines
2.0 KiB

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