PandaAPI 1.0.1__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PKG-INFO +2 -2
- pandaapi-1.0.3/PandaAPI/modules/ai.py +59 -0
- pandaapi-1.0.3/PandaAPI/modules/tools.py +262 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI.egg-info/PKG-INFO +2 -2
- {pandaapi-1.0.1 → pandaapi-1.0.3}/pyproject.toml +2 -2
- pandaapi-1.0.1/PandaAPI/modules/ai.py +0 -59
- pandaapi-1.0.1/PandaAPI/modules/tools.py +0 -259
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI/__init__.py +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI/func.py +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI/modules/__init__.py +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI/modules/media.py +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI/modules/telegram.py +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI.egg-info/SOURCES.txt +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI.egg-info/dependency_links.txt +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI.egg-info/requires.txt +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/PandaAPI.egg-info/top_level.txt +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/README.md +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/setup.cfg +0 -0
- {pandaapi-1.0.1 → pandaapi-1.0.3}/setup.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PandaAPI
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Python utility hub by @ll_PANDA_BBY_ll
|
|
5
5
|
Author: PANDA
|
|
6
6
|
Author-email:
|
|
7
|
-
License: MIT
|
|
7
|
+
License-Expression: MIT
|
|
8
8
|
Keywords: python,PandaAPI,telegram,bot
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
GEMINI_KEY = "AQ.Ab8RN6JORDWFSVSJUzMxcmvKqCA4qW5GBJMwDicXWun9vGsPpQ"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def gemini(prompt: str) -> dict:
|
|
9
|
+
url = (
|
|
10
|
+
"https://generativelanguage.googleapis.com/v1beta/models/"
|
|
11
|
+
f"gemini-2.0-flash:generateContent?key={GEMINI_KEY}"
|
|
12
|
+
)
|
|
13
|
+
payload = {"contents": [{"parts": [{"text": prompt}]}]}
|
|
14
|
+
try:
|
|
15
|
+
r = requests.post(
|
|
16
|
+
url,
|
|
17
|
+
headers={"Content-Type": "application/json"},
|
|
18
|
+
data=json.dumps(payload),
|
|
19
|
+
timeout=15,
|
|
20
|
+
)
|
|
21
|
+
if r.status_code == 200:
|
|
22
|
+
text = r.json()["candidates"][0]["content"]["parts"][0]["text"]
|
|
23
|
+
return {"result": text, "success": True}
|
|
24
|
+
# fallback to pollinations if key fails
|
|
25
|
+
r2 = requests.get(
|
|
26
|
+
f"https://text.pollinations.ai/{requests.utils.quote(prompt)}?model=openai",
|
|
27
|
+
timeout=20,
|
|
28
|
+
)
|
|
29
|
+
if r2.status_code == 200:
|
|
30
|
+
return {"result": r2.text.strip(), "success": True}
|
|
31
|
+
return {"success": False, "error": r.text}
|
|
32
|
+
except Exception as e:
|
|
33
|
+
return {"success": False, "error": str(e)}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def chatgpt(prompt: str) -> dict:
|
|
37
|
+
try:
|
|
38
|
+
r = requests.get(
|
|
39
|
+
f"https://text.pollinations.ai/{requests.utils.quote(prompt)}?model=openai",
|
|
40
|
+
timeout=20,
|
|
41
|
+
)
|
|
42
|
+
if r.status_code == 200:
|
|
43
|
+
return {"result": r.text.strip(), "success": True}
|
|
44
|
+
return {"success": False, "error": f"Status {r.status_code}"}
|
|
45
|
+
except Exception as e:
|
|
46
|
+
return {"success": False, "error": str(e)}
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def blackbox(prompt: str) -> dict:
|
|
50
|
+
try:
|
|
51
|
+
r = requests.get(
|
|
52
|
+
f"https://text.pollinations.ai/{requests.utils.quote(prompt)}?model=mistral",
|
|
53
|
+
timeout=20,
|
|
54
|
+
)
|
|
55
|
+
if r.status_code == 200:
|
|
56
|
+
return {"result": r.text.strip(), "success": True}
|
|
57
|
+
return {"success": False, "error": f"Status {r.status_code}"}
|
|
58
|
+
except Exception as e:
|
|
59
|
+
return {"success": False, "error": str(e)}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import random
|
|
2
|
+
import string
|
|
3
|
+
import requests
|
|
4
|
+
from bs4 import BeautifulSoup
|
|
5
|
+
from ..func import MORSE_CODE_DICT
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def password(length: int = 12) -> str:
|
|
9
|
+
chars = string.ascii_letters + string.punctuation + string.digits
|
|
10
|
+
return "".join(random.sample(chars, length))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def morse_encode(text: str) -> dict:
|
|
14
|
+
cipher = ""
|
|
15
|
+
for ch in text.upper():
|
|
16
|
+
if ch == " ":
|
|
17
|
+
cipher += " "
|
|
18
|
+
elif ch in MORSE_CODE_DICT:
|
|
19
|
+
cipher += MORSE_CODE_DICT[ch] + " "
|
|
20
|
+
return {"input": text, "result": cipher.strip(), "success": True}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def morse_decode(code: str) -> dict:
|
|
24
|
+
code += " "
|
|
25
|
+
decipher = ""
|
|
26
|
+
citext = ""
|
|
27
|
+
i = 0
|
|
28
|
+
for ch in code:
|
|
29
|
+
if ch != " ":
|
|
30
|
+
i = 0
|
|
31
|
+
citext += ch
|
|
32
|
+
else:
|
|
33
|
+
i += 1
|
|
34
|
+
if i == 2:
|
|
35
|
+
decipher += " "
|
|
36
|
+
else:
|
|
37
|
+
key = next(
|
|
38
|
+
(k for k, v in MORSE_CODE_DICT.items() if v == citext), "?"
|
|
39
|
+
)
|
|
40
|
+
decipher += key
|
|
41
|
+
citext = ""
|
|
42
|
+
return {"input": code.strip(), "result": decipher, "success": True}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def github(username: str) -> dict:
|
|
46
|
+
r = requests.get(f"https://api.github.com/users/{username}").json()
|
|
47
|
+
return {
|
|
48
|
+
"name": r.get("name"),
|
|
49
|
+
"username": r.get("login"),
|
|
50
|
+
"id": r.get("id"),
|
|
51
|
+
"bio": r.get("bio"),
|
|
52
|
+
"location": r.get("location"),
|
|
53
|
+
"repos": r.get("public_repos"),
|
|
54
|
+
"followers": r.get("followers"),
|
|
55
|
+
"following": r.get("following"),
|
|
56
|
+
"avatar": r.get("avatar_url"),
|
|
57
|
+
"url": r.get("html_url"),
|
|
58
|
+
"success": True,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def pypi(package: str) -> dict:
|
|
63
|
+
r = requests.get(f"https://pypi.org/pypi/{package}/json").json()
|
|
64
|
+
info = r.get("info", {})
|
|
65
|
+
return {
|
|
66
|
+
"name": info.get("name"),
|
|
67
|
+
"version": info.get("version"),
|
|
68
|
+
"summary": info.get("summary"),
|
|
69
|
+
"author": info.get("author"),
|
|
70
|
+
"license": info.get("license"),
|
|
71
|
+
"home_page": info.get("home_page"),
|
|
72
|
+
"success": True,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def hashtag(keyword: str) -> dict:
|
|
77
|
+
try:
|
|
78
|
+
# using ritetag API (no auth needed for basic)
|
|
79
|
+
url = f"https://ritetag.com/best-hashtags-for/{requests.utils.quote(keyword)}"
|
|
80
|
+
headers = {"User-Agent": "Mozilla/5.0"}
|
|
81
|
+
r = requests.get(url, headers=headers, timeout=10)
|
|
82
|
+
soup = BeautifulSoup(r.text, "html.parser")
|
|
83
|
+
tags = []
|
|
84
|
+
for el in soup.select(".hashtag-text, .tag, span.ht"):
|
|
85
|
+
t = el.text.strip()
|
|
86
|
+
if t.startswith("#"):
|
|
87
|
+
tags.append(t)
|
|
88
|
+
if not tags:
|
|
89
|
+
# fallback: generate basic hashtags
|
|
90
|
+
words = keyword.lower().split()
|
|
91
|
+
tags = [
|
|
92
|
+
f"#{keyword.replace(' ', '')}",
|
|
93
|
+
f"#{keyword.replace(' ', '_')}",
|
|
94
|
+
] + [f"#{w}" for w in words]
|
|
95
|
+
return {"input": keyword, "results": tags[:20], "success": True}
|
|
96
|
+
except Exception as e:
|
|
97
|
+
return {"success": False, "error": str(e)}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def chatbot(text: str) -> dict:
|
|
101
|
+
try:
|
|
102
|
+
r = requests.get(
|
|
103
|
+
f"https://text.pollinations.ai/{requests.utils.quote(text)}",
|
|
104
|
+
timeout=20,
|
|
105
|
+
)
|
|
106
|
+
if r.status_code == 200:
|
|
107
|
+
return {"result": r.text.strip(), "success": True}
|
|
108
|
+
return {"success": False, "error": f"Status {r.status_code}"}
|
|
109
|
+
except Exception as e:
|
|
110
|
+
return {"success": False, "error": str(e)}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def meme() -> dict:
|
|
114
|
+
try:
|
|
115
|
+
r = requests.get("https://meme-api.com/gimme", timeout=10).json()
|
|
116
|
+
return {
|
|
117
|
+
"title": r.get("title"),
|
|
118
|
+
"url": r.get("url"),
|
|
119
|
+
"subreddit": r.get("subreddit"),
|
|
120
|
+
"author": r.get("author"),
|
|
121
|
+
"success": True,
|
|
122
|
+
}
|
|
123
|
+
except Exception as e:
|
|
124
|
+
return {"success": False, "error": str(e)}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def unsplash(query: str) -> dict:
|
|
128
|
+
try:
|
|
129
|
+
url = f"https://source.unsplash.com/featured/?{requests.utils.quote(query)}"
|
|
130
|
+
r = requests.get(url, timeout=10, allow_redirects=True)
|
|
131
|
+
# unsplash source redirects to actual image
|
|
132
|
+
final_url = r.url
|
|
133
|
+
# also fetch a few via scraping picsum/unsplash search
|
|
134
|
+
search_url = f"https://unsplash.com/s/photos/{requests.utils.quote(query)}"
|
|
135
|
+
headers = {"User-Agent": "Mozilla/5.0"}
|
|
136
|
+
rs = requests.get(search_url, headers=headers, timeout=10)
|
|
137
|
+
soup = BeautifulSoup(rs.text, "html.parser")
|
|
138
|
+
imgs = []
|
|
139
|
+
for img in soup.find_all("img"):
|
|
140
|
+
src = img.get("src", "")
|
|
141
|
+
if "images.unsplash.com" in src:
|
|
142
|
+
imgs.append(src)
|
|
143
|
+
if len(imgs) >= 10:
|
|
144
|
+
break
|
|
145
|
+
if not imgs:
|
|
146
|
+
imgs = [final_url]
|
|
147
|
+
return {"results": imgs, "success": True}
|
|
148
|
+
except Exception as e:
|
|
149
|
+
return {"success": False, "error": str(e)}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def imdb(query: str) -> dict:
|
|
153
|
+
try:
|
|
154
|
+
headers = {
|
|
155
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
|
|
156
|
+
"Accept-Language": "en-US,en;q=0.9",
|
|
157
|
+
}
|
|
158
|
+
# use OMDB-style scrape via IMDB search JSON endpoint
|
|
159
|
+
search_url = f"https://v2.sg.media-imdb.com/suggestion/x/{requests.utils.quote(query)}.json"
|
|
160
|
+
r = requests.get(search_url, headers=headers, timeout=10)
|
|
161
|
+
data = r.json()
|
|
162
|
+
results = data.get("d", [])
|
|
163
|
+
if not results:
|
|
164
|
+
return {"success": False, "error": "No results"}
|
|
165
|
+
top = results[0]
|
|
166
|
+
imdb_id = top.get("id", "")
|
|
167
|
+
title = top.get("l", "")
|
|
168
|
+
year = top.get("y", "")
|
|
169
|
+
image = top.get("i", {}).get("imageUrl", "") if isinstance(top.get("i"), dict) else ""
|
|
170
|
+
rank = top.get("rank", "")
|
|
171
|
+
# fetch detail page for more info
|
|
172
|
+
detail_url = f"https://www.imdb.com/title/{imdb_id}/"
|
|
173
|
+
rd = requests.get(detail_url, headers=headers, timeout=10)
|
|
174
|
+
soup = BeautifulSoup(rd.text, "html.parser")
|
|
175
|
+
import json as _json
|
|
176
|
+
description = ""
|
|
177
|
+
genre = []
|
|
178
|
+
actors = []
|
|
179
|
+
rating = ""
|
|
180
|
+
script = soup.find("script", type="application/ld+json")
|
|
181
|
+
if script:
|
|
182
|
+
ld = _json.loads(script.string)
|
|
183
|
+
description = ld.get("description", "")
|
|
184
|
+
genre = ld.get("genre", [])
|
|
185
|
+
actors = [a["name"] for a in ld.get("actor", [])]
|
|
186
|
+
rating = ld.get("aggregateRating", {}).get("ratingValue", "")
|
|
187
|
+
return {
|
|
188
|
+
"name": title,
|
|
189
|
+
"year": year,
|
|
190
|
+
"imdb_id": imdb_id,
|
|
191
|
+
"image": image,
|
|
192
|
+
"url": detail_url,
|
|
193
|
+
"description": description,
|
|
194
|
+
"genre": genre,
|
|
195
|
+
"actors": actors,
|
|
196
|
+
"rating": rating,
|
|
197
|
+
"success": True,
|
|
198
|
+
}
|
|
199
|
+
except Exception as e:
|
|
200
|
+
return {"success": False, "error": str(e)}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def leetcode(username: str) -> dict:
|
|
204
|
+
url = "https://leetcode.com/graphql/"
|
|
205
|
+
q2 = {
|
|
206
|
+
"operationName": "userPublicProfile",
|
|
207
|
+
"query": """
|
|
208
|
+
query userPublicProfile($username: String!) {
|
|
209
|
+
matchedUser(username: $username) {
|
|
210
|
+
username
|
|
211
|
+
githubUrl
|
|
212
|
+
twitterUrl
|
|
213
|
+
linkedinUrl
|
|
214
|
+
submitStats {
|
|
215
|
+
acSubmissionNum {
|
|
216
|
+
difficulty
|
|
217
|
+
count
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
profile {
|
|
221
|
+
ranking
|
|
222
|
+
userAvatar
|
|
223
|
+
realName
|
|
224
|
+
countryName
|
|
225
|
+
company
|
|
226
|
+
jobTitle
|
|
227
|
+
skillTags
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}""",
|
|
231
|
+
"variables": {"username": username},
|
|
232
|
+
}
|
|
233
|
+
try:
|
|
234
|
+
headers = {"Content-Type": "application/json", "Referer": "https://leetcode.com"}
|
|
235
|
+
r2 = requests.post(url, json=q2, headers=headers, timeout=10).json()
|
|
236
|
+
user = r2.get("data", {}).get("matchedUser")
|
|
237
|
+
if not user:
|
|
238
|
+
return {"success": False, "error": "User not found"}
|
|
239
|
+
return {**user, "success": True}
|
|
240
|
+
except Exception as e:
|
|
241
|
+
return {"success": False, "error": str(e)}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def bhagwatgita(chapter: int, shalok: int = 1) -> dict:
|
|
245
|
+
try:
|
|
246
|
+
# use bhagavad-gita.org API
|
|
247
|
+
url = f"https://bhagavad-gita3.p.rapidapi.com/v2/chapters/{chapter}/verses/{shalok}/"
|
|
248
|
+
# fallback to free API
|
|
249
|
+
url = f"https://vedicscriptures.github.io/slok/{chapter}/{shalok}/"
|
|
250
|
+
r = requests.get(url, timeout=10)
|
|
251
|
+
data = r.json()
|
|
252
|
+
return {
|
|
253
|
+
"chapter": chapter,
|
|
254
|
+
"shloka": shalok,
|
|
255
|
+
"slok": data.get("slok", ""),
|
|
256
|
+
"transliteration": data.get("transliteration", ""),
|
|
257
|
+
"hindi": data.get("tej", {}).get("ht", ""),
|
|
258
|
+
"english": data.get("siva", {}).get("et", ""),
|
|
259
|
+
"success": True,
|
|
260
|
+
}
|
|
261
|
+
except Exception as e:
|
|
262
|
+
return {"success": False, "error": str(e)}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PandaAPI
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Python utility hub by @ll_PANDA_BBY_ll
|
|
5
5
|
Author: PANDA
|
|
6
6
|
Author-email:
|
|
7
|
-
License: MIT
|
|
7
|
+
License-Expression: MIT
|
|
8
8
|
Keywords: python,PandaAPI,telegram,bot
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "PandaAPI"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.3"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name = "PANDA" }
|
|
10
10
|
]
|
|
11
11
|
description = "Python utility hub by @ll_PANDA_BBY_ll"
|
|
12
12
|
readme = "README.md"
|
|
13
|
-
license =
|
|
13
|
+
license = "MIT"
|
|
14
14
|
requires-python = ">=3.8"
|
|
15
15
|
keywords = ["python", "PandaAPI", "telegram", "bot"]
|
|
16
16
|
classifiers = [
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import requests
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def gemini(prompt: str) -> dict:
|
|
6
|
-
url = (
|
|
7
|
-
"https://generativelanguage.googleapis.com/v1beta/models/"
|
|
8
|
-
"gemini-pro:generateContent"
|
|
9
|
-
"?key=AIzaSyBQaoUF-KWjPV_4ABtSN0DQ0RPkNeCh4tM"
|
|
10
|
-
)
|
|
11
|
-
payload = {"contents": [{"parts": [{"text": prompt}]}]}
|
|
12
|
-
try:
|
|
13
|
-
r = requests.post(url, headers={"Content-Type": "application/json"},
|
|
14
|
-
data=json.dumps(payload))
|
|
15
|
-
if r.status_code == 200:
|
|
16
|
-
text = r.json()["candidates"][0]["content"]["parts"][0]["text"]
|
|
17
|
-
return {"result": text, "success": True}
|
|
18
|
-
return {"success": False, "error": r.text}
|
|
19
|
-
except Exception as e:
|
|
20
|
-
return {"success": False, "error": str(e)}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def chatgpt(prompt: str) -> dict:
|
|
24
|
-
"""Uses free exh.ai endpoint (same as BadAPI)."""
|
|
25
|
-
try:
|
|
26
|
-
url = "https://api.exh.ai/chatbot/v1/get_response"
|
|
27
|
-
headers = {
|
|
28
|
-
"Authorization": (
|
|
29
|
-
"Bearer eyJhbGciOiJIUzUxMiJ9"
|
|
30
|
-
".eyJ1c2VybmFtZSI6ImJvdGlmeS13ZWItdjMifQ"
|
|
31
|
-
".O-w89I5aX2OE_i4k6jdHZJEDWECSUfOb1lr9UdVH4oT"
|
|
32
|
-
"PMkFGUNm9BNzoQjcXOu8NEiIXq64-481hnenHdUrXfg"
|
|
33
|
-
),
|
|
34
|
-
"Content-Type": "application/json",
|
|
35
|
-
}
|
|
36
|
-
payload = {
|
|
37
|
-
"messages": [{"role": "user", "content": prompt}],
|
|
38
|
-
"model": "gpt-3.5-turbo",
|
|
39
|
-
}
|
|
40
|
-
r = requests.post(url, headers=headers, data=json.dumps(payload))
|
|
41
|
-
return {"result": r.json().get("response", ""), "success": True}
|
|
42
|
-
except Exception as e:
|
|
43
|
-
return {"success": False, "error": str(e)}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def blackbox(prompt: str) -> dict:
|
|
47
|
-
try:
|
|
48
|
-
url = "https://www.blackbox.ai/api/chat"
|
|
49
|
-
headers = {"Content-Type": "application/json"}
|
|
50
|
-
payload = {
|
|
51
|
-
"messages": [{"role": "user", "content": prompt}],
|
|
52
|
-
"agentMode": {},
|
|
53
|
-
"trendingAgentMode": {},
|
|
54
|
-
"isMicMode": False,
|
|
55
|
-
}
|
|
56
|
-
r = requests.post(url, headers=headers, json=payload)
|
|
57
|
-
return {"result": r.text, "success": True}
|
|
58
|
-
except Exception as e:
|
|
59
|
-
return {"success": False, "error": str(e)}
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import random
|
|
2
|
-
import string
|
|
3
|
-
import re
|
|
4
|
-
import requests
|
|
5
|
-
from bs4 import BeautifulSoup
|
|
6
|
-
from ..func import MORSE_CODE_DICT
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def password(length: int = 12) -> str:
|
|
10
|
-
chars = string.ascii_letters + string.punctuation + string.digits
|
|
11
|
-
return "".join(random.sample(chars, length))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def morse_encode(text: str) -> dict:
|
|
15
|
-
cipher = ""
|
|
16
|
-
for ch in text.upper():
|
|
17
|
-
if ch == " ":
|
|
18
|
-
cipher += " "
|
|
19
|
-
elif ch in MORSE_CODE_DICT:
|
|
20
|
-
cipher += MORSE_CODE_DICT[ch] + " "
|
|
21
|
-
return {"input": text, "result": cipher.strip(), "success": True}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def morse_decode(code: str) -> dict:
|
|
25
|
-
code += " "
|
|
26
|
-
decipher = ""
|
|
27
|
-
citext = ""
|
|
28
|
-
i = 0
|
|
29
|
-
for ch in code:
|
|
30
|
-
if ch != " ":
|
|
31
|
-
i = 0
|
|
32
|
-
citext += ch
|
|
33
|
-
else:
|
|
34
|
-
i += 1
|
|
35
|
-
if i == 2:
|
|
36
|
-
decipher += " "
|
|
37
|
-
else:
|
|
38
|
-
key = next(
|
|
39
|
-
(k for k, v in MORSE_CODE_DICT.items() if v == citext), "?"
|
|
40
|
-
)
|
|
41
|
-
decipher += key
|
|
42
|
-
citext = ""
|
|
43
|
-
return {"input": code.strip(), "result": decipher, "success": True}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def github(username: str) -> dict:
|
|
47
|
-
r = requests.get(f"https://api.github.com/users/{username}").json()
|
|
48
|
-
return {
|
|
49
|
-
"name": r.get("name"),
|
|
50
|
-
"username": r.get("login"),
|
|
51
|
-
"id": r.get("id"),
|
|
52
|
-
"bio": r.get("bio"),
|
|
53
|
-
"location": r.get("location"),
|
|
54
|
-
"repos": r.get("public_repos"),
|
|
55
|
-
"followers": r.get("followers"),
|
|
56
|
-
"following": r.get("following"),
|
|
57
|
-
"avatar": r.get("avatar_url"),
|
|
58
|
-
"url": r.get("html_url"),
|
|
59
|
-
"success": True,
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def pypi(package: str) -> dict:
|
|
64
|
-
r = requests.get(f"https://pypi.org/pypi/{package}/json").json()
|
|
65
|
-
info = r.get("info", {})
|
|
66
|
-
return {
|
|
67
|
-
"name": info.get("name"),
|
|
68
|
-
"version": info.get("version"),
|
|
69
|
-
"summary": info.get("summary"),
|
|
70
|
-
"author": info.get("author"),
|
|
71
|
-
"license": info.get("license"),
|
|
72
|
-
"home_page": info.get("home_page"),
|
|
73
|
-
"success": True,
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def hashtag(keyword: str) -> dict:
|
|
78
|
-
url = "https://all-hashtag.com/library/contents/ajax_generator.php"
|
|
79
|
-
data = {"keyword": keyword, "filter": "top"}
|
|
80
|
-
response = requests.post(url, data=data).text
|
|
81
|
-
soup = BeautifulSoup(response, "html.parser")
|
|
82
|
-
div = soup.find("div", {"class": "copy-hashtags"})
|
|
83
|
-
if not div:
|
|
84
|
-
return {"success": False, "error": "No hashtags found"}
|
|
85
|
-
tags = div.string.split()
|
|
86
|
-
return {"input": keyword, "results": tags, "success": True}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def chatbot(text: str) -> dict:
|
|
90
|
-
try:
|
|
91
|
-
url = (
|
|
92
|
-
"https://fallenxbot.vercel.app/api"
|
|
93
|
-
f"?apikey=593560829-fallen-usbk33kbsu"
|
|
94
|
-
f"&group-controller/mukesh/message={text}"
|
|
95
|
-
)
|
|
96
|
-
r = requests.get(url).json()
|
|
97
|
-
return {"result": r.get("reply", ""), "success": True}
|
|
98
|
-
except Exception as e:
|
|
99
|
-
return {"success": False, "error": str(e)}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def meme() -> dict:
|
|
103
|
-
try:
|
|
104
|
-
r = requests.get("https://meme-api.com/gimme").json()
|
|
105
|
-
return {
|
|
106
|
-
"title": r.get("title"),
|
|
107
|
-
"url": r.get("url"),
|
|
108
|
-
"subreddit": r.get("subreddit"),
|
|
109
|
-
"author": r.get("author"),
|
|
110
|
-
"success": True,
|
|
111
|
-
}
|
|
112
|
-
except Exception as e:
|
|
113
|
-
return {"success": False, "error": str(e)}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
def unsplash(query: str) -> dict:
|
|
117
|
-
url = (
|
|
118
|
-
f"https://www.istockphoto.com/search/2/image"
|
|
119
|
-
f"?alloweduse=availableforalluses&phrase={query}&sort=best"
|
|
120
|
-
)
|
|
121
|
-
headers = {
|
|
122
|
-
"User-Agent": (
|
|
123
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
|
124
|
-
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
|
125
|
-
"Chrome/121.0.0.0 Safari/537.36"
|
|
126
|
-
),
|
|
127
|
-
"Accept-Language": "en-US,en;q=0.9",
|
|
128
|
-
"Referer": "https://unsplash.com/",
|
|
129
|
-
}
|
|
130
|
-
r = requests.get(url, headers=headers)
|
|
131
|
-
if r.status_code != 200:
|
|
132
|
-
return {"success": False, "error": f"Status {r.status_code}"}
|
|
133
|
-
soup = BeautifulSoup(r.content, "html.parser")
|
|
134
|
-
imgs = [
|
|
135
|
-
img["src"]
|
|
136
|
-
for img in soup.find_all("img")
|
|
137
|
-
if img.get("src", "").startswith("https://media.istockphoto.com")
|
|
138
|
-
]
|
|
139
|
-
return {"results": imgs, "success": True}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def imdb(query: str) -> dict:
|
|
143
|
-
try:
|
|
144
|
-
try:
|
|
145
|
-
from requests_html import HTMLSession
|
|
146
|
-
session = HTMLSession()
|
|
147
|
-
r = session.get(f"https://www.imdb.com/find?q={query}")
|
|
148
|
-
results = r.html.xpath(
|
|
149
|
-
"//section[@data-testid='find-results-section-title']/div/ul/li"
|
|
150
|
-
)
|
|
151
|
-
if not results:
|
|
152
|
-
return {"success": False, "error": "No results"}
|
|
153
|
-
first_url = results[0].find("a")[0].attrs["href"]
|
|
154
|
-
except ImportError:
|
|
155
|
-
# fallback: plain requests + bs4
|
|
156
|
-
headers = {"User-Agent": "Mozilla/5.0"}
|
|
157
|
-
r = requests.get(
|
|
158
|
-
f"https://www.imdb.com/find?q={query}&s=tt", headers=headers
|
|
159
|
-
)
|
|
160
|
-
soup = BeautifulSoup(r.text, "html.parser")
|
|
161
|
-
result = soup.select_one(".ipc-metadata-list-summary-item a")
|
|
162
|
-
if not result:
|
|
163
|
-
return {"success": False, "error": "No results"}
|
|
164
|
-
first_url = result["href"]
|
|
165
|
-
|
|
166
|
-
headers = {"User-Agent": "Mozilla/5.0"}
|
|
167
|
-
page = requests.get(f"https://www.imdb.com{first_url}", headers=headers)
|
|
168
|
-
soup = BeautifulSoup(page.text, "html.parser")
|
|
169
|
-
import json as _json
|
|
170
|
-
script = soup.find("script", type="application/ld+json")
|
|
171
|
-
if not script:
|
|
172
|
-
return {"success": False, "error": "Could not parse IMDB page"}
|
|
173
|
-
ld = _json.loads(script.string)
|
|
174
|
-
return {
|
|
175
|
-
"name": soup.title.text.strip() if soup.title else "",
|
|
176
|
-
"url": ld.get("url"),
|
|
177
|
-
"image": ld.get("image"),
|
|
178
|
-
"description": ld.get("description"),
|
|
179
|
-
"genre": ld.get("genre"),
|
|
180
|
-
"actors": [a["name"] for a in ld.get("actor", [])],
|
|
181
|
-
"review": ld.get("review", {}).get("reviewBody"),
|
|
182
|
-
"rating": ld.get("review", {}).get("reviewRating", {}).get("ratingValue"),
|
|
183
|
-
"trailer": ld.get("trailer"),
|
|
184
|
-
"success": True,
|
|
185
|
-
}
|
|
186
|
-
except Exception as e:
|
|
187
|
-
return {"success": False, "error": str(e)}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
def leetcode(username: str) -> dict:
|
|
191
|
-
url = "https://leetcode.com/graphql/"
|
|
192
|
-
q1 = {
|
|
193
|
-
"operationName": "userProfileCalendar",
|
|
194
|
-
"query": """
|
|
195
|
-
query userProfileCalendar($username: String!, $year: Int) {
|
|
196
|
-
matchedUser(username: $username) {
|
|
197
|
-
userCalendar(year: $year) {
|
|
198
|
-
streak
|
|
199
|
-
totalActiveDays
|
|
200
|
-
activeYears
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}""",
|
|
204
|
-
"variables": {"username": username, "year": 2024},
|
|
205
|
-
}
|
|
206
|
-
q2 = {
|
|
207
|
-
"operationName": "userPublicProfile",
|
|
208
|
-
"query": """
|
|
209
|
-
query userPublicProfile($username: String!) {
|
|
210
|
-
matchedUser(username: $username) {
|
|
211
|
-
username
|
|
212
|
-
githubUrl
|
|
213
|
-
twitterUrl
|
|
214
|
-
linkedinUrl
|
|
215
|
-
profile {
|
|
216
|
-
ranking
|
|
217
|
-
userAvatar
|
|
218
|
-
realName
|
|
219
|
-
countryName
|
|
220
|
-
company
|
|
221
|
-
jobTitle
|
|
222
|
-
skillTags
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}""",
|
|
226
|
-
"variables": {"username": username},
|
|
227
|
-
}
|
|
228
|
-
try:
|
|
229
|
-
r1 = requests.post(url, json=q1).json()
|
|
230
|
-
r2 = requests.post(url, json=q2).json()
|
|
231
|
-
d1 = r1["data"]["matchedUser"]
|
|
232
|
-
d2 = r2["data"]["matchedUser"]
|
|
233
|
-
return {**d1, **d2, "success": True}
|
|
234
|
-
except Exception as e:
|
|
235
|
-
return {"success": False, "error": str(e)}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
def bhagwatgita(chapter: int, shalok: int = 1) -> dict:
|
|
239
|
-
try:
|
|
240
|
-
url = f"https://www.holy-bhagavad-gita.org/chapter/{chapter}/hi"
|
|
241
|
-
r = requests.get(url)
|
|
242
|
-
soup = BeautifulSoup(r.text, "html.parser")
|
|
243
|
-
intro_div = soup.find("div", class_="chapterIntro")
|
|
244
|
-
verses = soup.find_all("section", class_="listItem")
|
|
245
|
-
texts = [
|
|
246
|
-
v.text.strip()
|
|
247
|
-
.replace("View commentary \u00bb", "")
|
|
248
|
-
.replace("Bhagavad Gita ", "")
|
|
249
|
-
.strip()
|
|
250
|
-
for v in verses
|
|
251
|
-
]
|
|
252
|
-
return {
|
|
253
|
-
"chapter": chapter,
|
|
254
|
-
"chapter_intro": intro_div.text if intro_div else "",
|
|
255
|
-
"shalok": texts[shalok] if shalok < len(texts) else "",
|
|
256
|
-
"success": True,
|
|
257
|
-
}
|
|
258
|
-
except Exception as e:
|
|
259
|
-
return {"success": False, "error": str(e)}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|