4 from .common
import InfoExtractor
5 from ..utils
import compat_urllib_parse_urlparse
, compat_urlparse
8 class LivestreamIE(InfoExtractor
):
9 _VALID_URL
= r
'http://new.livestream.com/.*?/(?P<event_name>.*?)(/videos/(?P<id>\d+))?/?$'
11 u
'url': u
'http://new.livestream.com/CoheedandCambria/WebsterHall/videos/4719370',
12 u
'file': u
'4719370.mp4',
13 u
'md5': u
'0d2186e3187d185a04b3cdd02b828836',
15 u
'title': u
'Live from Webster Hall NYC',
16 u
'upload_date': u
'20121012',
20 def _extract_video_info(self
, video_data
):
21 video_url
= video_data
.get('progressive_url_hd') or video_data
.get('progressive_url')
22 return {'id': video_data
['id'],
25 'title': video_data
['caption'],
26 'thumbnail': video_data
['thumbnail_url'],
27 'upload_date': video_data
['updated_at'].replace('-','')[:8],
30 def _real_extract(self
, url
):
31 mobj
= re
.match(self
._VALID
_URL
, url
)
32 video_id
= mobj
.group('id')
33 event_name
= mobj
.group('event_name')
34 webpage
= self
._download
_webpage
(url
, video_id
or event_name
)
37 # This is an event page:
38 api_url
= self
._search
_regex
(r
'event_design_eventId: \'(.+?
)\'',
40 info = json.loads(self._download_webpage(api_url, event_name,
41 u'Downloading event info
'))
42 videos = [self._extract_video_info(video_data['data
'])
43 for video_data in info['feed
']['data
'] if video_data['type'] == u'video
']
44 return self.playlist_result(videos, info['id'], info['full_name
'])
46 og_video = self._og_search_video_url(webpage, name=u'player url
')
47 query_str = compat_urllib_parse_urlparse(og_video).query
48 query = compat_urlparse.parse_qs(query_str)
49 api_url = query['play_url
'][0].replace('.smil
', '')
50 info = json.loads(self._download_webpage(api_url, video_id,
51 u'Downloading video info
'))
52 return self._extract_video_info(info)