From f3bcb6c4c5c4fee81a5c8eccbe915e781872f57c Mon Sep 17 00:00:00 2001 From: jaseg Date: Fri, 20 Jul 2018 17:12:54 +0200 Subject: Initial commit --- nyanping | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 nyanping (limited to 'nyanping') diff --git a/nyanping b/nyanping new file mode 100755 index 0000000..e5159d4 --- /dev/null +++ b/nyanping @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +import time + +import mpv +import ping + +def nyanping(destination): + p = mpv.MPV(ytdl=True) + p.play('https://www.youtube.com/watch?v=QH2-TGUlwu4') + p.loop = 'inf' + + while True: + time.sleep(0.1) + delay = ping.do_one(destination, 3.0) + print(delay) + if delay is None: # timeout + p.pause = True + continue + else: + p.pause = False + p.speed = 1/(1 + 3.3*delay) + p.command('show-text', f'{delay*1000:3f}ms') + +if __name__ == '__main__': + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('destination') + args = parser.parse_args() + + nyanping(args.destination) + -- cgit