def __init__(self, filename): try: import aeidon except ImportError: prerequisites() sys.exit(1) self.fix = Config.options.fix self.filename = filename self.project = aeidon.Project() # pylint: disable=W0201 self.open() self.fixchars() if not self.fix: matches = self.search() if matches: Config.results = True deletions = self.prompt(matches) if deletions: self.project.remove_subtitles(deletions) if self.modified: self.save() elif self.fix: LOGGER.info("No changes were made to '%s'", self.filename)
def _copy_project(self, project): """Return a copy of `project` with some same properties.""" copy = aeidon.Project(project.framerate) copy.main_file = project.main_file copy.tran_file = project.tran_file copy.subtitles = [x.copy() for x in project.subtitles] return copy
def start(self) -> None: self.settings = toml.load(self.conf_file) self.multiplexing = True self.multi_server = self.settings['pyborg']['multi_server'] self.project = aeidon.Project() logger.debug("About to load subs.") self.project.open_main(self.subs_file) logger.debug("Loaded subs!") self.subtitles = self.project.subtitles self.run()
def merge_subtitles(in_filename1, in_filename2, out_filename): # create aeidon project project1 = aeidon.Project() project2 = aeidon.Project() project1.open_main(in_filename1, 'UTF-8') project2.open_main(in_filename2, 'UTF-8') # setup output format out_format = aeidon.files.new(aeidon.formats.ASS, out_filename, 'utf_8') out_format.header = header.strip() # motify event entries for subtitle in project1.subtitles: subtitle.main_text = subtitle.main_text.replace('\n', ' ') for subtitle in project2.subtitles: subtitle.main_text = subtitle.main_text.replace('\n', ' ') subtitle.ssa.style = 'Alternate' project1.subtitles.extend(project2.subtitles) project1.save_main(out_format)
def main(): filename = sys.argv[1] encoding = chardet.detect(open(filename).read())['encoding'] project = aeidon.Project() project.open_main(filename, encoding) for subtitle in project.subtitles: text = subtitle.main_text.encode('UTF-8') subtitle.main_text = corrent_chs_symbol(text).decode('UTF-8') project.save_main()
def applyDelaysToSubtitles(delays, fileName): currentIndex = 0 conf = Configuration() p = aeidon.Project() p.open_main(fileName, encoding=conf.values["Subtitles"]["Encoding"]) for s in p.subtitles: if (hmsToSec(s.get_start(aeidon.modes.TIME)) + delays[currentIndex][0] > delays[currentIndex][1]) and (currentIndex < (len(delays) - 1)): currentIndex += 1 s.shift_positions(delays[currentIndex][0]) p.save_main()
def convert(input_filename, output_filename): # create aeidon project project = aeidon.Project() project.open_main(input_filename, 'UTF-8') # setup output format output_format = aeidon.files.new(aeidon.formats.ASS, output_filename, 'utf_8') output_format.header = header.strip() project.save_main(output_format)
def process_file(self, filename, dest=None): project = aeidon.Project() try: try: project.open_main(filename, encoding='utf-8') except UnicodeError: try: project.open_main(filename, encoding='latin1') except UnicodeError: return except Exception, e: print "AEIDON: ", unicode(e) return
def process_file(self, filename, dest=None): project = aeidon.Project() try: try: project.open_main(filename, encoding='utf-8') except UnicodeError: try: project.open_main(filename, encoding='latin1') except UnicodeError: return except: logger.error("Cannot process file ", exc_info=True) return p, at = self.init_package(filename=dest, schemaid='subtitle', annotationtypeid=project.main_file.format.name) self.annotationtype=at if len(project.subtitles) > 0: self.convert(self.iterator(project)) self.progress(1.0) return self.package
def load_file(self): self.project = aeidon.Project() self.project.open_main(self.filename, 'UTF-8')
def new_project(self): """Return a new project with both main and translation files.""" project = aeidon.Project() project.open_main(self.new_subrip_file(), "ascii") project.open_translation(self.new_microdvd_file(), "ascii") return project
def _init_project(self): """Initialize :class:`aeidon.Project` with proper properties.""" framerate = gaupol.conf.editor.framerate self.project = aeidon.Project(framerate)
def _init_project(self): """Initialize :class:`aeidon.Project` with proper properties.""" limit = gaupol.conf.editor.use_undo_limit levels = gaupol.conf.editor.undo_limit undo_limit = (levels if limit else None) self.project = aeidon.Project(gaupol.conf.editor.framerate, undo_limit)
def shift_positions(filename, amount): project = aeidon.Project() project.open_main(filename, 'UTF-8') project.shift_positions(None, float(amount)) project.save_main()