Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Sep 7, 2024
1 parent 2d6a0c9 commit 1bfc734
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Each option is explained below:

### Examples

Here is an example that demonstrates how to use pypdl library to download a file using headers, proxies, timeout and authentication:
Here is an example that demonstrates how to use pypdl library to download a file using headers, proxy and timeout:

```py
import aiohttp
Expand All @@ -87,19 +87,13 @@ from pypdl import Pypdl
def main():
# Using headers
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"}
# Using proxies
proxies = {
"http": "http://10.10.1.10:3128",
"https": "https://10.10.1.10:1080",
}
# Using authentication
auth = ("user","pass")

# Using proxy
proxy = "http://user:[email protected]"
# Using timeout
timeout = aiohttp.ClientTimeout(sock_read=20)

# create a new pypdl object
dl = Pypdl(headers=headers, proxies=proxies, timeout=timeout, auth=auth)
dl = Pypdl(headers=headers, proxy=proxy, timeout=timeout)

# start the download
dl.start(
Expand All @@ -118,7 +112,7 @@ if __name__ == '__main__':
main()
```

This example downloads a file from the internet using 10 segments and displays the download progress. If the download fails, it will retry up to 3 times. we are also using headers, proxies and authentication.
This example downloads a file from the internet using 10 segments and displays the download progress. If the download fails, it will retry up to 3 times. we are also using headers, proxy and timeout, For more info regarding these parameters refer [API reference](https://github.com/mjishnu/pypdl?tab=readme-ov-file#pypdl-1)

Another example of implementing pause resume functionality, printing the progress to console and changing log level to debug:

Expand Down Expand Up @@ -241,10 +235,10 @@ An example of using `PypdlFactory` to download multiple files concurrently:
```py
from pypdl import PypdlFactory

proxies = {"http": "http://10.10.1.10:3128", "https": "https://10.10.1.10:1080"}
proxy = "http://user:[email protected]"

# create a PypdlFactory object
factory = PypdlFactory(instances=5, allow_reuse=True, proxies=proxies)
factory = PypdlFactory(instances=5, allow_reuse=True, proxy=proxy)

# List of tasks to be downloaded. Each task is a tuple of (URL, {Pypdl arguments}).
# - URL: The download link (string).
Expand Down Expand Up @@ -294,6 +288,7 @@ factory.start(task2, display=True, block=True)
# shutdown the downloader, this is essential when allow_reuse is enabled
factory.shutdown()
```
For more detailed info about parameters refer [API reference](https://github.com/mjishnu/pypdl?tab=readme-ov-file#pypdlfactory)
## API Reference

### `Pypdl()`
Expand Down

0 comments on commit 1bfc734

Please sign in to comment.