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.

101 lines
3.5 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from .kaltura import KalturaIE
  5. from ..utils import NO_DEFAULT
  6. class EllenTVIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)'
  8. _TESTS = [{
  9. 'url': 'http://www.ellentv.com/videos/0-ipq1gsai/',
  10. 'md5': '4294cf98bc165f218aaa0b89e0fd8042',
  11. 'info_dict': {
  12. 'id': '0_ipq1gsai',
  13. 'ext': 'mov',
  14. 'title': 'Fast Fingers of Fate',
  15. 'description': 'md5:3539013ddcbfa64b2a6d1b38d910868a',
  16. 'timestamp': 1428035648,
  17. 'upload_date': '20150403',
  18. 'uploader_id': 'batchUser',
  19. },
  20. }, {
  21. # not available via http://widgets.ellentube.com/
  22. 'url': 'http://www.ellentv.com/videos/1-szkgu2m2/',
  23. 'info_dict': {
  24. 'id': '1_szkgu2m2',
  25. 'ext': 'flv',
  26. 'title': "Ellen's Amazingly Talented Audience",
  27. 'description': 'md5:86ff1e376ff0d717d7171590e273f0a5',
  28. 'timestamp': 1255140900,
  29. 'upload_date': '20091010',
  30. 'uploader_id': 'ellenkaltura@gmail.com',
  31. },
  32. 'params': {
  33. 'skip_download': True,
  34. },
  35. }]
  36. def _real_extract(self, url):
  37. video_id = self._match_id(url)
  38. URLS = ('http://widgets.ellentube.com/videos/%s' % video_id, url)
  39. for num, url_ in enumerate(URLS, 1):
  40. webpage = self._download_webpage(
  41. url_, video_id, fatal=num == len(URLS))
  42. default = NO_DEFAULT if num == len(URLS) else None
  43. partner_id = self._search_regex(
  44. r"var\s+partnerId\s*=\s*'([^']+)", webpage, 'partner id',
  45. default=default)
  46. kaltura_id = self._search_regex(
  47. [r'id="kaltura_player_([^"]+)"',
  48. r"_wb_entry_id\s*:\s*'([^']+)",
  49. r'data-kaltura-entry-id="([^"]+)'],
  50. webpage, 'kaltura id', default=default)
  51. if partner_id and kaltura_id:
  52. break
  53. return self.url_result('kaltura:%s:%s' % (partner_id, kaltura_id), KalturaIE.ie_key())
  54. class EllenTVClipsIE(InfoExtractor):
  55. IE_NAME = 'EllenTV:clips'
  56. _VALID_URL = r'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)'
  57. _TEST = {
  58. 'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/',
  59. 'info_dict': {
  60. 'id': 'meryl-streep-vanessa-hudgens',
  61. 'title': 'Meryl Streep, Vanessa Hudgens',
  62. },
  63. 'playlist_mincount': 5,
  64. }
  65. def _real_extract(self, url):
  66. playlist_id = self._match_id(url)
  67. webpage = self._download_webpage(url, playlist_id)
  68. playlist = self._extract_playlist(webpage, playlist_id)
  69. return {
  70. '_type': 'playlist',
  71. 'id': playlist_id,
  72. 'title': self._og_search_title(webpage),
  73. 'entries': self._extract_entries(playlist)
  74. }
  75. def _extract_playlist(self, webpage, playlist_id):
  76. json_string = self._search_regex(r'playerView.addClips\(\[\{(.*?)\}\]\);', webpage, 'json')
  77. return self._parse_json('[{' + json_string + '}]', playlist_id)
  78. def _extract_entries(self, playlist):
  79. return [
  80. self.url_result(
  81. 'kaltura:%s:%s' % (item['kaltura_partner_id'], item['kaltura_entry_id']),
  82. KalturaIE.ie_key(), video_id=item['kaltura_entry_id'])
  83. for item in playlist]