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.

84 lines
2.6 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. )
  8. class EllenTVIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)'
  10. _TEST = {
  11. 'url': 'http://www.ellentv.com/videos/0-ipq1gsai/',
  12. 'md5': '4294cf98bc165f218aaa0b89e0fd8042',
  13. 'info_dict': {
  14. 'id': '0_ipq1gsai',
  15. 'ext': 'mov',
  16. 'title': 'Fast Fingers of Fate',
  17. 'description': 'md5:3539013ddcbfa64b2a6d1b38d910868a',
  18. 'timestamp': 1428035648,
  19. 'upload_date': '20150403',
  20. 'uploader_id': 'batchUser',
  21. }
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(
  26. 'http://widgets.ellentube.com/videos/%s' % video_id,
  27. video_id)
  28. partner_id = self._search_regex(
  29. r"var\s+partnerId\s*=\s*'([^']+)", webpage, 'partner id')
  30. kaltura_id = self._search_regex(
  31. [r'id="kaltura_player_([^"]+)"',
  32. r"_wb_entry_id\s*:\s*'([^']+)",
  33. r'data-kaltura-entry-id="([^"]+)'],
  34. webpage, 'kaltura id')
  35. return self.url_result('kaltura:%s:%s' % (partner_id, kaltura_id), 'Kaltura')
  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': 7,
  46. }
  47. def _real_extract(self, url):
  48. playlist_id = self._match_id(url)
  49. webpage = self._download_webpage(url, playlist_id)
  50. playlist = self._extract_playlist(webpage)
  51. return {
  52. '_type': 'playlist',
  53. 'id': playlist_id,
  54. 'title': self._og_search_title(webpage),
  55. 'entries': self._extract_entries(playlist)
  56. }
  57. def _extract_playlist(self, webpage):
  58. json_string = self._search_regex(r'playerView.addClips\(\[\{(.*?)\}\]\);', webpage, 'json')
  59. try:
  60. return json.loads("[{" + json_string + "}]")
  61. except ValueError as ve:
  62. raise ExtractorError('Failed to download JSON', cause=ve)
  63. def _extract_entries(self, playlist):
  64. return [
  65. self.url_result(
  66. 'kaltura:%s:%s' % (item['kaltura_partner_id'], item['kaltura_entry_id']),
  67. 'Kaltura')
  68. for item in playlist]