hello guys i am trying to download video as two or more piece. so i have written program for that reason. it worked perfectly acurate like clock at bytes but there is problem when i download movie from start at middle point it works(playable) but other half does not work :D and why i don't understand can it be fixed? i will provide now program source code and u can play around
import pycurl
import time
from threading import Thread
global url
percent = 1000
total = 0
downloaded = 0
def run():
c = pycurl.Curl()
c.setopt(pycurl.URL,"http://some video link here.mp4")
fp= open("just file output name here.mp4", "wb")
c.setopt(pycurl.WRITEDATA, fp)
#range metter 1 megabyte is 1048576 byte just for knowladge
c.setopt(c.RANGE, '5242880-52428800')
c.setopt(c.NOPROGRESS, 0)
c.setopt(c.PROGRESSFUNCTION, progress)
c.setopt(pycurl.FOLLOWLOCATION, 0)
print("starting download,happy waiting..")
c.perform()
def progress(download_t, download_d, upload_t, upload_d):
global percent
global total
global downloaded
percent = (download_d+0.00000000001)/(download_t+0.000000000001)*100
total = (download_t/1048576)
downloaded = (download_d/1048576)
def main():
while percent != 101:
if percent != 1000:
try:
print ("downloaded",round(percent),"%","downloaded",round(downloaded),"from",round(total))
if percent == 100:
print("")
print("Download complete:")
break
time.sleep(2)
except:
print("unknown error")
if __name__ == "__main__":
t1 = Thread(target=run)
t1.start()
t2 = Thread(target=main)
t2.start()