aboutsummaryrefslogtreecommitdiff
path: root/nyanping
diff options
context:
space:
mode:
authorjaseg <git@jaseg.net>2018-07-20 17:12:54 +0200
committerjaseg <git@jaseg.net>2018-07-20 17:12:54 +0200
commitf3bcb6c4c5c4fee81a5c8eccbe915e781872f57c (patch)
tree01a5e53f6d9998857c27c55ab4965594b4b9d470 /nyanping
downloadnyanping-f3bcb6c4c5c4fee81a5c8eccbe915e781872f57c.tar.gz
nyanping-f3bcb6c4c5c4fee81a5c8eccbe915e781872f57c.tar.bz2
nyanping-f3bcb6c4c5c4fee81a5c8eccbe915e781872f57c.zip
Initial commit
Diffstat (limited to 'nyanping')
-rwxr-xr-xnyanping31
1 files changed, 31 insertions, 0 deletions
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)
+