pywebloader


Namepywebloader JSON
Version 1.3.1 PyPI version JSON
download
home_pagehttps://github.com/xzripper/PyLoader
SummaryImproves work with web files downloading.
upload_time2023-10-26 18:13:28
maintainer
docs_urlNone
authorIvan Perzhinsky.
requires_python
licenseMIT
keywords utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =========
PyLoader.
=========
Python library for downloading files by URL's. Fast and easy. Uses only Python STDLIB.

----------
Examples.
----------

~~~~~~~~~~~~~~~~
Simple download.
~~~~~~~~~~~~~~~~

.. code :: python

   from pyloader import PyLoader


   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'
   out = 'pic.png'

   file = PyLoader.download(url, out)

   print(f'{out} downloaded.')

.. image :: https://github.com/xzripper/PyLoader/blob/main/simple.gif?raw=true

~~~~~~~~~~~~~~~~~~~~~~~~~
No progress bar download.
~~~~~~~~~~~~~~~~~~~~~~~~~

.. code :: python

   from pyloader import PyLoader


   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'
   out = 'pic.png'

   file = PyLoader.pdownload(url, out)

   for data in file:
      print(PyLoader.util_format(data))


.. image :: https://github.com/xzripper/PyLoader/blob/main/nopb.gif?raw=true

~~~~~~~~~~~~~~~~~~
TQDM Progress Bar.
~~~~~~~~~~~~~~~~~~

.. code :: python

   from pyloader import PyLoader

   from tqdm import tqdm


   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'
   out = 'pic.png'

   pic = PyLoader.pdownload(url, out)

   progress_bar = tqdm()

   for download_info in pic:
      if download_info:
         if progress_bar.total == None:
               progress_bar.total = download_info['totalbytes']

        progress_bar.update(download_info['size_written'])

.. image :: https://github.com/xzripper/PyLoader/blob/main/withtqdm.gif?raw=true

As you see, using PyLoader is very easy.

--------------------------------------------------------------------

=======================
PyLoader Documentation.
=======================

.. code :: python

   # Static Functions & Variables (from pyloader import ...).
   VERSION = 1.0

   _percentage(current: int, maximal: int, _round: bool=False) -> int
   _convsize(_bytes: int, chunk: int=1024) -> str

   # PyLoader Functions & Variables (from pyloader import PyLoader).
   # All PyLoader functions and variables are static. It means you can call functions without initializing PyLoader.
   PyLoader.CHUNK = 1024

   PyLoader.temp_files = []

   @staticmethod PyLoader.download(url: str, out: str) -> bool
   @staticmethod PyLoader.pdownload(url: str, out: str, round_progress: bool=False) -> dict

   @staticmethod webfile(url: str, _type: str) -> str

   @staticmethod PyLoader.util_format(download_info: Union[bool, dict]) -> Union[bool, str]

   @staticmethod PyLoader.update_chunk(new_chunk: int) -> None

`VERSION`: Version of PyLoader.

`_percentage`: Calculate percentage. (_percentage:47, 100, True) -> 10%.<br>
`_convsize`: Converting bytes into another file sizes. (_convsize:1024) -> 1.0kb.

`PyLoader.CHUNK`: PyLoader default download chunk.

`PyLoader.temp_files`: Temporary files generated by `webfile`.

`PyLoader.download`: The "simple" download. Downloads file from URL into {out}. Already handles exceptions: HTTPError, URLError, SSLCertVerificationError, ValueError.

`PyLoader.pdownload`: Download file with ability to track things like: already downloaded percentage, downloaded bytes, file size, etc.

Yields ('yield [value]' in Python) dict with these values: 

percentage (downloaded percentage),
current_progress (current progress - downloaded bytes),
size_written (bytes was written in this chunk loading),
size (size of file),
totalbytes (size of file in bytes),
chunk (chunk),
time_wasted (wasted time to load chunk in nanoseconds),
success (is chunk loaded successfully).

Also handles exceptions: HTTPError, RequestHTTPError, RequestConnectionError, MissingSchema, (SSLError?).

