Skip to content

Commit b96877f

Browse files
committed
[build]: update react build
1 parent 15af812 commit b96877f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+592
-821
lines changed

README.md

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,4 @@
1-
# React + Vite
2-
3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4-
5-
Currently, two official plugins are available:
6-
7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9-
[lahelu](https://lahelu.com)
10-
11-
- endpoints
12-
```shell
13-
/api/lahelu/all
14-
```
15-
16-
### API parsing data NIK
17-
- endpoints
18-
```shell
19-
/api/cek-nik?nik=<nik>
20-
```
21-
22-
### API pencarian provinsi
23-
- endpoints
24-
```shell
25-
/api/provinsi?search=<query>
26-
```
27-
28-
### API pencarian kecamatan
29-
- endpoints
30-
```shell
31-
/api/kecamatan?search=<query>
32-
```
1+
# megane API
2+
Megane API Is A Collection Of APIs For Various Needs Built In Python
333

344
> built with ♥️ by fiandev

app.py

+30
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
from application.controllers.api.PhoneNumberController import PhoneNumberController
66
from application.controllers.api.LaheluController import LaheluController
77
from application.controllers.api.ShortLinkController import ShortLinkController
8+
from application.controllers.api.QuranController import QuranController
9+
from application.controllers.api.SocialMediaController import SocialMediaController
810

911
app = Flask(__name__, template_folder="./application/resources/views")
1012
app.secret_key = config["key"]
1113
app.config['SECRET_KEY'] = config["key"]
1214

15+
# disable strict trailing slash
16+
app.url_map.strict_slashes = False
1317

1418
# web routes
1519

@@ -88,6 +92,32 @@ def show_juz (juz_id):
8892
def search_quran ():
8993
return QuranController.search_quran()
9094

95+
@app.route("/api/ig/downloader")
96+
@app.route("/api/instagram/downloader")
97+
def ig_downloader ():
98+
return SocialMediaController.ig_downloader()
99+
100+
@app.route("/api/tiktok/downloader")
101+
def tiktok_downloader ():
102+
return SocialMediaController.tiktok_downloader()
103+
104+
@app.route("/api/tiktokslide/downloader")
105+
@app.route("/api/tiktok/images")
106+
@app.route("/api/tiktok/slides")
107+
def tiktok_slide_downloader ():
108+
return SocialMediaController.tiktok_slide_downloader()
109+
110+
@app.route("/api/tiktok/random")
111+
@app.route("/api/tiktok/random-post")
112+
def tiktok_random_user_post ():
113+
return SocialMediaController.tiktok_random_user_post()
114+
115+
@app.route("/api/tiktok/statistic")
116+
@app.route("/api/tiktok/statistics")
117+
@app.route("/api/tiktok/stats")
118+
def tiktok_statistic ():
119+
return SocialMediaController.tiktok_statistic()
120+
91121

92122

93123
if __name__ == "__main__":
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
import requests as xhr
2+
import re
3+
from application.utilities.response import api_response_error, api_response_success
4+
from application.utilities.request import get_params
5+
from application.utilities.parser import parse_title
6+
7+
IG_DOWNLODER_API_URL = "https://aemt.me/download/igdl"
8+
TIKTOK_DOWNLODER_API_URL = "https://aemt.me/download/tikdl"
9+
TIKTOK_SLIDE_DOWNLODER_API_URL = "https://aemt.me/download/tiktokslide"
10+
TIKTOK_RANDOM_USERPOST_API_URL = "https://aemt.me/download/asupantt"
11+
12+
VALID_VT_URL = r"^((http(s)?)\:\/\/)?vt.tiktok.com/((\w|\d)+)\/?$"
13+
14+
class SocialMediaController ():
15+
@staticmethod
16+
def ig_downloader ():
17+
try:
18+
url = get_params("url")
19+
data = xhr.get(f"{ IG_DOWNLODER_API_URL }?url={ url }").json()
20+
result = data["result"]
21+
22+
return api_response_success(result)
23+
except Exception as err:
24+
return api_response_error(str(err))
25+
26+
def tiktok_downloader ():
27+
try:
28+
url = get_params("url")
29+
30+
if not re.match(VALID_VT_URL, url):
31+
raise Exception("invalid vt url !")
32+
33+
data = xhr.get(f"{ TIKTOK_DOWNLODER_API_URL }/?url={ url }").json()
34+
result = data["result"]
35+
36+
return api_response_success({
37+
"thumbnail": result["info_video"]["thumbnail"],
38+
"post_author": result["author_info"],
39+
"media": {
40+
"no_watermark": result["url"]["nowm"],
41+
"watermark": result["url"]["wm"],
42+
"music": result["url"]["audio"],
43+
}
44+
})
45+
except Exception as err:
46+
return api_response_error(str(err))
47+
48+
def tiktok_slide_downloader ():
49+
try:
50+
url = get_params("url")
51+
52+
if not re.match(VALID_VT_URL, url):
53+
raise Exception("invalid vt url !")
54+
55+
data = xhr.get(f"{ TIKTOK_SLIDE_DOWNLODER_API_URL }/?url={ url }").json()
56+
result = data["result"]["data"]
57+
58+
return api_response_success({
59+
"cover": result["cover"],
60+
"post_author": result["author"],
61+
"images": result["images"],
62+
"media": {
63+
"music": result["music"],
64+
}
65+
})
66+
except Exception as err:
67+
return api_response_error(str(err))
68+
69+
def tiktok_random_user_post ():
70+
try:
71+
username = get_params("username")
72+
73+
data = xhr.get(f"{ TIKTOK_RANDOM_USERPOST_API_URL }/?username={ username }").json()
74+
result = data["result"]["data"]
75+
parsed_title = parse_title(result["caption"])
76+
77+
return api_response_success({
78+
"title": result["caption"],
79+
**parsed_title,
80+
"post_author": result["author"],
81+
"media": {
82+
"music": result["music"]["play"],
83+
"no_watermark": result["video"],
84+
}
85+
})
86+
except Exception as err:
87+
return api_response_error(str(err))
88+
89+
def tiktok_statistic ():
90+
try:
91+
url = get_params("url")
92+
93+
if not re.match(VALID_VT_URL, url):
94+
raise Exception("invalid vt url !")
95+
96+
data = xhr.get(f"{ TIKTOK_DOWNLODER_API_URL }/?url={ url }").json()
97+
result = data["result"]
98+
parsed_title = parse_title(result["info_video"]["title"])
99+
100+
return api_response_success({
101+
**result["info_video"],
102+
**parsed_title,
103+
"post_author": result["author_info"],
104+
"media": {
105+
"no_watermark": result["url"]["nowm"],
106+
"watermark": result["url"]["wm"],
107+
"music": result["url"]["audio"],
108+
}
109+
})
110+
except Exception as err:
111+
return api_response_error(str(err))

application/utilities/parser.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import re
2+
3+
def parse_title (title: str) -> dict:
4+
VALID_USER_TAGGED = r"\@(\w+|\d+)"
5+
VALID_HASTAG = r"\#(\w+|\d+)"
6+
7+
tags = re.findall(VALID_USER_TAGGED, title)
8+
hashtags = re.findall(VALID_HASTAG, title)
9+
10+
return {
11+
"tags": list(map(lambda item: f"@{ item }", tags)),
12+
"hashtags": list(map(lambda item: f"#{ item }", hashtags)),
13+
}

application/utilities/request.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from flask import request
2+
3+
def get_params (*keys):
4+
results = {}
5+
6+
for key in set(keys):
7+
value = request.args.get(key)
8+
9+
if not isinstance(key, str):
10+
raise Exception(f"data type of key must be string, but '{ type(key) }' received !")
11+
if not value:
12+
raise Exception (f"parameter '{ key }' is doesn't passed")
13+
if len(keys) == 1:
14+
return value
15+
results[key] = value
16+
17+
return results
18+

application/utilities/response.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from flask import jsonify
22
from datetime import datetime
33

4-
def response_json (data):
5-
return jsonify(data)
4+
def response_json (data, code):
5+
return jsonify(data), code
66

77
def api_response_error (message, code = 500):
88
return response_json({
@@ -12,7 +12,7 @@ def api_response_error (message, code = 500):
1212
"server_time": datetime.now(),
1313
"author": "fiandev",
1414
"docs": "https://megane-api.fiandev.my.id/",
15-
})
15+
}, code)
1616

