Files
legacy/modules/source.py
2022-03-01 15:12:39 +02:00

23 lines
596 B
Python

import requests
import json
import webbrowser
import modules.vars as horsy_vars
from rich import print
from modules.http_status import handle
def get_source(package):
r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}")
r_code = handle(r.status_code)
if r_code[1] not in [200, 201]:
return r_code[0]
r = r.text
r = json.loads(r)
try:
webbrowser.open(r["sourceUrl"])
return None
except:
print("[red]No source code available for this app[/]")
return "No source code available for this app"