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.

77 lines
2.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. int_or_none,
  5. unified_strdate,
  6. )
  7. class ExpoTVIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.)?expotv\.com/videos/[^?#]*/(?P<id>[0-9]+)($|[?#])'
  9. _TEST = {
  10. 'url': 'http://www.expotv.com/videos/reviews/3/40/NYX-Butter-lipstick/667916',
  11. 'md5': 'fe1d728c3a813ff78f595bc8b7a707a8',
  12. 'info_dict': {
  13. 'id': '667916',
  14. 'ext': 'mp4',
  15. 'title': 'NYX Butter Lipstick Little Susie',
  16. 'description': 'Goes on like butter, but looks better!',
  17. 'thumbnail': r're:^https?://.*\.jpg$',
  18. 'uploader': 'Stephanie S.',
  19. 'upload_date': '20150520',
  20. 'view_count': int,
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. player_key = self._search_regex(
  27. r'<param name="playerKey" value="([^"]+)"', webpage, 'player key')
  28. config = self._download_json(
  29. 'http://client.expotv.com/video/config/%s/%s' % (video_id, player_key),
  30. video_id, 'Downloading video configuration')
  31. formats = []
  32. for fcfg in config['sources']:
  33. media_url = fcfg.get('file')
  34. if not media_url:
  35. continue
  36. if fcfg.get('type') == 'm3u8':
  37. formats.extend(self._extract_m3u8_formats(
  38. media_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls'))
  39. else:
  40. formats.append({
  41. 'url': media_url,
  42. 'height': int_or_none(fcfg.get('height')),
  43. 'format_id': fcfg.get('label'),
  44. 'ext': self._search_regex(
  45. r'filename=.*\.([a-z0-9_A-Z]+)&', media_url,
  46. 'file extension', default=None) or fcfg.get('type'),
  47. })
  48. self._sort_formats(formats)
  49. title = self._og_search_title(webpage)
  50. description = self._og_search_description(webpage)
  51. thumbnail = config.get('image')
  52. view_count = int_or_none(self._search_regex(
  53. r'<h5>Plays: ([0-9]+)</h5>', webpage, 'view counts'))
  54. uploader = self._search_regex(
  55. r'<div class="reviewer">\s*<img alt="([^"]+)"', webpage, 'uploader',
  56. fatal=False)
  57. upload_date = unified_strdate(self._search_regex(
  58. r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date',
  59. fatal=False), day_first=False)
  60. return {
  61. 'id': video_id,
  62. 'formats': formats,
  63. 'title': title,
  64. 'description': description,
  65. 'view_count': view_count,
  66. 'thumbnail': thumbnail,
  67. 'uploader': uploader,
  68. 'upload_date': upload_date,
  69. }