]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/ustream.py
1 from __future__
import unicode_literals
6 from .common
import InfoExtractor
10 from ..utils
import ExtractorError
13 class UstreamIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://www\.ustream\.tv/(?P<type>recorded|embed|embed/recorded)/(?P<videoID>\d+)'
17 'url': 'http://www.ustream.tv/recorded/20274954',
18 'md5': '088f151799e8f572f84eb62f17d73e5c',
22 'uploader': 'Young Americans for Liberty',
23 'title': 'Young Americans for Liberty February 7, 2012 2:28 AM',
26 # From http://sportscanada.tv/canadagames/index.php/week2/figure-skating/444
27 # Title and uploader available only from params JSON
28 'url': 'http://www.ustream.tv/embed/recorded/59307601?ub=ff0000&lc=ff0000&oc=ffffff&uc=ffffff&v=3&wmode=direct',
29 'md5': '5a2abf40babeac9812ed20ae12d34e10',
33 'title': '-CG11- Canada Games Figure Skating',
34 'uploader': 'sportscanadatv',
38 def _real_extract(self
, url
):
39 m
= re
.match(self
._VALID
_URL
, url
)
40 video_id
= m
.group('videoID')
42 # some sites use this embed format (see: http://github.com/rg3/youtube-dl/issues/2990)
43 if m
.group('type') == 'embed/recorded':
44 video_id
= m
.group('videoID')
45 desktop_url
= 'http://www.ustream.tv/recorded/' + video_id
46 return self
.url_result(desktop_url
, 'Ustream')
47 if m
.group('type') == 'embed':
48 video_id
= m
.group('videoID')
49 webpage
= self
._download
_webpage
(url
, video_id
)
50 desktop_video_id
= self
._html
_search
_regex
(
51 r
'ContentVideoIds=\["([^"]*?)"\]', webpage
, 'desktop_video_id')
52 desktop_url
= 'http://www.ustream.tv/recorded/' + desktop_video_id
53 return self
.url_result(desktop_url
, 'Ustream')
55 params
= self
._download
_json
(
56 'http://cdngw.ustream.tv/rgwjson/Viewer.getVideo/' + json
.dumps({
58 'videoId': int(video_id
),
63 raise ExtractorError(params
['error']['message'], expected
=True)
65 video_url
= params
['flv']
67 webpage
= self
._download
_webpage
(url
, video_id
)
69 self
.report_extraction(video_id
)
71 video_title
= self
._html
_search
_regex
(r
'data-title="(?P<title>.+)"',
72 webpage
, 'title', default
=None)
76 video_title
= params
['moduleConfig']['meta']['title']
81 video_title
= 'Ustream video ' + video_id
83 uploader
= self
._html
_search
_regex
(r
'data-content-type="channel".*?>(?P<uploader>.*?)</a>',
84 webpage
, 'uploader', fatal
=False, flags
=re
.DOTALL
, default
=None)
88 uploader
= params
['moduleConfig']['meta']['userName']
92 thumbnail
= self
._html
_search
_regex
(r
'<link rel="image_src" href="(?P<thumb>.*?)"',
93 webpage
, 'thumbnail', fatal
=False)
100 'uploader': uploader
,
101 'thumbnail': thumbnail
,
105 class UstreamChannelIE(InfoExtractor
):
106 _VALID_URL
= r
'https?://www\.ustream\.tv/channel/(?P<slug>.+)'
107 IE_NAME
= 'ustream:channel'
109 'url': 'http://www.ustream.tv/channel/channeljapan',
113 'playlist_mincount': 17,
116 def _real_extract(self
, url
):
117 m
= re
.match(self
._VALID
_URL
, url
)
118 display_id
= m
.group('slug')
119 webpage
= self
._download
_webpage
(url
, display_id
)
120 channel_id
= self
._html
_search
_meta
('ustream:channel_id', webpage
)
122 BASE
= 'http://www.ustream.tv'
123 next_url
= '/ajax/socialstream/videos/%s/1.json' % channel_id
126 reply
= self
._download
_json
(
127 compat_urlparse
.urljoin(BASE
, next_url
), display_id
,
128 note
='Downloading video information (next: %d)' % (len(video_ids
) + 1))
129 video_ids
.extend(re
.findall(r
'data-content-id="(\d.*)"', reply
['data']))
130 next_url
= reply
['nextUrl']
133 self
.url_result('http://www.ustream.tv/recorded/' + vid
, 'Ustream')
134 for vid
in video_ids
]
138 'display_id': display_id
,