1717
def api_response_success (data, status = "success", code = 200, otherStateData = {}):
1818
responseTemplate = {
@@ -27,4 +27,4 @@ def api_response_success (data, status = "success", code = 200, otherStateData =
2727
for key in otherStateData:
2828
responseTemplate[key] = otherStateData[key]
2929

30-
return response_json(responseTemplate)
30+
return response_json(responseTemplate, code)

dev.py

+27-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
from application.controllers.api.LaheluController import LaheluController
77
from application.controllers.api.ShortLinkController import ShortLinkController
88
from application.controllers.api.QuranController import QuranController
9+
from application.controllers.api.SocialMediaController import SocialMediaController
910

1011
app = Flask(__name__, template_folder="./application/resources/views")
1112
app.secret_key = config["key"]
1213
app.config['SECRET_KEY'] = config["key"]
13-
14+
app.url_map.strict_slashes = False
1415

1516
# web routes
1617

@@ -90,8 +91,31 @@ def show_juz (juz_id):
9091
def search_quran ():
9192
return QuranController.search_quran()
9293

93-
94-
94+
@app.route("/api/ig/downloader")
95+
@app.route("/api/instagram/downloader")
96+
def ig_downloader ():
97+
return SocialMediaController.ig_downloader()
98+
99+
@app.route("/api/tiktok/downloader")
100+
def tiktok_downloader ():
101+
return SocialMediaController.tiktok_downloader()
102+
103+
@app.route("/api/tiktokslide/downloader")
104+
@app.route("/api/tiktok/images")
105+
@app.route("/api/tiktok/slides")
106+
def tiktok_slide_downloader ():
107+
return SocialMediaController.tiktok_slide_downloader()
108+
109+
@app.route("/api/tiktok/random")
110+
@app.route("/api/tiktok/random-post")
111+
def tiktok_random_user_post ():
112+
return SocialMediaController.tiktok_random_user_post()
113+
114+
@app.route("/api/tiktok/statistic")
115+
@app.route("/api/tiktok/statistics")
116+
@app.route("/api/tiktok/stats")
117+
def tiktok_statistic ():
118+
return SocialMediaController.tiktok_statistic()
95119

96120

97121
if __name__ == "__main__":

dist/docs/instagram.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# instagram API
2+
API that provides to get metadata of instagram post
3+
4+
## get metadata of a instagram post
5+
6+
### example
7+
```
8+
/api/instagram/downloader?url=<post_url>
9+
```
10+
11+
### example response
12+
```javascript
13+
{
14+
"author": "string",
15+
"code": "integer",
16+
"data": [
17+
...
18+
{
19+
"thumbnail": "string",
20+
"url": "string", // post download url
21+
"wm": "string" // post author username
22+
}
23+
...
24+
],
25+
"docs": "string",
26+
"server_time": "string",
27+
"status": "string"
28+
}
29+
```

0 commit comments

Comments
 (0)