Skip to content

Commit 5e9fe3c

Browse files
authored
Merge pull request #164 from Naman23-coder/patch-1
Patch 1
2 parents 468585e + 86aacda commit 5e9fe3c

File tree

7 files changed

+42
-20
lines changed

7 files changed

+42
-20
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ If applicable, add Screenshots to help explain your Problem
2424
- OS: [e.g. Windows 10]
2525
- Browser: [e.g. Microsoft Edge, Google Chrome]
2626
- Python: [e.g. 3.10.0]
27-
- PyWhatKit: [e.g. 5.1]
27+
- PyWhatKit: [e.g. 5.2]
2828

2929
You can Check the PyWhatKit Version using
3030

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Ankit Raj Mahapatra
3+
Copyright (c) 2019-present Ankit Raj Mahapatra
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
![image](https://media.discordapp.net/attachments/842794167134453820/882227960613048350/unknown.png?width=1440&height=420)
22

3-
![image](https://flat.badgen.net/github/stars/Ankit404butfound/Pywhatkit)
4-
![image](https://flat.badgen.net/github/forks/Ankit404butfound/Pywhatkit)
5-
![image](https://flat.badgen.net/github/open-issues/Ankit404butfound/Pywhatkit)
6-
![image](https://flat.badgen.net/github/open-prs/Ankit404butfound/Pywhatkit)
7-
![image](https://flat.badgen.net/github/commits/Ankit404butfound/Pywhatkit)
8-
![image](https://flat.badgen.net/github/license/Ankit404butfound/Pywhatkit)
9-
![image](https://flat.badgen.net/github/contributors/Ankit404butfound/Pywhatkit)
10-
![image](https://flat.badgen.net/github/release/Ankit404butfound/Pywhatkit)
3+
[![image](https://flat.badgen.net/github/stars/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/stargazers)
4+
[![image](https://flat.badgen.net/github/forks/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/network/members)
5+
[![image](https://flat.badgen.net/github/open-issues/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/issues)
6+
[![image](https://flat.badgen.net/github/open-prs/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/pulls)
7+
[![image](https://flat.badgen.net/github/commits/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/commits/master)
8+
[![image](https://flat.badgen.net/github/license/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/LICENCE)
9+
[![image](https://flat.badgen.net/github/contributors/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/graphs/contributors)
10+
[![image](https://flat.badgen.net/github/release/Ankit404butfound/Pywhatkit)](https://github.com/Ankit404butfound/PyWhatKit/releases)
1111
<!-- ![logo](https://github.com/Ankit404butfound/PyWhatKit/raw/master/Images/logo.png?raw=true) -->
1212

1313
[PyWhatKit](https://pypi.org/project/pywhatkit/) is a Python library with various helpful features. It's easy-to-use and does not require you to do any additional setup. Currently, it has about 300k+ downloads and counting. New updates are released frequently with new features and bug fixes.

pywhatkit/core/exceptions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ class UnsupportedEmailProvider(Exception):
2828
"""
2929

3030
pass
31+
32+
33+
class UnableToAccessApi(Exception):
34+
"""unable to access pywhatkit api"""
35+
36+
pass

pywhatkit/handwriting.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import requests
22

3+
from pywhatkit.core import exceptions
4+
35

46
def text_to_handwriting(
57
string: str, save_to: str = "pywhatkit.png", rgb: tuple = (0, 0, 0)
@@ -8,7 +10,13 @@ def text_to_handwriting(
810

911
data = requests.get(
1012
f"https://pywhatkit.herokuapp.com/handwriting?text={string}&rgb={rgb[0]},{rgb[1]},{rgb[2]}"
11-
).content
12-
with open(save_to, "wb") as file:
13-
file.write(data)
14-
file.close()
13+
)
14+
status_code = (
15+
data.status_code
16+
) # source = https://www.geeksforgeeks.org/http-status-codes-successful-responses/
17+
if status_code == 200:
18+
with open(save_to, "wb") as file:
19+
file.write(data.content)
20+
file.close()
21+
elif 400 <= status_code <= 599:
22+
raise exceptions.UnableToAccessApi("Unable to access Pywhatkit api right now")

pywhatkit/misc.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
import requests
88
import wikipedia
99

10+
from pywhatkit.core import exceptions
11+
1012
if system().lower() in ("windows", "darwin"):
1113
from PIL import ImageGrab
1214

1315
def take_screenshot(
14-
file_name: str = "pywhatkit_screenshot", delay: int = 2
16+
file_name: str = "pywhatkit_screenshot", delay: int = 2, show: bool = True
1517
) -> None:
1618
"""Take Screenshot of the Screen"""
1719

1820
time.sleep(delay)
1921
screen = ImageGrab.grab()
20-
screen.show(title=file_name)
22+
if show:
23+
screen.show(title=file_name)
2124
screen.save(f"{file_name}.png")
2225

2326

@@ -69,9 +72,15 @@ def playonyt(topic: str, use_api: bool = False, open_video: bool = True) -> str:
6972
response = requests.get(
7073
f"https://pywhatkit.herokuapp.com/playonyt?topic={topic}"
7174
)
72-
if open_video:
73-
web.open(response.content.decode("ascii"))
74-
return response.content.decode("ascii")
75+
status_code = response.status_code
76+
if status_code == 200:
77+
if open_video:
78+
web.open(response.content.decode("ascii"))
79+
return response.content.decode("ascii")
80+
elif 400 <= status_code <= 599:
81+
raise exceptions.UnableToAccessApi(
82+
"Unable to access pywhatkit api right now"
83+
)
7584
else:
7685
url = f"https://www.youtube.com/results?q={topic}"
7786
count = 0

pywhatkit/py.typed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

0 commit comments

Comments
 (0)