Python fast downloader
Project description
INSTALLATION
pip install aioxdl
USAGE
import time
import asyncio
from aioxdl.modules import Aioxdl
from aioxdl.modules import Filename
async def progress(tsize, dsize, stime):
# stime = start_time
# tsize = total_size
# dsize = download_size
percentage = round((dsize / tsize) * 100, 2)
print("\rCOMPLETED : {}%".format(percentage), end="", flush=True)
async def main():
core = Aioxdl(timeout=2000)
link = "https://example.link/file.txt"
loca = await Filename.filename(link)
file = await core.download(link, loca.result, progress=progress, progress_args=(time.time()))
fine = file.result if file.errors == None else file.errors
print(fine)
asyncio.run(main())
GET FILENAME
from aioxdl.modules import Filename
async def main():
link = "https://example.link/file.txt"
name = await Filename.get(link)
print(name.result)
asyncio.run(main())
STOP DOWNLOAD
import time
import asyncio
from aioxdl.modules import Aioxdl
from aioxdl.modules import Filename
from aioxdl.functions import Cancelled
TASK_ID = []
async def progress(tsize, dsize, stime, tuid):
# stime = start_time
# tsize = total_size
# dsize = download_size
if tuid in TASK_ID:
percentage = round((dsize / tsize) * 100, 2)
print("\rCOMPLETED : {}%".format(percentage), end="", flush=True)
else:
raise Cancelled("Cancelled ❌")
async def main():
tims = time.time()
tuid = 1234567890
TASK_ID.append(tuid)
core = Aioxdl(timeout=2000)
link = "https://example.uri/file.txt"
loca = await Filename.filename(link)
file = await core.download(link, loca.result,
progress=progress, progress_args=(tims, tuid))
if file.status == 400:
print(file.errors)
elif file.status == 300:
print("Cancelled ❌")
else:
print(fine.result)
asyncio.run(main())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioxdl-0.0.30.tar.gz
(9.1 kB
view hashes)
Built Distribution
aioxdl-0.0.30-py3-none-any.whl
(10.0 kB
view hashes)