python - How to join downloaded file parts -
so , trying download single file in parts using python threading
module , requests
download.
now thing able download file 4 separate parts not able join them.
i tried using pypdf2
join pdf , ffmpeg
join video files no help. not able open of downloaded files explains not getting downloaded correctly.
pypdf2
giving error
pdfreaderror: eof marker not found
what should that able join files correctly.
secondly , have use seperate methods join them, or can implement 1 method can used different file formats
below download
function implemented.
def download(threadid, drange, url): headers = {"range":"bytes={0}-{1}".format(drange[0], drange[1])} print headers size = drange[1] - drange[0] print "starting thread {0}".format(threadid) req = requests.get(url, headers=headers, stream=true) download_status[size] = size download_status[threadid] = 0 # return req open('test{0}.mp4'.format(threadid), 'wb') f: r in pr.bar(req.iter_content(chunk_size=2048), expected_size=(size/2048)+1): if r: f.write(r) f.flush()
Comments
Post a Comment