PandaAPI 1.0.0__tar.gz → 1.0.1__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.0 → pandaapi-1.0.1}/PKG-INFO +1 -1
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/modules/tools.py +29 -18
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI.egg-info/PKG-INFO +1 -1
- {pandaapi-1.0.0 → pandaapi-1.0.1}/pyproject.toml +1 -1
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/__init__.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/func.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/modules/__init__.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/modules/ai.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/modules/media.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI/modules/telegram.py +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI.egg-info/SOURCES.txt +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI.egg-info/dependency_links.txt +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI.egg-info/requires.txt +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/PandaAPI.egg-info/top_level.txt +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/README.md +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/setup.cfg +0 -0
- {pandaapi-1.0.0 → pandaapi-1.0.1}/setup.py +0 -0
|
@@ -3,7 +3,6 @@ import string
|
|
|
3
3
|
import re
|
|
4
4
|
import requests
|
|
5
5
|
from bs4 import BeautifulSoup
|
|
6
|
-
from requests_html import HTMLSession
|
|
7
6
|
from ..func import MORSE_CODE_DICT
|
|
8
7
|
|
|
9
8
|
|
|
@@ -142,26 +141,38 @@ def unsplash(query: str) -> dict:
|
|
|
142
141
|
|
|
143
142
|
def imdb(query: str) -> dict:
|
|
144
143
|
try:
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return {"success": False, "error": "No results"}
|
|
152
|
-
first_url = results[0].find("a")[0].attrs["href"]
|
|
153
|
-
headers = {
|
|
154
|
-
"User-Agent": (
|
|
155
|
-
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
|
156
|
-
"AppleWebKit/537.36"
|
|
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"
|
|
157
150
|
)
|
|
158
|
-
|
|
159
|
-
|
|
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)
|
|
160
168
|
soup = BeautifulSoup(page.text, "html.parser")
|
|
161
169
|
import json as _json
|
|
162
|
-
|
|
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)
|
|
163
174
|
return {
|
|
164
|
-
"name": soup.title.text.strip(),
|
|
175
|
+
"name": soup.title.text.strip() if soup.title else "",
|
|
165
176
|
"url": ld.get("url"),
|
|
166
177
|
"image": ld.get("image"),
|
|
167
178
|
"description": ld.get("description"),
|
|
@@ -233,7 +244,7 @@ def bhagwatgita(chapter: int, shalok: int = 1) -> dict:
|
|
|
233
244
|
verses = soup.find_all("section", class_="listItem")
|
|
234
245
|
texts = [
|
|
235
246
|
v.text.strip()
|
|
236
|
-
.replace("View commentary
|
|
247
|
+
.replace("View commentary \u00bb", "")
|
|
237
248
|
.replace("Bhagavad Gita ", "")
|
|
238
249
|
.strip()
|
|
239
250
|
for v in verses
|
|
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
|
|
File without changes
|