- cchar = '?'
- json_url = url + cchar + 'skin=json&version=2&no_wrap=1'
- request = compat_urllib_request.Request(json_url)
- request.add_header('User-Agent', 'iTunes/10.6.1')
- self.report_extraction(mobj.group(1))
- urlh = self._request_webpage(request, None, False,
- 'unable to download video info webpage')
-
- try:
- json_code_bytes = urlh.read()
- json_code = json_code_bytes.decode('utf-8')
- except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
- raise ExtractorError('Unable to read video info webpage: %s' % compat_str(err))
-
- try:
- json_data = json.loads(json_code)
- if 'Post' in json_data:
- data = json_data['Post']
- else:
- data = json_data
-
- upload_date = datetime.datetime.strptime(data['datestamp'], '%m-%d-%y %H:%M%p').strftime('%Y%m%d')
- formats = []
- if 'additionalMedia' in data:
- for f in sorted(data['additionalMedia'], key=lambda f: int(f['media_height'])):
- if not int(f['media_width']): # filter m3u8
- continue
- formats.append({
- 'url': f['url'],
- 'format_id': f['role'],
- 'width': int(f['media_width']),
- 'height': int(f['media_height']),
- })
- else:
+ video_id = mobj.group('id')
+
+ rss = self._download_xml('http://blip.tv/rss/flash/%s' % video_id, video_id, 'Downloading video RSS')
+
+ def blip(s):
+ return '{http://blip.tv/dtd/blip/1.0}%s' % s
+
+ def media(s):
+ return '{http://search.yahoo.com/mrss/}%s' % s
+
+ def itunes(s):
+ return '{http://www.itunes.com/dtds/podcast-1.0.dtd}%s' % s
+
+ item = rss.find('channel/item')
+
+ video_id = item.find(blip('item_id')).text
+ title = item.find('./title').text
+ description = clean_html(compat_str(item.find(blip('puredescription')).text))
+ timestamp = parse_iso8601(item.find(blip('datestamp')).text)
+ uploader = item.find(blip('user')).text
+ uploader_id = item.find(blip('userid')).text
+ duration = int(item.find(blip('runtime')).text)
+ media_thumbnail = item.find(media('thumbnail'))
+ thumbnail = media_thumbnail.get('url') if media_thumbnail is not None else item.find(itunes('image')).text
+ categories = [category.text for category in item.findall('category')]
+
+ formats = []
+ subtitles = {}
+
+ media_group = item.find(media('group'))
+ for media_content in media_group.findall(media('content')):
+ url = media_content.get('url')
+ role = media_content.get(blip('role'))
+ msg = self._download_webpage(
+ url + '?showplayer=20140425131715&referrer=http://blip.tv&mask=7&skin=flashvars&view=url',
+ video_id, 'Resolving URL for %s' % role)
+ real_url = compat_urlparse.parse_qs(msg)['message'][0]
+
+ media_type = media_content.get('type')
+ if media_type == 'text/srt' or url.endswith('.srt'):
+ LANGS = {
+ 'english': 'en',
+ }
+ lang = role.rpartition('-')[-1].strip().lower()
+ langcode = LANGS.get(lang, lang)
+ subtitles[langcode] = url
+ elif media_type.startswith('video/'):