Skip to main content

django-pbsmmapi

Code to model PBS MediaManager objects; scripts to ingest data into those models.

Introduction

This is a Django app to allow Django-based projects to work with the PBS MediaManager API. It is not expected to be a COMPLETE interface to the entirety of the PBS MediaManager; however it should allow access to all of the primary content object types.

In addition to Django, huey is used for running background ingestion tasks.

Quick start

  1. Add the pbsmmapi apps to your INSTALLED_APPS setting:
    INSTALLED_APPS = [
        ...
        'pbsmmapi',
        'pbsmmapi.episode',
        'pbsmmapi.season',
        'pbsmmapi.show',
        'pbsmmapi.special',
        'pbsmmapi.franchise',
        'pbsmmapi.changelog',
    ]
  1. You ALSO need to have PBS Media Manager credentials - an API KEY and a SECRET KEY. These also go into the settings.py file of your project:
    PBSMM_API_ID = os.environ["PBSMM_API_ID"]
    PBSMM_API_SECRET = os.environ["PBSMM_API_SECRET"]

It's not a good idea to commit these in plain text. Set them as environment variables (as suggested above) or using some other secret management tool.

  1. To ingest shows and/or franchises automatically, configure PBSMM_SHOW_SLUGS and/or PBSMM_FRANCHISE_SLUGS:
PBSMM_SHOW_SLUGS = [
    "antiques-roadshow",
]

PBSMM_FRANCHISE_SLUGS = [
    "masterpiece",
]

Huey will attempt to scrape all Show and/or Franchise data, including Specials, Seasons, Episodes, and Assets. The changelog endpoint will also be scraped.

Once a complete ingest has finished, changelog data is used to ingest updated and newly added objects.

Deleted objects

When the changelog reports an object as deleted, its row is kept but its ContentRecord (mm_content) is marked with a deleted timestamp (taken from the changelog entry). The mark also stamps the records of the object's directly-attached assets — the only descendants that disappear silently: Media Manager requires children to be deleted before their parents, so every franchise/show/season/episode/special gets its own changelog delete entry (which stamps its own assets in turn), while a parent's assets never get entries of their own.

Marked objects are excluded from every ingestion path — the scrapers, the changelog API fetches and the reingest-on-update pass all skip them, and save() will not fetch for them — so they are neither re-fetched nor resurrected.

A delete is terminal. Recreating an object in the Media Manager Console produces a new content ID (ingested here as a brand-new object), and unpublishing arrives as an update action, so a delete entry is never superseded on the same content ID and there is no un-delete: the Reingest selected items admin action simply skips deleted objects. For the same reason an asset that drops out of its parent's asset list is left untouched on reingest — if it was really deleted, its own changelog delete entry marks it.

Rows are never deleted locally, so consuming projects should filter them out where appropriate:

Show.objects.filter(mm_content__deleted__isnull=True)

Delete entries already recorded in the changelog table are applied automatically by a one-time (idempotent) data migration when you run migrate after upgrading.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_pbsmmapi-1.4.0.tar.gz (87.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_pbsmmapi-1.4.0-py3-none-any.whl (145.6 kB view details)

Uploaded Python 3

File details

Details for the file django_pbsmmapi-1.4.0.tar.gz.

File metadata

  • Download URL: django_pbsmmapi-1.4.0.tar.gz
  • Upload date:
  • Size: 87.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_pbsmmapi-1.4.0.tar.gz
Algorithm Hash digest
SHA256 aec239951395f48e960e858765caff57728214d0b2bb0e12e7c7dcfff0d60b2b
MD5 0eff0357f574763b54379514bfffc51c
BLAKE2b-256 ee9190ee07f3e410e07dd100c5d35bb54390c258e4102c6adae0e0dd6f69de43

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_pbsmmapi-1.4.0.tar.gz:

Publisher: ci.yml on WGBH/django-pbsmmapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_pbsmmapi-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: django_pbsmmapi-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 145.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_pbsmmapi-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1754f149e0c22fcd5d824d3425cd932d05ef1ef47c1c2057abc9faac2e3135d5
MD5 64c55c4f285c479c6d2c3cb41a2f691d
BLAKE2b-256 369556392269fe93c5529c88b492b7622107aed1edf42751f932f3616e32a2e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_pbsmmapi-1.4.0-py3-none-any.whl:

Publisher: ci.yml on WGBH/django-pbsmmapi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.4.4

2 files

1.4.3

2 files

1.4.2

2 files

1.4.1

2 files

This release

1.4.0 This release

2 files

1.3.6

2 files

1.3.5

2 files

1.3.4

2 files

1.3.3

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.2.5

1 file

0.2.4

2 files

0.2.3

1 file

0.2.1

1 file

0.2

1 file

0.1

1 file

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