PlexKodiConnect/resources/lib/skip_plex_intro.py

40 lines
1.3 KiB
Python
Raw Normal View History

2021-02-08 07:42:47 +11:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from .windows.skip_intro import SkipIntroDialog
2021-10-24 16:50:15 +11:00
from . import app, utils, variables as v
2021-02-08 07:42:47 +11:00
def skip_intro(intros):
try:
progress = app.APP.player.getTime()
except RuntimeError:
# XBMC is not playing any media file yet
return
2021-02-08 07:42:47 +11:00
in_intro = False
for start, end in intros:
if start <= progress < end:
in_intro = True
if in_intro and app.APP.skip_intro_dialog is None:
2021-03-14 22:55:51 +11:00
app.APP.skip_intro_dialog = SkipIntroDialog('script-plex-skip_intro.xml',
2021-02-08 07:42:47 +11:00
v.ADDON_PATH,
'default',
'1080i',
intro_end=end)
2021-10-24 16:50:15 +11:00
if utils.settings('enableAutoSkipIntro') == "true":
app.APP.skip_intro_dialog.seekTimeToIntroEnd()
else:
app.APP.skip_intro_dialog.show()
2021-02-08 07:42:47 +11:00
elif not in_intro and app.APP.skip_intro_dialog is not None:
app.APP.skip_intro_dialog.close()
app.APP.skip_intro_dialog = None
def check():
with app.APP.lock_playqueues:
playerid = list(app.PLAYSTATE.active_players)[0]
intros = app.PLAYSTATE.player_states[playerid]['intro_markers']
if not intros:
return
skip_intro(intros)