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.

80 lines
2.9 KiB

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