]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/ustream.py
1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
12 class UstreamIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://www\.ustream\.tv/(?P<type>recorded|embed|embed/recorded)/(?P<videoID>\d+)'
16 'url': 'http://www.ustream.tv/recorded/20274954',
17 'md5': '088f151799e8f572f84eb62f17d73e5c',
21 'uploader': 'Young Americans for Liberty',
22 'title': 'Young Americans for Liberty February 7, 2012 2:28 AM',
26 def _real_extract(self
, url
):
27 m
= re
.match(self
._VALID
_URL
, url
)
28 video_id
= m
.group('videoID')
30 # some sites use this embed format (see: http://github.com/rg3/youtube-dl/issues/2990)
31 if m
.group('type') == 'embed/recorded':
32 video_id
= m
.group('videoID')
33 desktop_url
= 'http://www.ustream.tv/recorded/' + video_id
34 return self
.url_result(desktop_url
, 'Ustream')
35 if m
.group('type') == 'embed':
36 video_id
= m
.group('videoID')
37 webpage
= self
._download
_webpage
(url
, video_id
)
38 desktop_video_id
= self
._html
_search
_regex
(
39 r
'ContentVideoIds=\["([^"]*?)"\]', webpage
, 'desktop_video_id')
40 desktop_url
= 'http://www.ustream.tv/recorded/' + desktop_video_id
41 return self
.url_result(desktop_url
, 'Ustream')
43 video_url
= 'http://tcdn.ustream.tv/video/%s' % video_id
44 webpage
= self
._download
_webpage
(url
, video_id
)
46 self
.report_extraction(video_id
)
48 video_title
= self
._html
_search
_regex
(r
'data-title="(?P<title>.+)"',
51 uploader
= self
._html
_search
_regex
(r
'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
52 webpage
, 'uploader', fatal
=False, flags
=re
.DOTALL
)
54 thumbnail
= self
._html
_search
_regex
(r
'<link rel="image_src" href="(?P<thumb>.*?)"',
55 webpage
, 'thumbnail', fatal
=False)
63 'thumbnail': thumbnail
,
67 class UstreamChannelIE(InfoExtractor
):
68 _VALID_URL
= r
'https?://www\.ustream\.tv/channel/(?P<slug>.+)'
69 IE_NAME
= 'ustream:channel'
71 'url': 'http://www.ustream.tv/channel/channeljapan',
75 'playlist_mincount': 17,
78 def _real_extract(self
, url
):
79 m
= re
.match(self
._VALID
_URL
, url
)
80 display_id
= m
.group('slug')
81 webpage
= self
._download
_webpage
(url
, display_id
)
82 channel_id
= get_meta_content('ustream:channel_id', webpage
)
84 BASE
= 'http://www.ustream.tv'
85 next_url
= '/ajax/socialstream/videos/%s/1.json' % channel_id
88 reply
= self
._download
_json
(
89 compat_urlparse
.urljoin(BASE
, next_url
), display_id
,
90 note
='Downloading video information (next: %d)' % (len(video_ids
) + 1))
91 video_ids
.extend(re
.findall(r
'data-content-id="(\d.*)"', reply
['data']))
92 next_url
= reply
['nextUrl']
95 self
.url_result('http://www.ustream.tv/recorded/' + vid
, 'Ustream')
100 'display_id': display_id
,