Last active
August 19, 2017 23:00
-
-
Save Hellowlol/5114628330f82994f6c8bb08e5e51f71 to your computer and use it in GitHub Desktop.
autojump.py
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
import time | |
from plexapi.server import PlexServer | |
from functools import partial | |
baseurl = 'http://localhost:32400' | |
token = '' | |
plex = PlexServer(baseurl, token) | |
JUMPTO = 60 | |
def cb(data, plex=None, sec=None): | |
if data.get('type') == 'transcodeSession.start': | |
sessionkey = data['TranscodeSession'][0]['key'] | |
for session in plex.sessions(): | |
if session and session.transcodeSessions[0].key == sessionkey: | |
# We got the correct stream | |
session.players[0].seekTo(sec * 1000) | |
listner = plex.startAlertListener(partial(cb, plex=plex, sec=JUMPTO)) | |
while True: | |
try: | |
time.sleep(0.5) | |
except KeyboardInterrupt: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment