about summary refs log tree commit diff stats
path: root/src/instances
diff options
context:
space:
mode:
authorManeraKai <manerakai@protonmail.com>2022-07-18 11:30:06 +0200
committerManeraKai <manerakai@protonmail.com>2022-07-18 11:30:06 +0200
commitf4193428049efc1edc712a20e6e441b46c8126a3 (patch)
treec12aa2d2633387903bd7d96f6ced90085c7d0aa3 /src/instances
parentMerge pull request 'data and blacklist only handled by ci' (#7) from BobIsMyM... (diff)
parentNo more trailing slashes (diff)
downloadlibredirect-f4193428049efc1edc712a20e6e441b46c8126a3.zip
Merge pull request 'No more trailing slashes' (#9) from BobIsMyManager/libredirect:optimizations into master
Reviewed-on: https://codeberg.org/LibRedirect/libredirect/pulls/9
Diffstat (limited to 'src/instances')
-rw-r--r--src/instances/get_instances.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/instances/get_instances.py b/src/instances/get_instances.py
index 098bc38b..2227a39b 100644
--- a/src/instances/get_instances.py
+++ b/src/instances/get_instances.py
@@ -14,13 +14,17 @@ mightyList = {}
 
 
 def filterLastSlash(urlList):
-    tmp = []
-    for i in urlList:
-        if i.endswith('/'):
-            tmp.append(i[:-1])
-            print(Fore.YELLOW + "Fixed " + Style.RESET_ALL + i)
-        else:
-            tmp.append(i)
+    tmp = {}
+    for x in urlList:
+        tmp[x] = {}
+        for y in urlList[x]:
+            tmp[x][y] = []
+            for z in urlList[x][y]:
+                if z.endswith('/'):
+                    tmp[x][y].append(z[:-1])
+                    print(Fore.YELLOW + "Fixed " + Style.RESET_ALL + z)
+                else:
+                    tmp[x][y].append(z)
     return tmp
 
 
@@ -177,7 +181,6 @@ def libreddit():
     tmp = re.findall(
         r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text)
 
-    tmp = filterLastSlash(tmp)
 
     for item in tmp:
         if item.endswith('.onion'):
@@ -249,7 +252,6 @@ def quetre():
     tmp = re.findall(
         r"\| \[.*\]\(([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)\)*\|*[A-Z]{0,}.*\|.*\|", r.text)
 
-    tmp = filterLastSlash(tmp)
 
     for item in tmp:
         if item.endswith('.onion'):
@@ -270,7 +272,6 @@ def libremdb():
     tmp = re.findall(
         r"\| ([-a-zA-Z0-9@:%_\+.~#?&//=]{2,}\.[a-z]{2,}\b(?:\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?)*\|*[A-Z]{0,}.*\|.*\|", r.text)
 
-    tmp = filterLastSlash(tmp)
 
     for item in tmp:
         if item.strip() == "":
@@ -433,6 +434,7 @@ linvgatranslate()
 searx_searxng()
 whoogle()
 rimgo()
+mightyList = filterLastSlash(mightyList)
 
 cloudflare = []
 authenticate = []