commit - 15efabff9a5b649dd6576c2a6e29b1ccb0c7d9ed
commit + d76a52db79b46fd5dfa0e89a6744b573da25b862
blob - 6d6c02dd1e501e90365524b747af4b0764e33eed
blob + f87a1058a322c572f0a3a1491fa426cdfca4de44
--- lonk.py
+++ lonk.py
#!/usr/bin/env python3
-from sqlite3 import connect as sqlite3_connect
from json import loads as json_loads
+from os import environ
from pathlib import Path
from sys import stdout
from urllib.error import HTTPError, URLError
assert honk["Noise"] == honk["HTML"], honk
lines = [header, f'=> {honk["XID"]}', HtmlToGmi(_build_url()).feed(honk["HTML"])]
for donk in (honk.get("Donks") or []):
- gemini_url = urlunsplit(
- (
- "gemini",
- lonk_url.netloc,
- lonk_url.path + "/proxy",
- urlencode({"m": donk["Media"], "u": donk["URL"]}),
- ""
+ if environ.get("LONK_PROXY_MEDIA"):
+ gemini_url = urlunsplit(
+ (
+ "gemini",
+ lonk_url.netloc,
+ lonk_url.path + "/proxy",
+ urlencode({"m": donk["Media"], "u": donk["URL"]}),
+ ""
+ )
)
- )
- lines.append(f'=> {donk["URL"]}')
- lines.append(f'=> {gemini_url}')
+ lines.append(f'=> {gemini_url}')
+ else:
+ lines.append(f'=> {donk["URL"]}')
desc = donk.get("Desc") or donk.get("Name")
if desc:
lines.append(desc)
if __name__ == '__main__':
- from os import environ
-
cert_hash = environ.get("VGI_CERT_HASH")
if cert_hash:
try: