van/van.py

28 lines
801 B
Python

#!/usr/bin/env python3
import os, time, argparse, platform
if platform.system() == "Windows":
clr = "cls"
else:
clr = "clear"
parser = argparse.ArgumentParser(description="plays .van files", epilog="Made by MrV on IRC")
parser.add_argument("file", help="path of file to play")
parser.add_argument("-s", "--speed", help="time between frames in seconds (default: 0)", default=0)
parser.add_argument("-e", "--encoding", help="text encoding (default: ascii)", default="ascii")
args = parser.parse_args()
file = args.file
speed = float(args.speed)
encoding = args.encoding
print("Reading...")
with open(file, "rb") as f:
raw = f.read()
data = raw.split(b"\x1b<VAN>\x1b")
os.system(clr)
for frame in data:
print(frame.decode(encoding))
time.sleep(speed)
os.system(clr)