projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[thisav] Simplify and use unicode literals
[youtube-dl]
/
youtube_dl
/
downloader
/
http.py
diff --git
a/youtube_dl/downloader/http.py
b/youtube_dl/downloader/http.py
index 54dc7616bd2a92941e71a3b17d4c400104d0682a..748f9f3adfe0555024cce272b8eb872c55558d6c 100644
(file)
--- a/
youtube_dl/downloader/http.py
+++ b/
youtube_dl/downloader/http.py
@@
-1,7
+1,4
@@
import os
import os
-import re
-import subprocess
-import sys
import time
from .common import FileDownloader
import time
from .common import FileDownloader
@@
-30,7
+27,7
@@
class HttpFD(FileDownloader):
request = compat_urllib_request.Request(url, None, headers)
if self.params.get('test', False):
request = compat_urllib_request.Request(url, None, headers)
if self.params.get('test', False):
- request.add_header('Range','bytes=0-10240')
+ request.add_header('Range',
'bytes=0-10240')
# Establish possible resume length
if os.path.isfile(encodeFilename(tmpfilename)):
# Establish possible resume length
if os.path.isfile(encodeFilename(tmpfilename)):
@@
-42,7
+39,7
@@
class HttpFD(FileDownloader):
if resume_len != 0:
if self.params.get('continuedl', False):
self.report_resuming_byte(resume_len)
if resume_len != 0:
if self.params.get('continuedl', False):
self.report_resuming_byte(resume_len)
- request.add_header('Range','bytes=%d-' % resume_len)
+ request.add_header('Range',
'bytes=%d-' % resume_len)
open_mode = 'ab'
else:
resume_len = 0
open_mode = 'ab'
else:
resume_len = 0
@@
-52,8
+49,6
@@
class HttpFD(FileDownloader):
while count <= retries:
# Establish connection
try:
while count <= retries:
# Establish connection
try:
- if count == 0 and 'urlhandle' in info_dict:
- data = info_dict['urlhandle']
data = compat_urllib_request.urlopen(request)
break
except (compat_urllib_error.HTTPError, ) as err:
data = compat_urllib_request.urlopen(request)
break
except (compat_urllib_error.HTTPError, ) as err:
@@
-105,7
+100,7
@@
class HttpFD(FileDownloader):
if data_len is not None:
data_len = int(data_len) + resume_len
min_data_len = self.params.get("min_filesize", None)
if data_len is not None:
data_len = int(data_len) + resume_len
min_data_len = self.params.get("min_filesize", None)
- max_data_len =
self.params.get("max_filesize", None)
+ max_data_len = self.params.get("max_filesize", None)
if min_data_len is not None and data_len < min_data_len:
self.to_screen(u'\r[download] File is smaller than min-filesize (%s bytes < %s bytes). Aborting.' % (data_len, min_data_len))
return False
if min_data_len is not None and data_len < min_data_len:
self.to_screen(u'\r[download] File is smaller than min-filesize (%s bytes < %s bytes). Aborting.' % (data_len, min_data_len))
return False
@@
-138,7
+133,7
@@
class HttpFD(FileDownloader):
return False
try:
stream.write(data_block)
return False
try:
stream.write(data_block)
- except (IOError, OSError):
+ except (IOError, OSError)
as err
:
self.to_stderr(u"\n")
self.report_error(u'unable to write data: %s' % str(err))
return False
self.to_stderr(u"\n")
self.report_error(u'unable to write data: %s' % str(err))
return False