Skip to content

Instantly share code, notes, and snippets.

@Hellowlol
Last active August 19, 2017 23:00
Show Gist options
  • Save Hellowlol/5114628330f82994f6c8bb08e5e51f71 to your computer and use it in GitHub Desktop.
Save Hellowlol/5114628330f82994f6c8bb08e5e51f71 to your computer and use it in GitHub Desktop.
autojump.py
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