TraxDinosaur
commited on
Commit
•
0490835
1
Parent(s):
c934c74
initial commit
Browse files- Dockerfile +13 -0
- app.py +82 -0
- requirements.txt +5 -0
Dockerfile
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
8 |
+
|
9 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
10 |
+
|
11 |
+
COPY --chown=user . /app
|
12 |
+
|
13 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request, jsonify
|
2 |
+
import requests
|
3 |
+
from bs4 import BeautifulSoup as bs
|
4 |
+
|
5 |
+
app = Flask(__name__)
|
6 |
+
|
7 |
+
|
8 |
+
API_URL: str = 'https://api.gplinks.com/api'
|
9 |
+
API_TOKEN: str = 'dc9faf9392e2665facf1a6dec42a91600773fc5f'
|
10 |
+
STATUS: bool = False
|
11 |
+
# STATUS: bool = True
|
12 |
+
|
13 |
+
@app.route('/search', methods=['GET'])
|
14 |
+
def search_movies():
|
15 |
+
query = request.args.get('query')
|
16 |
+
try:
|
17 |
+
results = fetch_results(query)
|
18 |
+
return jsonify(results)
|
19 |
+
except Exception as e:
|
20 |
+
return jsonify({'error': str(e)}), 500
|
21 |
+
|
22 |
+
@app.route('/get_movie', methods=['GET'])
|
23 |
+
def get_movie():
|
24 |
+
movie_id = request.args.get('id')
|
25 |
+
try:
|
26 |
+
main_link = get_main_link(movie_id)
|
27 |
+
Shortner = f'{API_URL}?api={API_TOKEN}&url={main_link}'
|
28 |
+
r = requests.get(Shortner)
|
29 |
+
data = r.json()
|
30 |
+
shorted = (data['shortenedUrl'])
|
31 |
+
return jsonify({'download_link': shorted})
|
32 |
+
except Exception as e:
|
33 |
+
return jsonify({'error': str(e)}), 500
|
34 |
+
|
35 |
+
def fetch_results(query):
|
36 |
+
headers = {
|
37 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:127.0) Gecko/20100101 Firefox/127.0',
|
38 |
+
'Accept': '*/*',
|
39 |
+
'Accept-Language': 'en-US,en;q=0.5',
|
40 |
+
# 'Accept-Encoding': 'gzip, deflate',
|
41 |
+
'Referer': 'http://scloud.starkflix.cloud/',
|
42 |
+
'DNT': '1',
|
43 |
+
'Sec-GPC': '1',
|
44 |
+
'Connection': 'keep-alive',
|
45 |
+
'Priority': 'u=1',
|
46 |
+
}
|
47 |
+
|
48 |
+
params = {
|
49 |
+
'q': query,
|
50 |
+
}
|
51 |
+
|
52 |
+
try:
|
53 |
+
r = requests.get('http://scloud.starkflix.cloud/search', params=params, headers=headers)
|
54 |
+
r.raise_for_status() # Raise an error for bad responses (4xx or 5xx)
|
55 |
+
data = r.json()
|
56 |
+
results = [{'id': item['id'], 'title': item['title']} for item in data]
|
57 |
+
return results
|
58 |
+
except requests.exceptions.RequestException as e:
|
59 |
+
raise Exception(f"Request error: {str(e)}")
|
60 |
+
except (KeyError, TypeError, ValueError) as e:
|
61 |
+
raise Exception(f"Response parsing error: {str(e)}")
|
62 |
+
|
63 |
+
def get_main_link(movie_id):
|
64 |
+
url = f"http://scloud.starkflix.cloud/file/{movie_id}"
|
65 |
+
try:
|
66 |
+
r = requests.get(url)
|
67 |
+
r.raise_for_status() # Raise an error for bad responses (4xx or 5xx)
|
68 |
+
data = r.content
|
69 |
+
soup = bs(data, 'html5lib')
|
70 |
+
links = soup.find('a')
|
71 |
+
if links:
|
72 |
+
link = links.get('href')
|
73 |
+
return link
|
74 |
+
else:
|
75 |
+
raise Exception(f"No download link found for movie_id: {movie_id}")
|
76 |
+
except requests.exceptions.RequestException as e:
|
77 |
+
raise Exception(f"Request error: {str(e)}")
|
78 |
+
except (AttributeError, TypeError, ValueError) as e:
|
79 |
+
raise Exception(f"Response parsing error: {str(e)}")
|
80 |
+
|
81 |
+
if __name__ == '__main__':
|
82 |
+
app.run(debug=True,host='0.0.0.0',port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
flask
|
2 |
+
requests
|
3 |
+
bs4
|
4 |
+
fastapi
|
5 |
+
waitress
|