• Stars
    star
    148
  • Rank 248,503 (Top 5 %)
  • Language
    Python
  • Created over 5 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A packer/unpacker for Apple Keynote presentation files.

keynote-parser

build:

keynote-parser is a Python module for unpacking and re-packing Apple Keynote .key files. It supports Keynote files generated by Keynote version 13.1 (current as of June 2023).

Keynote uses a proprietary, compressed binary format to store its presentations. This format is comprised of a zip file containing images and videos, as well as Snappy-compressed Protobuf .iwa files containing metadata, text, and all other definitions used in the presentation.

keynote-parser unpacks these component files into .yaml files in a directory, making them editable by text editors and/or scripts, then allows re-packing of these files into a working Keynote archive.

What could you use this for? Well, I use it to allow versioning of Keynote files in Git, which makes diffs more understandable (rather than binary), as well as modifying text in Keynote files in response to external scripts. (e.g.: figures that update from databases before giving a presentation)

Installation

pip3 install keynote-parser

Usage

# Unpack MyPresentation.key into ./MyPresentation/
keynote-parser unpack MyPresentation.key

# Re-pack ./MyPresentation/ into MyPresentation.out.key
keynote-parser pack ./MyPresentation/

# List the files within a Keynote archive
keynote-parser ls MyPresentation.key

# Dump a particular .iwa file into its yaml representation on stdout
keynote-parser cat MyPresentation.key /Index/Slide-00001.iwa

# Replace text within a Keynote file in-place
keynote-parser replace MyPresentation.key --find "hello world" --replace "hello dolly"

Formats

keynote-parser supports reading a list of replacements from a JSON file passed in as --replacements. This file must have the form:

{
  "replacements": [
    {
      "find": "regexp to search for",
      "replace": "string to replace with"
    },
    ...
  ]
}

This argument can be passed to keynote-parser replace to replace text in a Keynote file in-place. It can also be passed to keynote-parser pack to pack a directory into a Keynote file, replacing text along the way.

Replacing Images

The replacements json format can also be used to replace images in a Keynote file. To do so:

  • Use the keynote-parser ls command to determine the name of the image to replace.
  • Set the find pattern to the image's name, with the -\d\d\d suffix removed.
  • Set the replace field to the local path to the replacement image.

keynote-parser will automatically rescale the replacement image to fit all of the sizes of the target image.

Compatibility

Note that between Keynote 10.2 and Keynote 11.2, a number of Protobuf definitions used by Keynote have changed names. keynote-parser does not yet support backwards compatibility: it can only read .key files as the currently-supported Keynote version would, and will write .yaml output with keys that match the current names of the keys. This means that .yaml files generated with older versions of keynote-parser may not be readable by with v1.11.2.1 or higher of keynote-parser.

