-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapp.py
126 lines (115 loc) · 4.25 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from fastapi import FastAPI, Request, HTTPException
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
import cloudscraper
from bs4 import BeautifulSoup
requests = cloudscraper.create_scraper()
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
main_url = "https://cf-proxy.seshu-yarra.workers.dev"
def scape_link(url: str) -> str:
req = requests.get(url).content
soup = BeautifulSoup(req, "html.parser")
link = soup.find("a", {"class": "main-button dlbutton"})['href']
return link
def get_page(url: str) -> list:
req = requests.get(url).content
soup = BeautifulSoup(req, "html.parser")
divs = soup.find_all("div", class_="cont_display")
data = []
for i in range(2, len(divs)):
title = divs[i].find("a")
img = divs[i].find("img")
dat = {"title": title['title'], "image": img['src'], "link": title['href']}
data.append(dat)
return data
def get_movie(url: str) -> dict:
req = requests.get(url).content
soup = BeautifulSoup(req, "html.parser")
title = soup.find("h2", class_="entry-title").text.replace("Full Movie Watch Online Free", "")
image = soup.find("img", class_="attachment-post-thumbnail size-post-thumbnail wp-post-image")['src']
description = soup.find_all("p")[4].text
torrents = soup.find_all("a", class_="mv_button_css")
torrent = []
other_links = []
for tor in torrents:
link = tor['href']
size = tor.find_all("small")[0].text
quality = tor.find_all("small")[1].text
data = {"magnet": link, "size": size, "quality": quality}
torrent.append(data)
ps = soup.find_all("p")
for p in ps:
if p.find("strong"):
if "Watch Online –" in p.find("strong").text:
typ = p.find("strong").text.split("–")[-1]
try:
lin = p.find("a")['href']
data = {"type": typ, "url": lin}
other_links.append(data)
except:
pass
data = {"status": True, "url": url, "title": title, "description": description, "image": image, "torrent": torrent, "other_links": other_links}
return data
@app.get("/search")
async def search(query: str):
url = main_url+f"/?s={query}"
try:
data = get_page(url)
total = len(data)
main_data = {"status": True, "total_found": total, "url": url, "data": data}
except:
main_data = {"status": False, "msg": "No Data Found"}
return JSONResponse(content=main_data)
@app.get("/{language}/{page}")
async def get_home(language: str, page: int = 1):
if language == "telugu":
url = main_url+f"/telugu-movie/page/{page}"
elif language == "hindi":
url = main_url+f"/bollywood-movie-free/page/{page}"
elif language == "tamil":
url = main_url+f"/tamil-movie-free/page/{page}"
elif language == "malayalam":
url = main_url+f"/malayalam-movie-online/page/{page}"
elif language == "english":
url = main_url+"/category/hollywood-movie-2023/"
else:
url = None
if url:
data = get_page(url)
total = len(data)
main_data = {"status": True, "total_found": total, "url": url, "data": data}
else:
main_data = {"status": False}
return JSONResponse(content=main_data)
@app.get("/")
async def home():
url = main_url+"/"
data = get_page(url)
total = len(data)
main_data = {"status": True, "total_found": total, "url": url, "data": data}
return JSONResponse(content=main_data)
@app.get("/fetch")
async def fetch(url: str):
req = requests.get(url)
return req.content
@app.get("/get")
async def get_s(url: str):
try:
data = get_movie(url)
return JSONResponse(content=data)
except Exception as e:
data = {"status": False, "msg": "Unable to get data", "error": str(e)}
return JSONResponse(content=data)
@app.get("/ss")
async def sse():
return requests.get(main_url).content
if __name__ == "__main__":
import uvicorn
uvicorn.run(app)