|
@ -70,13 +70,14 @@ class BlipTVIE(InfoExtractor): |
|
|
info = None |
|
|
info = None |
|
|
urlh = self._request_webpage(request, None, False, |
|
|
urlh = self._request_webpage(request, None, False, |
|
|
u'unable to download video info webpage') |
|
|
u'unable to download video info webpage') |
|
|
|
|
|
|
|
|
if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download |
|
|
if urlh.headers.get('Content-Type', '').startswith('video/'): # Direct download |
|
|
basename = url.split('/')[-1] |
|
|
basename = url.split('/')[-1] |
|
|
title,ext = os.path.splitext(basename) |
|
|
title,ext = os.path.splitext(basename) |
|
|
title = title.decode('UTF-8') |
|
|
title = title.decode('UTF-8') |
|
|
ext = ext.replace('.', '') |
|
|
ext = ext.replace('.', '') |
|
|
self.report_direct_download(title) |
|
|
self.report_direct_download(title) |
|
|
info = { |
|
|
|
|
|
|
|
|
return { |
|
|
'id': title, |
|
|
'id': title, |
|
|
'url': url, |
|
|
'url': url, |
|
|
'uploader': None, |
|
|
'uploader': None, |
|
@ -85,49 +86,47 @@ class BlipTVIE(InfoExtractor): |
|
|
'ext': ext, |
|
|
'ext': ext, |
|
|
'urlhandle': urlh |
|
|
'urlhandle': urlh |
|
|
} |
|
|
} |
|
|
if info is None: # Regular URL |
|
|
|
|
|
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(u'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') |
|
|
|
|
|
if 'additionalMedia' in data: |
|
|
|
|
|
formats = sorted(data['additionalMedia'], key=lambda f: int(f['media_height'])) |
|
|
|
|
|
best_format = formats[-1] |
|
|
|
|
|
video_url = best_format['url'] |
|
|
|
|
|
else: |
|
|
|
|
|
video_url = data['media']['url'] |
|
|
|
|
|
umobj = re.match(self._URL_EXT, video_url) |
|
|
|
|
|
if umobj is None: |
|
|
|
|
|
raise ValueError('Can not determine filename extension') |
|
|
|
|
|
ext = umobj.group(1) |
|
|
|
|
|
|
|
|
|
|
|
info = { |
|
|
|
|
|
'id': compat_str(data['item_id']), |
|
|
|
|
|
'url': video_url, |
|
|
|
|
|
'uploader': data['display_name'], |
|
|
|
|
|
'upload_date': upload_date, |
|
|
|
|
|
'title': data['title'], |
|
|
|
|
|
'ext': ext, |
|
|
|
|
|
'format': data['media']['mimeType'], |
|
|
|
|
|
'thumbnail': data['thumbnailUrl'], |
|
|
|
|
|
'description': data['description'], |
|
|
|
|
|
'player_url': data['embedUrl'], |
|
|
|
|
|
'user_agent': 'iTunes/10.6.1', |
|
|
|
|
|
} |
|
|
|
|
|
except (ValueError,KeyError) as err: |
|
|
|
|
|
raise ExtractorError(u'Unable to parse video information: %s' % repr(err)) |
|
|
|
|
|
|
|
|
|
|
|
return [info] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(u'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') |
|
|
|
|
|
if 'additionalMedia' in data: |
|
|
|
|
|
formats = sorted(data['additionalMedia'], key=lambda f: int(f['media_height'])) |
|
|
|
|
|
best_format = formats[-1] |
|
|
|
|
|
video_url = best_format['url'] |
|
|
|
|
|
else: |
|
|
|
|
|
video_url = data['media']['url'] |
|
|
|
|
|
umobj = re.match(self._URL_EXT, video_url) |
|
|
|
|
|
if umobj is None: |
|
|
|
|
|
raise ValueError('Can not determine filename extension') |
|
|
|
|
|
ext = umobj.group(1) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
|
'id': compat_str(data['item_id']), |
|
|
|
|
|
'url': video_url, |
|
|
|
|
|
'uploader': data['display_name'], |
|
|
|
|
|
'upload_date': upload_date, |
|
|
|
|
|
'title': data['title'], |
|
|
|
|
|
'ext': ext, |
|
|
|
|
|
'format': data['media']['mimeType'], |
|
|
|
|
|
'thumbnail': data['thumbnailUrl'], |
|
|
|
|
|
'description': data['description'], |
|
|
|
|
|
'player_url': data['embedUrl'], |
|
|
|
|
|
'user_agent': 'iTunes/10.6.1', |
|
|
|
|
|
} |
|
|
|
|
|
except (ValueError, KeyError) as err: |
|
|
|
|
|
raise ExtractorError(u'Unable to parse video information: %s' % repr(err)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BlipTVUserIE(InfoExtractor): |
|
|
class BlipTVUserIE(InfoExtractor): |
|
|