Skip to main content

Screenplay PDF to JSON Converter

Description

After years of trying to convert screenplay PDFs to a machine-readable format consistently using Final Draft and PDF Python tools, we decided to create our own screenplay PDF to JSON converter using OpenAI vision transformers. The results are much more reliable for our purposes.

The package converts a Screenplay PDF into a JSON file using the OpenAI API, returns JSON and writes it to a local file whose name is the screenplay filename.json. The process currently costs about 50 cents via the OpenAI API to convert an hour-long pilot, but will no doubt go down in price exponentially over time.

Below is an example of the JSON structure output to file:

[
    {
        "type": "dialogue",
        "name": "JOHN",
        "modifier": "(V.O.)",
        "content": "Hello, how are you?",
        "page": 1
    },
    {
        "type": "action",
        "content": "John walks into the room.",
        "page": 3
    },
    {
        "type": "dialogue",
        "name": "MARY",
        "modifier": "(smiling)",
        "content": "I'm good, thank you!",
        "page": 4
    },
    {
        "type": "dialogue",
        "name": "JOHN",
        "content": "That's great to hear.",
        "page": 4
    },
    {
        "type": "scene",
        "content": "INT. LIVING ROOM - DAY",
        "page": 5
    }
]

Getting Started

Installation

pip install screenplay-pdf-to-json-openai

OpenAI

You will need to provide your own OpenAI key. Follow the instructions here.

Known Issues

  • Because it uses a statistical model, sometimes split action lines will be combined into a single JSON Action element and sometimes into multiple Action elements.
  • If slug-lines are used WITHOUT INT and EXT then their behaviour is unpredictable but easily detectable.

Quickstart

1. Convert Whole Screenplay and Save to JSON File

from screenplay_pdf_to_json import ScreenplayPDFToJSON
sptj = ScreenplayPDFToJSON(api_key=<your_openai_key>)
data = sptj.convert('TheEmpireStrikesBack.pdf')

2. Convert First 3 Pages of a Screenplay and Save to JSON File

from screenplay_pdf_to_json import ScreenplayPDFToJSON
sptj = ScreenplayPDFToJSON(api_key=<your_openai_key>)
data = sptj.convert('TheEmpireStrikesBack.pdf', end_page=3)

3. Estimate Cost of Converting a Screenplay

from screenplay_pdf_to_json import ScreenplayPDFToJSON
sptj = ScreenplayPDFToJSON(api_key=<your_openai_key>)
cost = sptj.estimate_cost('TheEmpireStrikesBack.pdf')
print(f"Estimated cost to convert screenplay: ${cost:.2f}")

4. Convert Screenplay with No Title Page and Save to JSON File

from screenplay_pdf_to_json import ScreenplayPDFToJSON
sptj = ScreenplayPDFToJSON(api_key=KEY, skip_title_page=False)
data3 = sptj.convert('screenplay_with_no_title_page.pdf')

Metadata

Release files for screenplay-to-json-openai 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for screenplay-to-json-openai 1.0.3
File Size Uploaded
screenplay_to_json_openai-1.0.3.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for screenplay-to-json-openai 1.0.3
File Interpreter ABI Platform
screenplay_to_json_openai-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / screenplay_to_json_openai-1.0.3.tar.gz

Download URL screenplay_to_json_openai-1.0.3.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
377eb22170a23195e202395a47e8e28965a17a9a96ebff0d6122c95e7e095aab
BLAKE2b-256 checksum
How to use checksums
08a2c27873853f68eb74a75d208790f0d10002196bbf87045ad49086ece8449c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.4

Release files / screenplay_to_json_openai-1.0.3-py3-none-any.whl

Download URL screenplay_to_json_openai-1.0.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a3934ee9b70fa853274b1c039087aff9e5b3e227a6d95e36918ed53628d1b54
BLAKE2b-256 checksum
How to use checksums
6d5d31982d2b16f7867380b0b74fd2b5a64b4a295e45f8c586b34ccffb8916e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page