3232 "checking your browser" , "ddos-guard" , "making sure you" ,
3333 "tollbat" , "<title>gandalf</title>" ]
3434
35+ # LibRedirect's curated instance registry covers most frontends; entries are
36+ # candidates only -- each still has to pass the live + identity checks.
37+ LIBREDIRECT = "https://raw.githubusercontent.com/libredirect/instances/main/data.json"
38+
3539# service -> {sources, test_url, markers}. markers are matched (lowercased,
3640# HTML-entity-safe) against the instance home page to confirm identity.
41+ # "lr" is the service's key in the LibRedirect data.json, if it has one.
3742SERVICES = {
3843 "lingva" : {
3944 "sources" : ["https://raw.githubusercontent.com/thedaviddelta/lingva-translate/main/README.md" ],
45+ "lr" : "lingva" ,
4046 "test_url" : "/auto/en/hola" , "markers" : ["lingva" ]},
4147 "quetre" : {
4248 "sources" : ["https://raw.githubusercontent.com/zyachel/quetre/main/README.md" ],
49+ "lr" : "quetre" ,
4350 "test_url" : "/How-does-the-Z-boson-decay" , "markers" : ["quetre" ]},
4451 "libremdb" : {
4552 "sources" : ["https://raw.githubusercontent.com/zyachel/libremdb/main/README.md" ],
53+ "lr" : "libremdb" ,
4654 "test_url" : "/title/tt0133093" , "markers" : ["libremdb" ]},
4755 "dumb" : {
4856 "sources" : ["https://raw.githubusercontent.com/rramiachraf/dumb/main/README.md" ],
57+ "lr" : "dumb" ,
4958 "test_url" : "/Naughty-boy-la-la-la-lyrics" , "markers" : ["dumb" , "genius" ]},
5059 "anonymousoverflow" : {
5160 "sources" : ["https://raw.githubusercontent.com/httpjamesm/AnonymousOverflow/main/README.md" ],
61+ "lr" : "anonymousOverflow" ,
5262 "test_url" : "/questions/6591213/how-do-i-rename-a-local-git-branch" ,
5363 "markers" : ["anonymousoverflow" , "anonymous overflow" ]},
5464 "4get" : {
5565 "sources" : ["https://4get.ca/instances" ],
5666 "test_url" : "/ami4get" , "markers" : ["4get" ]},
5767 "biblioreads" : {
5868 "sources" : ["https://raw.githubusercontent.com/nesaku/BiblioReads/main/README.md" ],
69+ "lr" : "biblioReads" ,
5970 "test_url" : "/search?q=dune" , "markers" : ["biblioreads" ]},
71+ # whoogle's own instances.txt is tiny these days; LibRedirect finds more
72+ "whoogle" : {
73+ "sources" : [], "lr" : "whoogle" ,
74+ "test_url" : "/search?cookies_disabled=1&q=current+weather" ,
75+ "markers" : ["whoogle" ]},
76+ # scribe's sourcehut registry is dead (HTTP 418); LibRedirect is the only
77+ # living source of scribe instances
78+ "scribe" : {
79+ "sources" : [], "lr" : "scribe" ,
80+ "test_url" : "/@ftrain/big-data-small-effort-b62607a43a8c" ,
81+ "markers" : ["scribe" ]},
6082}
6183
6284BAD = ("github.com" , "githubusercontent" , "shields.io" , "gitlab.com" , "codeberg.org" ,
@@ -76,6 +98,23 @@ def candidates(source):
7698 return sorted (u .rstrip ("/" ) for u in urls if not any (b in u for b in BAD ))
7799
78100
101+ _lr_data = None
102+
103+
104+ def lr_candidates (key ):
105+ global _lr_data
106+ if _lr_data is None :
107+ try :
108+ _lr_data = json .loads (fetch (LIBREDIRECT , limit = 4 * 1024 * 1024 )[1 ])
109+ except Exception as e :
110+ print (f" [libredirect] registry fetch failed ({ type (e ).__name__ } )" ,
111+ file = sys .stderr )
112+ _lr_data = {}
113+ urls = _lr_data .get (key , {}).get ("clearnet" , [])
114+ return [u .rstrip ("/" ) for u in urls
115+ if isinstance (u , str ) and u .startswith ("https://" )]
116+
117+
79118def verify (base , test_url , markers ):
80119 try : # liveness via test_url
81120 code , body = fetch (base + test_url )
@@ -104,6 +143,8 @@ def discover(svc):
104143 cands .update (candidates (s ))
105144 except Exception as e :
106145 print (f" [{ svc } ] source failed: { s } ({ type (e ).__name__ } )" , file = sys .stderr )
146+ if cfg .get ("lr" ):
147+ cands .update (lr_candidates (cfg ["lr" ]))
107148 cands = sorted (cands )
108149 good = []
109150 with cf .ThreadPoolExecutor (max_workers = 12 ) as ex :
0 commit comments