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.

79 lines
2.4 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. import json
  5. from .common import InfoExtractor
  6. from ..utils import (
  7. ExtractorError,
  8. parse_iso8601,
  9. )
  10. class EllenTVIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?ellentv\.com/videos/(?P<id>[a-z0-9_-]+)'
  12. _TEST = {
  13. 'url': 'http://www.ellentv.com/videos/0-7jqrsr18/',
  14. 'md5': 'e4af06f3bf0d5f471921a18db5764642',
  15. 'info_dict': {
  16. 'id': '0-7jqrsr18',
  17. 'ext': 'mp4',
  18. 'title': 'What\'s Wrong with These Photos? A Whole Lot',
  19. 'timestamp': 1406876400,
  20. 'upload_date': '20140801',
  21. }
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. webpage = self._download_webpage(url, video_id)
  27. timestamp = parse_iso8601(self._search_regex(
  28. r'<span class="publish-date"><time datetime="([^"]+)">',
  29. webpage, 'timestamp'))
  30. return {
  31. 'id': video_id,
  32. 'title': self._og_search_title(webpage),
  33. 'url': self._html_search_meta('VideoURL', webpage, 'url'),
  34. 'timestamp': timestamp,
  35. }
  36. class EllenTVClipsIE(InfoExtractor):
  37. IE_NAME = 'EllenTV:clips'
  38. _VALID_URL = r'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)'
  39. _TEST = {
  40. 'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/',
  41. 'info_dict': {
  42. 'id': 'meryl-streep-vanessa-hudgens',
  43. 'title': 'Meryl Streep, Vanessa Hudgens',
  44. },
  45. 'playlist_mincount': 9,
  46. }
  47. def _real_extract(self, url):
  48. mobj = re.match(self._VALID_URL, url)
  49. playlist_id = mobj.group('id')
  50. webpage = self._download_webpage(url, playlist_id)
  51. playlist = self._extract_playlist(webpage)
  52. return {
  53. '_type': 'playlist',
  54. 'id': playlist_id,
  55. 'title': self._og_search_title(webpage),
  56. 'entries': self._extract_entries(playlist)
  57. }
  58. def _extract_playlist(self, webpage):
  59. json_string = self._search_regex(r'playerView.addClips\(\[\{(.*?)\}\]\);', webpage, 'json')
  60. try:
  61. return json.loads("[{" + json_string + "}]")
  62. except ValueError as ve:
  63. raise ExtractorError('Failed to download JSON', cause=ve)
  64. def _extract_entries(self, playlist):
  65. return [self.url_result(item['url'], 'EllenTV') for item in playlist]