mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-12 15:50:01 -08:00
34 lines
863 B
Python
34 lines
863 B
Python
import shutil
|
|
import subprocess
|
|
|
|
import requests
|
|
|
|
|
|
def print_img(url: str):
|
|
"""helper funtion to print an image given its url
|
|
|
|
Args:
|
|
url: [TODO:description]
|
|
"""
|
|
if EXECUTABLE := shutil.which("icat"):
|
|
subprocess.run([EXECUTABLE, url])
|
|
else:
|
|
EXECUTABLE = shutil.which("chafa")
|
|
|
|
if EXECUTABLE is None:
|
|
print("chafanot found")
|
|
return
|
|
|
|
res = requests.get(url)
|
|
if res.status_code != 200:
|
|
print("Error fetching image")
|
|
return
|
|
img_bytes = res.content
|
|
"""
|
|
Change made in call to chafa. Chafa dev dropped abilty
|
|
to pull from urls. Keeping old line here just in case.
|
|
|
|
subprocess.run([EXECUTABLE, url, "--size=15x15"], input=img_bytes)
|
|
"""
|
|
subprocess.run([EXECUTABLE, "--size=15x15"], input=img_bytes)
|