Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f499cd

Browse files
Merge pull request avinashkranjan#1094 from noviicee/issue-1056
Added File Downloader
2 parents 7129b3d + 5178ec4 commit 5f499cd

File tree

3 files changed

+74
-0
lines changed

3 files changed

+74
-0
lines changed

‎File Downloader/Readme.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# File Downloader
2+
3+
This python script will help users to download any kind of files, irrespective of their size from the internet.<br>
4+
You just need to have the url and you are good to go!
5+
6+
## Setup instructions
7+
8+
Just run the python script.
9+
It will ask for the url of the file to be downloaded.
10+
After providing the url, the corresponding file will be downloaded in no time.
11+
12+
## Output
13+
14+
You will be able to see the status of the file being downloaded.
15+
16+
![output1](https://user-images.githubusercontent.com/72334601/119267747-83658f80-bc0d-11eb-95ec-7cf757a520e6.png)
17+
18+
![output2](https://user-images.githubusercontent.com/72334601/119267761-90827e80-bc0d-11eb-8b94-1eb81aaf487c.png)
19+
20+
![output3](https://user-images.githubusercontent.com/72334601/119267780-a5f7a880-bc0d-11eb-842a-c78cd74c6d7a.png)
21+
22+
![output_2_mp4](https://user-images.githubusercontent.com/72334601/119267771-9c6e4080-bc0d-11eb-93c6-4e21a2976a1a.PNG)
23+
24+
25+
The file will be stored locally after being downloaded.
26+
27+
## Author(s)
28+
29+
[Anamika](https://github.com/noviicee)

‎File Downloader/file_downloader.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
File Downloader
3+
4+
This python script will help users to download any kind of files, irrespective of their size from the internet.<br>
5+
You just need to have the url and you are good to go!
6+
"""
7+
import os
8+
import requests
9+
from tqdm import tqdm
10+
import math
11+
import time
12+
13+
url=input("Enter the url of the file you want to download: ")
14+
15+
r=requests.get(url)
16+
#receives data from the url
17+
18+
file_size=int(r.headers['Content-Length'])
19+
chunk_size=256
20+
21+
"""Chunk size is the
22+
number of bytes downloaded at a time
23+
"""
24+
25+
r=requests.get(url,stream=True)
26+
27+
"""streams=True ensures that
28+
will not get data at once, but will get data one by one
29+
30+
"""
31+
32+
extension=(os.path.splitext(url))[-1]
33+
file="file"+extension
34+
35+
iterations=math.ceil(file_size/chunk_size)
36+
37+
with open(file, "wb") as file:
38+
for chunk in tqdm(r.iter_content(chunk_size=chunk_size),total=iterations):
39+
time.sleep(0.5)
40+
file.write(chunk)

‎File Downloader/requirements.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
os
2+
requests
3+
tqdm
4+
math
5+
time

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /