]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ellentv.py
74bbc5c51c576880465e76453604891b6b5f48ca
   2 from __future__ 
import unicode_literals
 
   6 from .common 
import InfoExtractor
 
  13 class EllenTVIE(InfoExtractor
): 
  14     _VALID_URL 
= r
'https?://(?:www\.)?(?:ellentv|ellentube)\.com/videos/(?P<id>[a-z0-9_-]+)' 
  16         'url': 'http://www.ellentv.com/videos/0-ipq1gsai/', 
  17         'md5': '4294cf98bc165f218aaa0b89e0fd8042', 
  21             'title': 'Fast Fingers of Fate', 
  22             'description': 'md5:3539013ddcbfa64b2a6d1b38d910868a', 
  23             'timestamp': 1428035648, 
  24             'upload_date': '20150403', 
  25             'uploader_id': 'batchUser', 
  28         # not available via http://widgets.ellentube.com/ 
  29         'url': 'http://www.ellentv.com/videos/1-szkgu2m2/', 
  33             'title': "Ellen's Amazingly Talented Audience", 
  34             'description': 'md5:86ff1e376ff0d717d7171590e273f0a5', 
  35             'timestamp': 1255140900, 
  36             'upload_date': '20091010', 
  37             'uploader_id': 'ellenkaltura@gmail.com', 
  40             'skip_download': True, 
  44     def _real_extract(self
, url
): 
  45         video_id 
= self
._match
_id
(url
) 
  47         URLS 
= ('http://widgets.ellentube.com/videos/%s' % video_id
, url
) 
  49         for num
, url_ 
in enumerate(URLS
, 1): 
  50             webpage 
= self
._download
_webpage
( 
  51                 url_
, video_id
, fatal
=num 
== len(URLS
)) 
  53             default 
= NO_DEFAULT 
if num 
== len(URLS
) else None 
  55             partner_id 
= self
._search
_regex
( 
  56                 r
"var\s+partnerId\s*=\s*'([^']+)", webpage
, 'partner id', 
  59             kaltura_id 
= self
._search
_regex
( 
  60                 [r
'id="kaltura_player_([^"]+)"', 
  61                  r
"_wb_entry_id\s*:\s*'([^']+)", 
  62                  r
'data-kaltura-entry-id="([^"]+)'], 
  63                 webpage
, 'kaltura id', default
=default
) 
  65             if partner_id 
and kaltura_id
: 
  68         return self
.url_result('kaltura:%s:%s' % (partner_id
, kaltura_id
), 'Kaltura') 
  71 class EllenTVClipsIE(InfoExtractor
): 
  72     IE_NAME 
= 'EllenTV:clips' 
  73     _VALID_URL 
= r
'https?://(?:www\.)?ellentv\.com/episodes/(?P<id>[a-z0-9_-]+)' 
  75         'url': 'http://www.ellentv.com/episodes/meryl-streep-vanessa-hudgens/', 
  77             'id': 'meryl-streep-vanessa-hudgens', 
  78             'title': 'Meryl Streep, Vanessa Hudgens', 
  80         'playlist_mincount': 7, 
  83     def _real_extract(self
, url
): 
  84         playlist_id 
= self
._match
_id
(url
) 
  86         webpage 
= self
._download
_webpage
(url
, playlist_id
) 
  87         playlist 
= self
._extract
_playlist
(webpage
) 
  92             'title': self
._og
_search
_title
(webpage
), 
  93             'entries': self
._extract
_entries
(playlist
) 
  96     def _extract_playlist(self
, webpage
): 
  97         json_string 
= self
._search
_regex
(r
'playerView.addClips\(\[\{(.*?)\}\]\);', webpage
, 'json') 
  99             return json
.loads('[{' + json_string 
+ '}]') 
 100         except ValueError as ve
: 
 101             raise ExtractorError('Failed to download JSON', cause
=ve
) 
 103     def _extract_entries(self
, playlist
): 
 106                 'kaltura:%s:%s' % (item
['kaltura_partner_id'], item
['kaltura_entry_id']), 
 108             for item 
in playlist
]