-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
83 lines (73 loc) · 3.57 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
from flask import Flask, render_template, request, send_file
from application.facebook import Facebook
from application.twitter import Twitter
from application.threads import Threads
from application.tiktok import Tiktok
from application.instagram import Instagram
app = Flask(__name__)
@app.route('/instagram/downloader/', methods=['POST', 'GET'])
def DownloadFromInstagram():
if request.method == "POST":
get_json_data = request.get_json()
video_stream = Instagram(get_json_data['url'])
if isinstance(video_stream, tuple):
message, status = video_stream
return (message, status)
return send_file(video_stream, as_attachment=True, download_name='instagram-video.mp4', mimetype='video/mp4')
else:
return render_template('unduh.html', platform="instagram", placeholder="Example: https://www.instagram.com/reel/...")
@app.route('/facebook/downloader/', methods=['POST', 'GET'])
def DownloadFromFacebook():
if request.method == "POST":
get_json_data = request.get_json()
video_stream = Facebook(get_json_data['url'])
if isinstance(video_stream, tuple):
message, status = video_stream
return (message, status)
return send_file(video_stream, as_attachment=True, download_name='facebook-video.mp4', mimetype='video/mp4')
else:
return render_template('unduh.html', platform="facebook", placeholder="Example: https://www.facebook.com/share/r/...")
@app.route('/tiktok/downloader/', methods=['POST', 'GET'])
def DownloadFromTiktok():
if request.method == "POST":
get_json_data = request.get_json()
video_stream = Tiktok(get_json_data['url'])
if isinstance(video_stream, tuple):
message, status = video_stream
return (message, status)
return send_file(video_stream, as_attachment=True, download_name='tiktok-video.mp4', mimetype='video/mp4')
else:
return render_template('unduh.html', platform="tiktok", placeholder="Example: https://vm.tiktok.com/...")
@app.route('/threads/downloader/', methods=['POST', 'GET'])
def DownloadFromThreads():
if request.method == "POST":
get_json_data = request.get_json()
video_stream = Threads(get_json_data['url'])
if isinstance(video_stream, tuple):
message, status = video_stream
return (message, status)
return send_file(video_stream, as_attachment=True, download_name='threads-video.mp4', mimetype='video/mp4')
else:
return render_template('unduh.html', platform="threads", placeholder="Example: https://www.threads.net/@.../post/...")
@app.route('/twitter/downloader/', methods=['POST', 'GET'])
def DownloadFromTwitter():
if request.method == "POST":
get_json_data = request.get_json()
video_stream = Twitter(get_json_data['url'])
if isinstance(video_stream, tuple):
message, status = video_stream
return (message, status)
return send_file(video_stream, as_attachment=True, download_name='twitter-video.mp4', mimetype='video/mp4')
else:
return render_template('unduh.html', platform="twitter", placeholder="Example: https://x.com/.../status/...")
@app.route('/terms-of-service/')
def TermsOfService():
return render_template('terms-of-service.html')
@app.route('/')
def HomePage():
return render_template('index.html')
@app.route('/privacy-policy/')
def PrivacyPolicy():
return render_template('privacy-policy.html')
if __name__=='__main__':
app.run(debug=True)