`PyLoader.webfile`: Downloads file from URL and places downloaded into system temporary folder. Returns tuple with path to temporary file, is file downloaded successfully.
`PyLoader.clear_temp_files`: Clear temporary files generated by `webfile`.

`PyLoader.util_format`: Format download information. Converts dictionary with information to string. If ```download_info``` (first argument) is bool, function will return the same bool.

`PyLoader.update_chunk`: Update default PyLoader chunk.

-------
Notes.
-------
You can customize your progress bar just by using values from download information, you also can customize messages, etc by yourself, how to do it: `util_format` source code.
You also can use PyLoader static functions like _percentage, for your goals. These functions can be really useful.
Report any errors to project issues.

XXX: `GitHub. <github.com/xzripper/PyLoader>`_ 

----------------------------------------------

   **PyLoader MIT License v1.3.1.**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xzripper/PyLoader",
    "name": "pywebloader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "utility",
    "author": "Ivan Perzhinsky.",
    "author_email": "name1not1found.com@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/05/43/2c81118f750e8a2e90db1b8585148484365665660eb3412d2b9f4965d21c/pywebloader-1.3.1.tar.gz",
    "platform": null,
    "description": "=========\r\nPyLoader.\r\n=========\r\nPython library for downloading files by URL's. Fast and easy. Uses only Python STDLIB.\r\n\r\n----------\r\nExamples.\r\n----------\r\n\r\n~~~~~~~~~~~~~~~~\r\nSimple download.\r\n~~~~~~~~~~~~~~~~\r\n\r\n.. code :: python\r\n\r\n   from pyloader import PyLoader\r\n\r\n\r\n   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'\r\n   out = 'pic.png'\r\n\r\n   file = PyLoader.download(url, out)\r\n\r\n   print(f'{out} downloaded.')\r\n\r\n.. image :: https://github.com/xzripper/PyLoader/blob/main/simple.gif?raw=true\r\n\r\n~~~~~~~~~~~~~~~~~~~~~~~~~\r\nNo progress bar download.\r\n~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. code :: python\r\n\r\n   from pyloader import PyLoader\r\n\r\n\r\n   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'\r\n   out = 'pic.png'\r\n\r\n   file = PyLoader.pdownload(url, out)\r\n\r\n   for data in file:\r\n      print(PyLoader.util_format(data))\r\n\r\n\r\n.. image :: https://github.com/xzripper/PyLoader/blob/main/nopb.gif?raw=true\r\n\r\n~~~~~~~~~~~~~~~~~~\r\nTQDM Progress Bar.\r\n~~~~~~~~~~~~~~~~~~\r\n\r\n.. code :: python\r\n\r\n   from pyloader import PyLoader\r\n\r\n   from tqdm import tqdm\r\n\r\n\r\n   url = 'https://yt3.ggpht.com/1yafclomM37uN64INRwmmWPC7kT0OXwx6W5Or4JRs5eRrlGAXYD2x6thKfyrK_mf493GkScfUV5P7g=s742-nd-v1'\r\n   out = 'pic.png'\r\n\r\n   pic = PyLoader.pdownload(url, out)\r\n\r\n   progress_bar = tqdm()\r\n\r\n   for download_info in pic:\r\n      if download_info:\r\n         if progress_bar.total == None:\r\n               progress_bar.total = download_info['totalbytes']\r\n\r\n        progress_bar.update(download_info['size_written'])\r\n\r\n.. image :: https://github.com/xzripper/PyLoader/blob/main/withtqdm.gif?raw=true\r\n\r\nAs you see, using PyLoader is very easy.\r\n\r\n--------------------------------------------------------------------\r\n\r\n=======================\r\nPyLoader Documentation.\r\n=======================\r\n\r\n.. code :: python\r\n\r\n   # Static Functions & Variables (from pyloader import ...).\r\n   VERSION = 1.0\r\n\r\n   _percentage(current: int, maximal: int, _round: bool=False) -> int\r\n   _convsize(_bytes: int, chunk: int=1024) -> str\r\n\r\n   # PyLoader Functions & Variables (from pyloader import PyLoader).\r\n   # All PyLoader functions and variables are static. It means you can call functions without initializing PyLoader.\r\n   PyLoader.CHUNK = 1024\r\n\r\n   PyLoader.temp_files = []\r\n\r\n   @staticmethod PyLoader.download(url: str, out: str) -> bool\r\n   @staticmethod PyLoader.pdownload(url: str, out: str, round_progress: bool=False) -> dict\r\n\r\n   @staticmethod webfile(url: str, _type: str) -> str\r\n\r\n   @staticmethod PyLoader.util_format(download_info: Union[bool, dict]) -> Union[bool, str]\r\n\r\n   @staticmethod PyLoader.update_chunk(new_chunk: int) -> None\r\n\r\n`VERSION`: Version of PyLoader.\r\n\r\n`_percentage`: Calculate percentage. (_percentage:47, 100, True) -> 10%.<br>\r\n`_convsize`: Converting bytes into another file sizes. (_convsize:1024) -> 1.0kb.\r\n\r\n`PyLoader.CHUNK`: PyLoader default download chunk.\r\n\r\n`PyLoader.temp_files`: Temporary files generated by `webfile`.\r\n\r\n`PyLoader.download`: The \"simple\" download. Downloads file from URL into {out}. Already handles exceptions: HTTPError, URLError, SSLCertVerificationError, ValueError.\r\n\r\n`PyLoader.pdownload`: Download file with ability to track things like: already downloaded percentage, downloaded bytes, file size, etc.\r\n\r\nYields ('yield [value]' in Python) dict with these values: \r\n\r\npercentage (downloaded percentage),\r\ncurrent_progress (current progress - downloaded bytes),\r\nsize_written (bytes was written in this chunk loading),\r\nsize (size of file),\r\ntotalbytes (size of file in bytes),\r\nchunk (chunk),\r\ntime_wasted (wasted time to load chunk in nanoseconds),\r\nsuccess (is chunk loaded successfully).\r\n\r\nAlso handles exceptions: HTTPError, RequestHTTPError, RequestConnectionError, MissingSchema, (SSLError?).\r\n\r\n`PyLoader.webfile`: Downloads file from URL and places downloaded into system temporary folder. Returns tuple with path to temporary file, is file downloaded successfully.\r\n`PyLoader.clear_temp_files`: Clear temporary files generated by `webfile`.\r\n\r\n`PyLoader.util_format`: Format download information. Converts dictionary with information to string. If ```download_info``` (first argument) is bool, function will return the same bool.\r\n\r\n`PyLoader.update_chunk`: Update default PyLoader chunk.\r\n\r\n-------\r\nNotes.\r\n-------\r\nYou can customize your progress bar just by using values from download information, you also can customize messages, etc by yourself, how to do it: `util_format` source code.\r\nYou also can use PyLoader static functions like _percentage, for your goals. These functions can be really useful.\r\nReport any errors to project issues.\r\n\r\nXXX: `GitHub. <github.com/xzripper/PyLoader>`_ \r\n\r\n----------------------------------------------\r\n\r\n   **PyLoader MIT License v1.3.1.**\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Improves work with web files downloading.",
    "version": "1.3.1",
    "project_urls": {
        "Download": "https://github.com/xzripper/PyLoader/archive/refs/tags/v1.3.1.tar.gz",
        "Homepage": "https://github.com/xzripper/PyLoader"
    },
    "split_keywords": [
        "utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05432c81118f750e8a2e90db1b8585148484365665660eb3412d2b9f4965d21c",
                "md5": "56380d2ac2222c1af0b95320fab39d5d",
                "sha256": "44bb63a1f6e2b3643accc6cf4f48fa1b6fca15d08c47fdd3bace927c1ebc9d4f"
            },
            "downloads": -1,
            "filename": "pywebloader-1.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "56380d2ac2222c1af0b95320fab39d5d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5195,
            "upload_time": "2023-10-26T18:13:28",
            "upload_time_iso_8601": "2023-10-26T18:13:28.707556Z",
            "url": "https://files.pythonhosted.org/packages/05/43/2c81118f750e8a2e90db1b8585148484365665660eb3412d2b9f4965d21c/pywebloader-1.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-26 18:13:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xzripper",
    "github_project": "PyLoader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pywebloader"
}
        
Elapsed time: 0.31568s