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.

59 lines
2.0 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. _TESTS = [{
  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. 'url': 'http://www.goldenmoustache.com/le-lab-tout-effacer-mc-fly-et-carlito-55249/',
  23. 'md5': '27f0c50fb4dd5f01dc9082fc67cd5700',
  24. 'info_dict': {
  25. 'id': '55249',
  26. 'ext': 'mp4',
  27. 'title': 'Le LAB - Tout Effacer (Mc Fly et Carlito)',
  28. 'description': 'md5:9b7fbf11023fb2250bd4b185e3de3b2a',
  29. 'thumbnail': 're:^https?://.*\.(?:png|jpg)$',
  30. 'view_count': int,
  31. }
  32. }]
  33. def _real_extract(self, url):
  34. video_id = self._match_id(url)
  35. webpage = self._download_webpage(url, video_id)
  36. video_url = self._html_search_regex(
  37. r'data-src-type="mp4" data-src="([^"]+)"', webpage, 'video URL')
  38. title = self._html_search_regex(
  39. r'<title>(.*?)(?: - Golden Moustache)?</title>', webpage, 'title')
  40. thumbnail = self._og_search_thumbnail(webpage)
  41. description = self._og_search_description(webpage)
  42. view_count = int_or_none(self._html_search_regex(
  43. r'<strong>([0-9]+)</strong>\s*VUES</span>',
  44. webpage, 'view count', fatal=False))
  45. return {
  46. 'id': video_id,
  47. 'url': video_url,
  48. 'ext': 'mp4',
  49. 'title': title,
  50. 'description': description,
  51. 'thumbnail': thumbnail,
  52. 'view_count': view_count,
  53. }