[generic] Add support for BOMs (Fixes #4753)

This commit is contained in:
Philipp Hagemeister 2015-01-23 01:21:30 +01:00
parent 317239b097
commit 61ca9a80b3
3 changed files with 39 additions and 1 deletions

View file

@ -17,6 +17,7 @@ from ..utils import (
ExtractorError,
float_or_none,
HEADRequest,
is_html,
orderedSet,
parse_xml,
smuggle_url,
@ -647,7 +648,7 @@ class GenericIE(InfoExtractor):
# Maybe it's a direct link to a video?
# Be careful not to download the whole thing!
first_bytes = full_response.read(512)
if not re.match(r'^\s*<', first_bytes.decode('utf-8', 'replace')):
if not is_html(first_bytes):
self._downloader.report_warning(
'URL could be a direct video link, returning it as such.')
upload_date = unified_strdate(