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.

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