-
-
Save pyropeter/ef7e20b46a6b1b5b6c41baac1f0aca57 to your computer and use it in GitHub Desktop.
#weAreNameless
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mpv --input-ipc-server=/tmp/mpvsocket --keep-open=yes hackers-ger.mkv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import timezone, datetime | |
from socket import socket, AF_UNIX, SOCK_STREAM, SHUT_WR | |
from json import dumps | |
# adjust time as neccessary... | |
start = datetime.fromisoformat("2019-09-15T22:00+00:00") | |
sock = socket(AF_UNIX, SOCK_STREAM) | |
sock.connect("/tmp/mpvsocket") | |
delta = (datetime.now(timezone.utc) - start).total_seconds() | |
if delta < 0: | |
print("Movie has not started yet!") | |
exit() | |
msg = dumps({ | |
"command": [ | |
"set_property", | |
"playback-time", | |
delta, | |
], | |
}) + "\n" | |
sock.sendall(msg.encode("ascii")) | |
sock.shutdown(SHUT_WR) | |
response = b"" | |
while True: | |
buf = sock.recv(1024) | |
if not buf: | |
break | |
response += buf | |
sock.close() | |
print(repr(response)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment