-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtools.py
90 lines (72 loc) · 2.99 KB
/
tools.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
import requests as r
import json
from bs4 import BeautifulSoup
import base64
req = r#.Session()
# req.headers.update({
# 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
# })
def get(url, options={}):
response = req.get(url, headers=options.get("headers", {}), params=options.get("params", {}))
# get status code
status = response.status_code
if status == 200:
return response
elif status == 404:
return { 'success': False, 'statusCode': 404, 'message': "Not Found" }
else:
url_base64 = base64.b64encode(url.encode('utf-8'))
response = req.get("https://bypass.katowproject.my.id/?q=" + url_base64.decode('utf-8'))
# if "komikindo" in url:
# # url = url.replace("komikindo.id", "komikindo-id.translate.goog")
# # if "?" in url:
# # response = req.get(url + "&_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=id", params=options)
# # else:
# # response = req.get(url + "?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=id", params=options)
# return response
# if "otakudesu" in url:
# url_base64 = base64.b64encode(url.encode('utf-8'))
# response = req.get("https://bypass.kato-rest.us/?q=" + url_base64.decode('utf-8'))
# # url = url.replace("otakudesu.site", "otakudesu-site.translate.goog")
# # if "?" in url:
# # response = req.get(url + "&_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=id", params=options)
# # else:
# # response = req.get(url + "?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=id", params=options)
return response
def post(url, data, options={}):
response = req.post(url, data=data, headers=options.get("headers", {}))
status = response.status_code
if '2' in str(status):
return response
# url_base64 = base64.b64encode(url.encode('utf-8'))
# # add to data
# data = data + f"&url={url_base64.decode('utf-8')}"
# response = req.post("https://bypass.kato-rest.us/", data=data, headers=options.get("headers", {}))
# return response
def get_media_src(url):
response = get(url)
data = response.text
soup = BeautifulSoup(data, "html.parser")
src = None
src1 = soup.find("source")
src2 = data.split("sources: [")
src3 = soup.find("iframe")
if (src1):
src = src1.get("src")
elif (len(src2) > 1):
src = src2[1].split("]")[0].split("'file':")[1].split("'")[1]
elif (src3):
src = src3.get("src")
return src
def reverse_proxy(url):
#decode base64
url = base64.b64decode(url).decode('utf-8')
#return as video
response = req.get(url,)
return response
def to_base64(url):
url = base64.b64encode(url.encode('utf-8'))
return url.decode('utf-8')
def decode_base64(url):
url = base64.b64decode(url).decode('utf-8')
return url