aeidon.agents.PreviewAgent

Source: aeidon/agents/preview.py

Anchestors: aeidon.delegate.Delegate, builtins.object

class aeidon.agents.PreviewAgent
Previewing subtitles with a video player.

Methods

PreviewAgent.__init__(master)

Initialize a aeidon.PreviewAgent instance.

PreviewAgent.find_video()

Find and return the video file path based on main file’s path.

The video file is searched for in the same directory as the subtitle file. The subtitle file’s filename without extension is assumed to start with or match the video file’s filename without extension, e.g. ‘movie.avi’ for ‘movie.en.srt’.

PreviewAgent.preview(position, doc, command, offset, encoding=None, temp=False)

Start video player with command from position.

command can have variables $MILLISECONDS, $SECONDS, $SUBFILE and $VIDEOFILE. offset should be the amount of seconds before position to start. encoding can be specified if different from doc file encoding. Use True for temp to always use a temporary file for preview regardless of whether the file is changed or not.

Return a three tuple of subprocess.POpen instance, command with variables expanded and a file object to which process standard output and standard error are directed.

Raise IOError if writing to temporary file fails. Raise UnicodeError if encoding temporary file fails. Raise aeidon.ProcessError if unable to start process.