Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tarfile
- import requests
- class PDownload(object):
- def __init__(self, url):
- self.url = url
- self.current = 0
- self.session = requests.Session()
- def tell(self):
- return self.current
- def read(self, blocksize):
- req = self.session.get(self.url, headers={'Range': 'bytes=%s-%s'%(self.current, self.current+blocksize-1)})
- self.current += blocksize
- return req.content
- def seek(self, offset):
- self.current = offset
- if __name__ == '__main__':
- obj = PDownload('https://dimonb.com/.torrents/qqq.tar')
- tar = tarfile.TarFile(fileobj=obj)
- print tar.getmembers()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement