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.7 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,
  33. note='Downloading video configuration')
  34. formats = []
  35. for fcfg in config['sources']:
  36. if fcfg['type'] == 'm3u8':
  37. formats.extend(self._extract_m3u8_formats(fcfg['file'], video_id))
  38. else:
  39. formats.append({
  40. 'url': fcfg['file'],
  41. 'height': int_or_none(fcfg.get('height')),
  42. 'format_id': fcfg.get('label'),
  43. 'ext': self._search_regex(
  44. r'filename=.*\.([a-z0-9_A-Z]+)&', fcfg['file'],
  45. 'file extension', default=None),
  46. })
  47. self._sort_formats(formats)
  48. title = self._og_search_title(webpage)
  49. description = self._og_search_description(webpage)
  50. thumbnail = config.get('image')
  51. view_count = int_or_none(self._search_regex(
  52. r'<h5>Plays: ([0-9]+)</h5>', webpage, 'view counts'))
  53. uploader = self._search_regex(
  54. r'<div class="reviewer">\s*<img alt="([^"]+)"', webpage, 'uploader',
  55. fatal=False)
  56. upload_date = unified_strdate(self._search_regex(
  57. r'<h5>Reviewed on ([0-9/.]+)</h5>', webpage, 'upload date',
  58. fatal=False))
  59. return {
  60. 'id': video_id,
  61. 'formats': formats,
  62. 'title': title,
  63. 'description': description,
  64. 'view_count': view_count,
  65. 'thumbnail': thumbnail,
  66. 'uploader': uploader,
  67. 'upload_date': upload_date,
  68. }