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.

95 lines
3.2 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. parse_iso8601,
  8. )
  9. class EllenTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)'
  11. _TESTS = [{
  12. 'url': 'http://www.ellentv.com/videos/0-ipq1gsai/',
  13. 'md5': '8e3c576bf2e9bfff4d76565f56f94c9c',
  14. 'info_dict': {
  15. 'id': '0-ipq1gsai',
  16. 'ext': 'mp4',
  17. 'title': 'Fast Fingers of Fate',
  18. 'description': 'md5:686114ced0a032926935e9015ee794ac',
  19. 'timestamp': 1428033600,
  20. 'upload_date': '20150403',
  21. }
  22. }, {
  23. 'url': 'http://ellentube.com/videos/0-dvzmabd5/',
  24. 'md5': '98238118eaa2bbdf6ad7f708e3e4f4eb',
  25. 'info_dict': {
  26. 'id': '0-dvzmabd5',
  27. 'ext': 'mp4',
  28. 'title': '1 year old twin sister makes her brother laugh',
  29. 'description': '1 year old twin sister makes her brother laugh',
  30. 'timestamp': 1419542075,
  31. 'upload_date': '20141225',
  32. }
  33. }]
  34. def _real_extract(self, url):
  35. video_id = self._match_id(url)
  36. webpage = self._download_webpage(url, video_id)
  37. video_url = self._html_search_meta('VideoURL', webpage, 'url', fatal=True)
  38. title = self._og_search_title(webpage, default=None) or self._search_regex(
  39. r'pageName\s*=\s*"([^"]+)"', webpage, 'title')
  40. description = self._html_search_meta(
  41. 'description', webpage, 'description') or self._og_search_description(webpage)
  42. timestamp = parse_iso8601(self._search_regex(
  43. r'<span class="publish-date"><time datetime="([^"]+)">',
  44. webpage, 'timestamp', fatal=False))
  45. return {
  46. 'id': video_id,
  47. 'url': video_url,
  48. 'title': title,
  49. 'description': description,
  50. 'timestamp': timestamp,
  51. }
  52. class EllenTVClipsIE(InfoExtractor):
  53. IE_NAME = 'EllenTV:clips'
  54. _VALID_URL = r'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)'
  55. _TEST = {
  56. 'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/',
  57. 'info_dict': {
  58. 'id': 'meryl-streep-vanessa-hudgens',
  59. 'title': 'Meryl Streep, Vanessa Hudgens',
  60. },
  61. 'playlist_mincount': 9,
  62. }
  63. def _real_extract(self, url):
  64. playlist_id = self._match_id(url)
  65. webpage = self._download_webpage(url, playlist_id)
  66. playlist = self._extract_playlist(webpage)
  67. return {
  68. '_type': 'playlist',
  69. 'id': playlist_id,
  70. 'title': self._og_search_title(webpage),
  71. 'entries': self._extract_entries(playlist)
  72. }
  73. def _extract_playlist(self, webpage):
  74. json_string = self._search_regex(r'playerView.addClips\(\[\{(.*?)\}\]\);', webpage, 'json')
  75. try:
  76. return json.loads("[{" + json_string + "}]")
  77. except ValueError as ve:
  78. raise ExtractorError('Failed to download JSON', cause=ve)
  79. def _extract_entries(self, playlist):
  80. return [self.url_result(item['url'], 'EllenTV') for item in playlist]