]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ellentv.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   5 from .kaltura 
import KalturaIE
 
   6 from ..utils 
import NO_DEFAULT
 
   9 class EllenTVIE(InfoExtractor
): 
  10     _VALID_URL 
= r
'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)' 
  12         'url': 'http://www.ellentv.com/videos/0-ipq1gsai/', 
  13         'md5': '4294cf98bc165f218aaa0b89e0fd8042', 
  17             'title': 'Fast Fingers of Fate', 
  18             'description': 'md5:3539013ddcbfa64b2a6d1b38d910868a', 
  19             'timestamp': 1428035648, 
  20             'upload_date': '20150403', 
  21             'uploader_id': 'batchUser', 
  24         # not available via http://widgets.ellentube.com/ 
  25         'url': 'http://www.ellentv.com/videos/1-szkgu2m2/', 
  29             'title': "Ellen's Amazingly Talented Audience", 
  30             'description': 'md5:86ff1e376ff0d717d7171590e273f0a5', 
  31             'timestamp': 1255140900, 
  32             'upload_date': '20091010', 
  33             'uploader_id': 'ellenkaltura@gmail.com', 
  36             'skip_download': True, 
  40     def _real_extract(self
, url
): 
  41         video_id 
= self
._match
_id
(url
) 
  43         URLS 
= ('http://widgets.ellentube.com/videos/%s' % video_id
, url
) 
  45         for num
, url_ 
in enumerate(URLS
, 1): 
  46             webpage 
= self
._download
_webpage
( 
  47                 url_
, video_id
, fatal
=num 
== len(URLS
)) 
  49             default 
= NO_DEFAULT 
if num 
== len(URLS
) else None 
  51             partner_id 
= self
._search
_regex
( 
  52                 r
"var\s+partnerId\s*=\s*'([^']+)", webpage
, 'partner id', 
  55             kaltura_id 
= self
._search
_regex
( 
  56                 [r
'id="kaltura_player_([^"]+)"', 
  57                  r
"_wb_entry_id\s*:\s*'([^']+)", 
  58                  r
'data-kaltura-entry-id="([^"]+)'], 
  59                 webpage
, 'kaltura id', default
=default
) 
  61             if partner_id 
and kaltura_id
: 
  64         return self
.url_result('kaltura:%s:%s' % (partner_id
, kaltura_id
), KalturaIE
.ie_key()) 
  67 class EllenTVClipsIE(InfoExtractor
): 
  68     IE_NAME 
= 'EllenTV:clips' 
  69     _VALID_URL 
= r
'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)' 
  71         'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/', 
  73             'id': 'meryl-streep-vanessa-hudgens', 
  74             'title': 'Meryl Streep, Vanessa Hudgens', 
  76         'playlist_mincount': 5, 
  79     def _real_extract(self
, url
): 
  80         playlist_id 
= self
._match
_id
(url
) 
  82         webpage 
= self
._download
_webpage
(url
, playlist_id
) 
  83         playlist 
= self
._extract
_playlist
(webpage
, playlist_id
) 
  88             'title': self
._og
_search
_title
(webpage
), 
  89             'entries': self
._extract
_entries
(playlist
) 
  92     def _extract_playlist(self
, webpage
, playlist_id
): 
  93         json_string 
= self
._search
_regex
(r
'playerView.addClips\(\[\{(.*?)\}\]\);', webpage
, 'json') 
  94         return self
._parse
_json
('[{' + json_string 
+ '}]', playlist_id
) 
  96     def _extract_entries(self
, playlist
): 
  99                 'kaltura:%s:%s' % (item
['kaltura_partner_id'], item
['kaltura_entry_id']), 
 100                 KalturaIE
.ie_key(), video_id
=item
['kaltura_entry_id']) 
 101             for item 
in playlist
]