Skip to content

Commit a66f8cb

Browse files
committed
Merge branch 'master' of https://github.com/chavarera/python-mini-projects into fetch_imdb_ratings
2 parents aa86c21 + 7081d5b commit a66f8cb

44 files changed

Lines changed: 778 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/blank.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ jobs:
3131
run: |
3232
echo Add other actions to build,
3333
echo test, and deploy your project.
34+

‎README.md‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Mini-Projects-Python
88

9-
[![All Contributors](https://img.shields.io/badge/all_contributors-41-blue.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-44-blue.svg?style=flat-square)](#contributors-)
1010
![Issues](https://img.shields.io/github/issues/chavarera/python-mini-projects)
1111
![Pull Requests](https://img.shields.io/github/issues-pr/chavarera/python-mini-projects?)
1212
![Forks](https://img.shields.io/github/forks/chavarera/python-mini-projects)
@@ -46,11 +46,15 @@ If you are new to Github and open source then, visit [here.](https://towardsdata
4646
git pull upstream master
4747
git push
4848
```
49-
- If you run into a **merge conflict**, you have to resolve the conflict. There are a lot of guides online, or you can try this one by [opensource.com](https://opensource.com/article/20/4/git-merge-conflict).
49+
50+
- If you run into a **merge conflict**, you have to resolve the conflict. There are a lot of guides online, or you can try this one by [opensource.com](https://opensource.com/article/20/4/git-merge-conflict).
51+
5052
- Checkout to development branch (*name your branch according to the issue name*).
53+
5154
```basg
5255
git checkout -b <branch-name>
5356
```
57+
5458
- Create a folder in [projects directory](https://github.com/chavarera/python-mini-projects/tree/master/projects) according to issue name.
5559
- Write your code and add to the respective folder in the projects directory, locally.
5660
- Don't forget to add a `README.md` in your folder, according to the [README_TEMPLATE.](https://github.com/chavarera/python-mini-projects/blob/master/README_TEMPLATE.md)
@@ -60,16 +64,19 @@ If you are new to Github and open source then, visit [here.](https://towardsdata
6064
git add -A
6165
git commit -m "<your message>"
6266
```
67+
6368
- Push the code *to your repository*.
69+
6470
```bash
6571
git push origin <branch-name>
6672
```
73+
6774
- Go to the GitHub page of _your fork_, and **make a pull request**:
6875
6976
![pull request image](https://help.github.com/assets/images/help/pull_requests/choose-base-and-compare-branches.png)
7077
7178
Read more about pull requests on the [GitHub help pages](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request).
72-
- Now wait, until one of us *reviews your Pull Request*! If there are any conflicts, you will get a notification.
79+
- Now wait, until one of us *reviews your Pull Request*! If there are any conflicts, you will get a notification.
7380
7481
## README Template for scripts
7582
@@ -150,7 +157,7 @@ SR No | Project | Author
150157
65 | [Test Internet Connection](https://github.com/chavarera/python-mini-projects/tree/master/projects/Internet_connection_check) | [Jacob Ogle](https://github.com/Jakeogle94)
151158
66 | [XKCD Comics Downloader](https://github.com/chavarera/python-mini-projects/tree/master/projects/XKCD_downloader)| [Aditya Jetely](https://github.com/AdityaJ7)
152159
67 | [Website Blocker And Unblocker](https://github.com/chavarera/python-mini-projects/tree/master/projects/Website_blocker)| [Phillibob55](https://github.com/Phillibob55)
153-
68 | [Fetch Domain Dns Record ](https://github.com/chavarera/python-mini-projects/tree/master/projects/Dns_record)| [Aditya Jetely](https://github.com/AdityaJ7)
160+
68 | [Fetch Domain Dns Record](https://github.com/chavarera/python-mini-projects/tree/master/projects/Dns_record)| [Aditya Jetely](https://github.com/AdityaJ7)
154161
69 | [Python-Auto-Draw](https://github.com/chavarera/python-mini-projects/tree/master/projects/Python_auto_draw)| [Tushar Nankani](https://github.com/tusharnankani)
155162
70 | [News Website Scraper](https://github.com/chavarera/python-mini-projects/tree/master/projects/News_website_scraper)| [pratik-choudhari](https://github.com/pratik-choudhari)
156163
71 | [Rock Paper Scissors Game](https://github.com/chavarera/python-mini-projects/tree/master/projects/RockPaperScissors_Game)| [Tushar Nankani](https://github.com/tusharnankani)
@@ -175,3 +182,9 @@ SR No | Project | Author
175182
90 | [Scrape Medium Articles](https://github.com/chavarera/python-mini-projects/tree/master/projects/Scraping%20Medium%20Articles)| [Naman Shah](https://github.com/namanshah01)
176183
91 | [HackerNews Scrapper](https://github.com/chavarera/python-mini-projects/tree/master/projects/Scrape_Hacker_News)| [Javokhirbek](https://github.com/leader2one)
177184
92 | [Reduce Image Size](https://github.com/chavarera/python-mini-projects/tree/master/projects/Reduce_image_file_size)| [Vipul Verma](https://github.com/VIPverma01)
185+
93 | [Easy Video Player](https://github.com/chavarera/python-mini-projects/tree/master/projects/EasyVideoPlayer)| [Bartu Yaman](https://github.com/brtymn)
186+
94 | [GeeksforGeeks Article downloader](https://github.com/chavarera/python-mini-projects/tree/master/projects/download%20GeeksForGeeks%20articles)| [Shiv Thakur](https://github.com/ShivSt)
187+
95 | [PDF to Text](https://github.com/chavarera/python-mini-projects/tree/master/projects/convert%20pdf%20to%20text)| [pi1814](https://github.com/pi1814)
188+
96 | [Unstructured Supplemenrary Service Data](https://github.com/chavarera/python-mini-projects/tree/master/projects/Unstructured%20Supplemenrary%20%20Service%20Data)| [ART](https://github.com/Tomyzon1728)
189+
97 | [Duplicate Files remover](https://github.com/chavarera/python-mini-projects/tree/master/projects/Duplicate%20files%20remover)| [Anandha Krishnan Aji](https://github.com/anandhakrishnanaji)
190+
98 | [PNG to ICO converter](https://github.com/chavarera/python-mini-projects/tree/master/projects/convert_png_images_to_ico_format)| [weicheansoo](https://github.com/weicheansoo)

‎docs/README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,9 @@ SR No | Project | Author
9797
90 | [Scrape Medium Articles](https://github.com/chavarera/python-mini-projects/tree/master/projects/Scraping%20Medium%20Articles)| [Naman Shah](https://github.com/namanshah01)
9898
91 | [HackerNews Scrapper](https://github.com/chavarera/python-mini-projects/tree/master/projects/Scrape_Hacker_News)| [Javokhirbek](https://github.com/leader2one)
9999
92 | [Reduce Image Size](https://github.com/chavarera/python-mini-projects/tree/master/projects/Reduce_image_file_size)| [Vipul Verma](https://github.com/VIPverma01)
100+
93 | [Easy Video Player](https://github.com/chavarera/python-mini-projects/tree/master/projects/EasyVideoPlayer)| [Bartu Yaman](https://github.com/brtymn)
101+
94 | [GeeksforGeeks Article downloader](https://github.com/chavarera/python-mini-projects/tree/master/projects/download%20GeeksForGeeks%20articles)| [Shiv Thakur](https://github.com/ShivSt)
102+
95 | [PDF to Text](https://github.com/chavarera/python-mini-projects/tree/master/projects/convert%20pdf%20to%20text)| [pi1814](https://github.com/pi1814)
103+
96 | [Unstructured Supplemenrary Service Data](https://github.com/chavarera/python-mini-projects/tree/master/projects/Unstructured%20Supplemenrary%20%20Service%20Data)| [ART](https://github.com/Tomyzon1728)
104+
97 | [Duplicate Files remover](https://github.com/chavarera/python-mini-projects/tree/master/projects/Duplicate%20files%20remover)| [Anandha Krishnan Aji](https://github.com/anandhakrishnanaji)
105+
98 | [PNG to ICO converter](https://github.com/chavarera/python-mini-projects/tree/master/projects/convert_png_images_to_ico_format)| [weicheansoo](https://github.com/weicheansoo)
-6.01 KB
Loading
-28.6 KB
Loading
-285 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Duplicate Files Remover
2+
This script removes duplicate files in the directory where the script runs.
3+
4+
### Prerequisites
5+
* No external libraries are used
6+
* os
7+
* hashlib
8+
9+
### How to run the script
10+
Execute `python3 duplicatefileremover.py`
11+
12+
### Screenshot/GIF showing the sample use of the script
13+
<!--Remove the below lines and add yours -->
14+
![Screenshot of the Output](Screenshot.png)
15+
16+
## Working
17+
The script first lists all the files in the directory. It takes MD5 hash of each file, when hash of 2 files become same it deletes the file.
18+
19+
## Author Name
20+
Anandha Krishnan Aji
138 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import hashlib
2+
import os
3+
4+
# Returns the hash string of the given file name
5+
6+
7+
def hashFile(filename):
8+
# For large files, if we read it all together it can lead to memory overflow, So we take a blocksize to read at a time
9+
BLOCKSIZE = 65536
10+
hasher = hashlib.md5()
11+
with open(filename, 'rb') as file:
12+
# Reads the particular blocksize from file
13+
buf = file.read(BLOCKSIZE)
14+
while(len(buf) > 0):
15+
hasher.update(buf)
16+
buf = file.read(BLOCKSIZE)
17+
return hasher.hexdigest()
18+
19+
20+
if __name__ == "__main__":
21+
# Dictionary to store the hash and filename
22+
hashMap = {}
23+
24+
# List to store deleted files
25+
deletedFiles = []
26+
filelist = [f for f in os.listdir() if os.path.isfile(f)]
27+
for f in filelist:
28+
key = hashFile(f)
29+
# If key already exists, it deletes the file
30+
if key in hashMap.keys():
31+
deletedFiles.append(f)
32+
os.remove(f)
33+
else:
34+
hashMap[key] = f
35+
if len(deletedFiles) == 0:
36+
print('Deleted Files')
37+
for i in deletedFiles:
38+
print(i)
39+
else:
40+
print('No duplicate files found')
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import cv2
2+
import os
3+
from pathlib import Path
4+
from ffpyplayer.player import MediaPlayer
5+
6+
7+
# User input for the name of the image file.
8+
video_name = input("Name of the video file that you want to play: ")
9+
10+
# User input for the path of the image file.
11+
video_directory_guess = input("Directory that may contain the video: ")
12+
13+
14+
# This function finds your file. If you don't know the directory just type '/'
15+
def find_the_video(file_name, directory_name):
16+
files_found = []
17+
for path, subdirs, files in os.walk(directory_name):
18+
for name in files:
19+
if(file_name == name):
20+
file_path = os.path.join(path, name)
21+
files_found.append(file_path)
22+
23+
print(files_found)
24+
return files_found[0] # Return the path.
25+
26+
27+
# Initialize the path of the image file.
28+
video_directory = Path(find_the_video(video_name, video_directory_guess))
29+
30+
# Initialize the parent directory of the image path.
31+
new_working_directory = video_directory.parent
32+
33+
# Change the working directory of the script.
34+
os.chdir(new_working_directory)
35+
36+
37+
video_path = find_the_video(video_name, video_directory_guess)
38+
39+
40+
def PlayVideo(video_path):
41+
42+
video = cv2.VideoCapture(video_path)
43+
player = MediaPlayer(video_path)
44+
45+
while True:
46+
grabbed, frame = video.read()
47+
audio_frame, val = player.get_frame()
48+
if not grabbed:
49+
print("End of video")
50+
break
51+
if cv2.waitKey(28) & 0xFF == ord("q"):
52+
break
53+
cv2.imshow("Video", frame)
54+
if val != 'eof' and audio_frame is not None:
55+
img, t = audio_frame
56+
video.release()
57+
cv2.destroyAllWindows()
58+
59+
60+
PlayVideo(video_path)

0 commit comments

Comments
 (0)