Until this issue is fixed (if it's ever fixed) - to properly read .yaml files created by older versions of keynote-parser:

  • use an older version of keynote-parser to read the file
  • write a .key (or .iwa) file with that older version
  • upgrade keynote-parser
  • read that resulting .iwa file in the newer version of keynote-parser

Updates

As keynote-parser includes Protobuf definitions extracted from a copy of Keynote, new versions of Keynote will inevitably create .key files that cannot be read by keynote-parser. As new versions of Keynote are released, updates to keynote-parser can be made automatically by running the following on a macOS machine with Keynote installed:

cd dumper
make clean
make

Troubleshooting

Unable to complete installation due to snappy-c.h not found.

snappy/snappymodule.cc:31:10: fatal error: 'snappy-c.h' file not found

This means you're missing the Snappy libraries. Install Snappy via whatever method your OS supports. e.g. brew install snappy, sudo apt-get install libsnappy-dev, etc.

Credits

keynote-parser was built by Peter Sobot but heavily based on prior work by Sean Patrick O'Brien. A copy of O'Brien's format documentation is included in the docs folder for posterity.

License

All code in this repository is licensed under the MIT License.

Copyright 2019-2023 Peter Sobot

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

wub-machine

Automatic Dubstep/Electro-House remixer app, powered by the Echo Nest Remix API.
Python
133
star
2

SampleScanner

Convert hardware MIDI instruments into software instruments from the command line.
Python
99
star
3

foreverfm

Your infinite DJ. An endless stream of beatmatched music from SoundCloud.
JavaScript
95
star
4

pressure

A synchronized bounded message queue built on Redis.
C
83
star
5

hangover

Native Mac OS X client for Google Hangouts. Not maintained - use Parrot instead:
Swift
58
star
6

machine-learning-for-drummers

An introductory machine learning classifier for drum samples.
Python
37
star
7

traktor

Automatic cuepoint generator for Traktor DJ software. Uses EchoNest analysis.
Python
36
star
8

musicboy

A high-quality audio playback cartridge for Nintendo® Game Boy® and Game Boy Color®.
C
36
star
9

arduino-coldfire-bdm

An interface to Motorola® Coldfire processors' Background Debug Interface (BDM) using an Arduino.
Python
15
star
10

secalculator

A handy financial calculator to estimate the cost of a Waterloo Software Engineering degree.
JavaScript
14
star
11

smartcrop

An intelligent image thumbnailer in C++, using libJPEG and some magic.
C++
13
star
12

till

A server for immutable, time-limited objects backed by local files, Redis, S3 and Rackspace.
Go
11
star
13

k2000

A Python package for working with the Kurzweil K2000/K2500/K2600 family of synthesizers.
Python
10
star
14

mp3toyoutube

Take boring old MP3s and turn them into YouTube videos.
Python
9
star
15

ninjaquote

Which of your friends said something on Facebook? (Winning entry of the Facebook@UWaterloo Hackathon 2012)
JavaScript
8
star
16

lndry

Laundry-tracking web app made for VeloCity residence
Ruby
7
star
17

ohjournal

Email-based daily journal
PHP
7
star
18

amealforme

What should I make for dinner? A single-serving site.
Ruby
6
star
19

ipsumcrypt

A small C program to embed binary data into the whitespace between words.
C
6
star
20

meet-midi-mute

Control the mute button in Google Meet with any MIDI-attached sustain pedal.
JavaScript
4
star
21

biographer

Keep your bio information consistent on all of your social networks.
Python
4
star
22

petersobot.com

Personal homepage. Small and fast. In Comic Sans.
HTML
3
star
23

samplepadpro-editor

A drum kit editor for the Alesis SamplePad line of electronic drums.
JavaScript
3
star
24

phptwidget

Simple PHP Twitter Widget
PHP
3
star
25

beatboxmachine

Automatic Beatbox remixer, powered by the Echo Nest. Made for MusicHackDay Montreal 2011. Unmaintained.
Python
3
star
26

Colourl

Dynamic analysis of the colour of web pages.
Python
3
star
27

foreverfm-relay

Bandwidth relay for Forever.fm
JavaScript
2
star
28

superupload

Javascript-based file uploader in Node.js. (for SoundCloud!)
JavaScript
2
star
29

packing-tape

A Python library for transparently reading and writing binary data formats.
Python
2
star
30

phplatestsong

Simple PHP last.fm widget
PHP
2
star
31

sehackday

The automatic showcase of SE Hack Day projects.
Ruby
2
star
32

koodo-prepaid-api

An unofficial JSON API (and visualizer) for reading data from your Koodo Prepaid account.
Python
2
star
33

csshero

CSS Hero
1
star
34

automagenta

A simple framework for running local TensorFlow experiments on GPU-enabled cloud instances with minimal fuss.
Python
1
star
35

battery-emoji

A tiny Go program that outputs your Macbook's battery state as emoji. For your shell prompt.
Go
1
star
36

pressure-python

Python client library for interfacing with Pressure queues.
Python
1
star
37

coreaudio.info

An annotated guide through Apple's Core Audio library.
1
star
38

protodump

Extract .proto files from compiled binary applications.
Python
1
star