Skip to main content

A Python Asynchronous Downloader - pyaiodl

Project description

Python Asynchronous Downloader - pyaoidl

Don't Use it in Production or Live Projects Currently Its Unstable


Python 3.8 Maintenance PyPI license Open Source Love png3 Hits


Version

Beta badge

PyPI version

installation

pypi Method (recommanded)

pip3 install pyaiodl

Github repo method

pip3 install git+https://github.com/aryanvikash/pyaiodl.git

Avalible Methods

  • Downloader class Instance Non-blocking , params = [fake_useragent:bool,chunk_size:int ,download_path:str] optinals

      dl = Downloader()
    
  • Download [ download(self.url) ]

    uuid = await dl.download(url)
    
  • cancel [ cancel(self, uuid) ]

     await dl.cancel(uuid)
    
  • Get Status [ status(self, uuid) ]

      response = await dl.status(uuid)
      
      
      
      returns a dict
    
      """
      filename:str
      file_type :str
      total_size :int
      total_size_str : str
      downloaded :int
      downloaded_str :str
      progress:int
      download_speed:str
      active: bool
      complete :bool
      download_path:str
      """
    
  • is_active returns : bool [ is_active( self,uuid ) ] on cancel and download complete it will return False

      result = await dl.is_active(uuid)
    

Usage

Example :


import asyncio
from pyaiodl import Downloader

url = "https://speed.hetzner.de/100MB.bin"

async def main(url):
    dl = Downloader()

    try:
            #Non-blocking
        uuid = await dl.download(url)


        
        #progress
        while await dl.is_active(uuid):
        
            r = await dl.status(uuid)
            #cancel
            # await dl.cancel(uuid)
            print(f"""
        Filename: {r['filename']}
        Total : {r['total_size_str']}
        Downloaded : {r['downloaded_str']}
        Download Speed : {r['download_speed']}
        progress: {r['progress']}
         """)

            await asyncio.sleep(1)
        
        # Final filename / path
        print( "download completed : ",r['download_path'])


    except Exception as e:
        print(e)

asyncio.get_event_loop().run_until_complete(main(url))

known Bugs -

  • Error is Not Handled Correctly

TODO

  • Multipart Download
  • Queue Download / Pararrel Download Limit
  • Better Error Handling

Thanks ❤️


Powered badge

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyaiodl-0.0.3.tar.gz (7.6 kB view details)

Uploaded Source

File details

Details for the file pyaiodl-0.0.3.tar.gz.

File metadata

  • Download URL: pyaiodl-0.0.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

File hashes

Hashes for pyaiodl-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cf6e966927607c69152b0af3d391ea6625da405050556bd81a1db6bce0c6e34e
MD5 292b6c36619a9fb8384a93b977ccfe10
BLAKE2b-256 87dcbd9cdc1387a9cc863e7e7e40e61c29f0b7a449126e7537dcc1be19ccfd2c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page