-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkuma-add.py
53 lines (42 loc) · 1.46 KB
/
kuma-add.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
from uptime_kuma_api import UptimeKumaApi, MonitorType
import urllib.parse
from itertools import groupby
import tldextract
import os
from dotenv import load_dotenv
load_dotenv()
# If set to true, the Script will add the domains in abbreviated form, taking the initials, middle and
nsfw_check = False
# function for domain name digest for some NSFW check
def urlclean(domain):
url_clean = tldextract.extract(domain)
re = url_clean.domain
resx = ''
if len(re) > 6:
resx = re[0] + re[1] + re[2] + re[3] + re[4] + re[len(re) // 2] + re[-1]
else:
resx = re[0] + re[len(re) // 2] + re[-1]
return resx.upper()
print("Connecting to Uptime Kuma on: "+os.getenv('UPTIME_KUMA_URL'))
api = UptimeKumaApi(os.getenv('UPTIME_KUMA_URL'))
api.login(os.getenv('UPTIME_KUMA_USER'), os.getenv('UPTIME_KUMA_PASSWORD'))
with open('urls.txt', 'r') as f:
for line in f:
parsedUrl = urllib.parse.urlparse(line)
if nsfw_check:
checkName = urlclean(parsedUrl.netloc)
else:
checkName = parsedUrl.netloc
urlCheck = line
print("Working On: ", checkName)
api.add_monitor(
type=MonitorType.HTTP,
name=checkName,
description=parsedUrl.netloc,
url=urlCheck,
expiryNotification=True,
headers={"cache-control": "no-cache"},
interval=120,
)
print('-----------------------------------')
api.disconnect()